blob: a0c2c1e037ed428fadc4f368ec0c1420da3e89ee [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor42a552f2008-11-05 20:51:48 +00002class A {
3public:
4 ~A();
5};
6
7class B {
8public:
9 ~B() { }
10};
11
12class C {
13public:
14 (~C)() { }
15};
16
17struct 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 Gregor42a552f2008-11-05 20:51:48 +000021 // expected-error{{destructor cannot have any parameters}} \
22 // expected-error{{destructor cannot be variadic}}
23};
24
Chris Lattner65401802009-04-25 08:28:21 +000025struct D2 {
26 void ~D2() { } // \
27 // expected-error{{destructor cannot have a return type}}
28};
29
Chris Lattnereaaebc72009-04-25 08:06:05 +000030
Douglas Gregor42a552f2008-11-05 20:51:48 +000031struct E;
32
33typedef E E_typedef;
34struct E {
Chris Lattnerd0344a42009-02-19 23:45:49 +000035 ~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' (aka 'struct E') of the class name}}
Douglas Gregor42a552f2008-11-05 20:51:48 +000036};
37
38struct F {
Chris Lattner5f4a6822008-11-23 23:12:31 +000039 (~F)(); // expected-note {{previous declaration is here}}
40 ~F(); // expected-error {{destructor cannot be redeclared}}
Douglas Gregor42a552f2008-11-05 20:51:48 +000041};
42
Douglas Gregor124b8782010-02-16 19:09:40 +000043~; // expected-error {{expected a class name after '~' to name a destructor}}
Fariborz Jahanian76ed9cb2009-07-20 22:41:12 +000044~undef(); // expected-error {{expected the class name after '~' to name a destructor}}
Douglas Gregor124b8782010-02-16 19:09:40 +000045~operator+(int, int); // expected-error {{expected a class name after '~' to name a destructor}}
Argyrios Kyrtzidisc7ed9c62008-11-07 22:02:30 +000046~F(){} // expected-error {{destructor must be a non-static member function}}
Douglas Gregor9d350972008-12-12 08:25:50 +000047
48struct G {
49 ~G();
50};
51
52G::~G() { }
53
Anders Carlsson7786d1c2009-04-30 23:18:11 +000054// <rdar://problem/6841210>
55struct H {
56 ~H(void) { }
57};
Fariborz Jahanianc19f9592009-07-21 15:28:50 +000058
59struct X {};
60
61struct Y {
62 ~X(); // expected-error {{expected the class name after '~' to name the enclosing class}}
63};