Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -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}} \ |
Douglas Gregor | d92ec47 | 2010-07-01 05:10:53 +0000 | [diff] [blame^] | 22 | // expected-error{{destructor cannot be variadic}} \ |
| 23 | // expected-error{{destructor cannot have a return type}} \ |
| 24 | // expected-error{{'const' qualifier is not allowed on a destructor}} |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 25 | }; |
| 26 | |
Chris Lattner | 6540180 | 2009-04-25 08:28:21 +0000 | [diff] [blame] | 27 | struct D2 { |
| 28 | void ~D2() { } // \ |
| 29 | // expected-error{{destructor cannot have a return type}} |
| 30 | }; |
| 31 | |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 32 | |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 33 | struct E; |
| 34 | |
| 35 | typedef E E_typedef; |
| 36 | struct E { |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 37 | ~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' (aka 'E') of the class name}} |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | struct F { |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 41 | (~F)(); // expected-note {{previous declaration is here}} |
| 42 | ~F(); // expected-error {{destructor cannot be redeclared}} |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
Douglas Gregor | 124b878 | 2010-02-16 19:09:40 +0000 | [diff] [blame] | 45 | ~; // expected-error {{expected a class name after '~' to name a destructor}} |
Fariborz Jahanian | 76ed9cb | 2009-07-20 22:41:12 +0000 | [diff] [blame] | 46 | ~undef(); // expected-error {{expected the class name after '~' to name a destructor}} |
Douglas Gregor | 124b878 | 2010-02-16 19:09:40 +0000 | [diff] [blame] | 47 | ~operator+(int, int); // expected-error {{expected a class name after '~' to name a destructor}} |
Argyrios Kyrtzidis | c7ed9c6 | 2008-11-07 22:02:30 +0000 | [diff] [blame] | 48 | ~F(){} // expected-error {{destructor must be a non-static member function}} |
Douglas Gregor | 9d35097 | 2008-12-12 08:25:50 +0000 | [diff] [blame] | 49 | |
| 50 | struct G { |
| 51 | ~G(); |
| 52 | }; |
| 53 | |
| 54 | G::~G() { } |
| 55 | |
Anders Carlsson | 7786d1c | 2009-04-30 23:18:11 +0000 | [diff] [blame] | 56 | // <rdar://problem/6841210> |
| 57 | struct H { |
| 58 | ~H(void) { } |
| 59 | }; |
Fariborz Jahanian | c19f959 | 2009-07-21 15:28:50 +0000 | [diff] [blame] | 60 | |
| 61 | struct X {}; |
| 62 | |
| 63 | struct Y { |
| 64 | ~X(); // expected-error {{expected the class name after '~' to name the enclosing class}} |
| 65 | }; |
Douglas Gregor | 333de06 | 2010-02-25 18:11:54 +0000 | [diff] [blame] | 66 | |
| 67 | namespace PR6421 { |
| 68 | class T; // expected-note{{forward declaration}} |
| 69 | |
| 70 | class QGenericArgument |
| 71 | { |
| 72 | template<typename U> |
| 73 | void foo(T t) // expected-error{{variable has incomplete type}} |
| 74 | { } |
| 75 | |
| 76 | void disconnect() |
| 77 | { |
| 78 | T* t; |
| 79 | bob<QGenericArgument>(t); // expected-error{{undeclared identifier 'bob'}} |
| 80 | } |
| 81 | }; |
| 82 | } |
Douglas Gregor | 9c12739 | 2010-03-26 06:57:13 +0000 | [diff] [blame] | 83 | |
| 84 | namespace PR6709 { |
| 85 | template<class T> class X { T v; ~X() { ++*v; } }; |
| 86 | void a(X<int> x) {} |
| 87 | } |
Douglas Gregor | d92ec47 | 2010-07-01 05:10:53 +0000 | [diff] [blame^] | 88 | |
| 89 | struct X0 { virtual ~X0() throw(); }; |
| 90 | struct X1 : public X0 { }; |