Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Anders Carlsson | 2cf738f | 2009-08-26 19:22:42 +0000 | [diff] [blame] | 2 | struct A {}; |
| 3 | |
| 4 | enum Foo { F }; |
| 5 | typedef Foo Bar; |
| 6 | |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 7 | typedef int Integer; |
Douglas Gregor | b10cd04 | 2010-02-21 18:36:56 +0000 | [diff] [blame] | 8 | typedef double Double; |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 9 | |
| 10 | void g(); |
| 11 | |
| 12 | namespace N { |
| 13 | typedef Foo Wibble; |
Douglas Gregor | 7754908 | 2010-02-24 21:29:12 +0000 | [diff] [blame^] | 14 | typedef int OtherInteger; |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 15 | } |
| 16 | |
Douglas Gregor | b10cd04 | 2010-02-21 18:36:56 +0000 | [diff] [blame] | 17 | void f(A* a, Foo *f, int *i, double *d) { |
Anders Carlsson | 2cf738f | 2009-08-26 19:22:42 +0000 | [diff] [blame] | 18 | a->~A(); |
| 19 | a->A::~A(); |
| 20 | |
| 21 | a->~foo(); // expected-error{{identifier 'foo' in pseudo-destructor expression does not name a type}} |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 22 | |
Douglas Gregor | 124b878 | 2010-02-16 19:09:40 +0000 | [diff] [blame] | 23 | // FIXME: the diagnostic below isn't wonderful |
| 24 | a->~Bar(); // expected-error{{does not name a type}} |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 25 | |
| 26 | f->~Bar(); |
| 27 | f->~Foo(); |
| 28 | i->~Bar(); // expected-error{{does not match}} |
| 29 | |
| 30 | g().~Bar(); // expected-error{{non-scalar}} |
| 31 | |
| 32 | f->::~Bar(); |
Douglas Gregor | 93649fd | 2010-02-23 00:15:22 +0000 | [diff] [blame] | 33 | f->N::~Wibble(); // FIXME: technically, Wibble isn't a class-name |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 34 | |
| 35 | f->::~Bar(17, 42); // expected-error{{cannot have any arguments}} |
Douglas Gregor | b10cd04 | 2010-02-21 18:36:56 +0000 | [diff] [blame] | 36 | |
| 37 | i->~Integer(); |
| 38 | i->Integer::~Integer(); |
Douglas Gregor | 7754908 | 2010-02-24 21:29:12 +0000 | [diff] [blame^] | 39 | i->N::~OtherInteger(); |
| 40 | i->N::OtherInteger::~OtherInteger(); |
| 41 | i->N::OtherInteger::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}} |
| 42 | i->N::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}} |
| 43 | i->Integer::~Double(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('Double' (aka 'double')) in pseudo-destructor expression}} |
Anders Carlsson | 2cf738f | 2009-08-26 19:22:42 +0000 | [diff] [blame] | 44 | } |
Douglas Gregor | a78c5c3 | 2009-09-04 18:29:40 +0000 | [diff] [blame] | 45 | |
| 46 | typedef int Integer; |
| 47 | |
| 48 | void destroy_without_call(int *ip) { |
| 49 | ip->~Integer; // expected-error{{called immediately}} |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 50 | } |
Douglas Gregor | f6e6fc8 | 2009-11-20 22:03:38 +0000 | [diff] [blame] | 51 | |
| 52 | // PR5530 |
| 53 | namespace N1 { |
| 54 | class X0 { }; |
| 55 | } |
| 56 | |
| 57 | void test_X0(N1::X0 &x0) { |
| 58 | x0.~X0(); |
| 59 | } |