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; |
| 14 | } |
| 15 | |
Douglas Gregor | b10cd04 | 2010-02-21 18:36:56 +0000 | [diff] [blame^] | 16 | void f(A* a, Foo *f, int *i, double *d) { |
Anders Carlsson | 2cf738f | 2009-08-26 19:22:42 +0000 | [diff] [blame] | 17 | a->~A(); |
| 18 | a->A::~A(); |
| 19 | |
| 20 | 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] | 21 | |
Douglas Gregor | 124b878 | 2010-02-16 19:09:40 +0000 | [diff] [blame] | 22 | // FIXME: the diagnostic below isn't wonderful |
| 23 | a->~Bar(); // expected-error{{does not name a type}} |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 24 | |
| 25 | f->~Bar(); |
| 26 | f->~Foo(); |
| 27 | i->~Bar(); // expected-error{{does not match}} |
| 28 | |
| 29 | g().~Bar(); // expected-error{{non-scalar}} |
| 30 | |
| 31 | f->::~Bar(); |
Chandler Carruth | 5e895a8 | 2010-02-21 10:19:54 +0000 | [diff] [blame] | 32 | f->N::~Wibble(); // FIXME: Cannot use typedef name in destructor id. |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 33 | |
| 34 | f->::~Bar(17, 42); // expected-error{{cannot have any arguments}} |
Douglas Gregor | b10cd04 | 2010-02-21 18:36:56 +0000 | [diff] [blame^] | 35 | |
| 36 | i->~Integer(); |
| 37 | i->Integer::~Integer(); |
| 38 | |
| 39 | i->Integer::~Double(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('double') in pseudo-destructor expression}} |
Anders Carlsson | 2cf738f | 2009-08-26 19:22:42 +0000 | [diff] [blame] | 40 | } |
Douglas Gregor | a78c5c3 | 2009-09-04 18:29:40 +0000 | [diff] [blame] | 41 | |
| 42 | typedef int Integer; |
| 43 | |
| 44 | void destroy_without_call(int *ip) { |
| 45 | ip->~Integer; // expected-error{{called immediately}} |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 46 | } |
Douglas Gregor | f6e6fc8 | 2009-11-20 22:03:38 +0000 | [diff] [blame] | 47 | |
| 48 | // PR5530 |
| 49 | namespace N1 { |
| 50 | class X0 { }; |
| 51 | } |
| 52 | |
| 53 | void test_X0(N1::X0 &x0) { |
| 54 | x0.~X0(); |
| 55 | } |