Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 2 | class A { |
| 3 | public: |
| 4 | ~A(); |
| 5 | }; |
| 6 | |
| 7 | class B { |
| 8 | public: |
| 9 | ~B() { } |
| 10 | }; |
| 11 | |
| 12 | class C { |
| 13 | public: |
| 14 | (~C)() { } |
| 15 | }; |
| 16 | |
| 17 | struct D { |
| 18 | static void ~D(int, ...) const { } // \ |
| 19 | // expected-error{{type qualifier is not allowed on this function}} \ |
| 20 | // expected-error{{destructor cannot be declared 'static'}} \ |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 21 | // expected-error{{destructor cannot have any parameters}} \ |
| 22 | // expected-error{{destructor cannot be variadic}} |
| 23 | }; |
| 24 | |
Chris Lattner | 6540180 | 2009-04-25 08:28:21 +0000 | [diff] [blame] | 25 | struct D2 { |
| 26 | void ~D2() { } // \ |
| 27 | // expected-error{{destructor cannot have a return type}} |
| 28 | }; |
| 29 | |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 30 | |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 31 | struct E; |
| 32 | |
| 33 | typedef E E_typedef; |
| 34 | struct E { |
Chris Lattner | d0344a4 | 2009-02-19 23:45:49 +0000 | [diff] [blame] | 35 | ~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' (aka 'struct E') of the class name}} |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | struct F { |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 39 | (~F)(); // expected-note {{previous declaration is here}} |
| 40 | ~F(); // expected-error {{destructor cannot be redeclared}} |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
Fariborz Jahanian | 76ed9cb | 2009-07-20 22:41:12 +0000 | [diff] [blame] | 43 | ~; // expected-error {{expected the class name after '~' to name a destructor}} |
| 44 | ~undef(); // expected-error {{expected the class name after '~' to name a destructor}} |
| 45 | ~operator+(int, int); // expected-error {{expected the class name after '~' to name a destructor}} |
Argyrios Kyrtzidis | c7ed9c6 | 2008-11-07 22:02:30 +0000 | [diff] [blame] | 46 | ~F(){} // expected-error {{destructor must be a non-static member function}} |
Douglas Gregor | 9d35097 | 2008-12-12 08:25:50 +0000 | [diff] [blame] | 47 | |
| 48 | struct G { |
| 49 | ~G(); |
| 50 | }; |
| 51 | |
| 52 | G::~G() { } |
| 53 | |
Anders Carlsson | 7786d1c | 2009-04-30 23:18:11 +0000 | [diff] [blame] | 54 | // <rdar://problem/6841210> |
| 55 | struct H { |
| 56 | ~H(void) { } |
| 57 | }; |
Fariborz Jahanian | c19f959 | 2009-07-21 15:28:50 +0000 | [diff] [blame^] | 58 | |
| 59 | struct X {}; |
| 60 | |
| 61 | struct Y { |
| 62 | ~X(); // expected-error {{expected the class name after '~' to name the enclosing class}} |
| 63 | }; |