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'}} \ |
| 21 | // expected-error{{destructor cannot have a return type}} \ |
| 22 | // expected-error{{destructor cannot have any parameters}} \ |
| 23 | // expected-error{{destructor cannot be variadic}} |
| 24 | }; |
| 25 | |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame^] | 26 | |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 27 | struct E; |
| 28 | |
| 29 | typedef E E_typedef; |
| 30 | struct E { |
Chris Lattner | d0344a4 | 2009-02-19 23:45:49 +0000 | [diff] [blame] | 31 | ~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] | 32 | }; |
| 33 | |
| 34 | struct F { |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 35 | (~F)(); // expected-note {{previous declaration is here}} |
| 36 | ~F(); // expected-error {{destructor cannot be redeclared}} |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 37 | }; |
| 38 | |
Argyrios Kyrtzidis | c7ed9c6 | 2008-11-07 22:02:30 +0000 | [diff] [blame] | 39 | ~; // expected-error {{expected class name}} |
| 40 | ~undef(); // expected-error {{expected class name}} |
| 41 | ~F(){} // expected-error {{destructor must be a non-static member function}} |
Douglas Gregor | 9d35097 | 2008-12-12 08:25:50 +0000 | [diff] [blame] | 42 | |
| 43 | struct G { |
| 44 | ~G(); |
| 45 | }; |
| 46 | |
| 47 | G::~G() { } |
| 48 | |