blob: c60045bb59d1e2d8647d9f3978cde6e9bab5e20b [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -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'}} \
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 Lattnereaaebc72009-04-25 08:06:05 +000026
Douglas Gregor42a552f2008-11-05 20:51:48 +000027struct E;
28
29typedef E E_typedef;
30struct E {
Chris Lattnerd0344a42009-02-19 23:45:49 +000031 ~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 +000032};
33
34struct F {
Chris Lattner5f4a6822008-11-23 23:12:31 +000035 (~F)(); // expected-note {{previous declaration is here}}
36 ~F(); // expected-error {{destructor cannot be redeclared}}
Douglas Gregor42a552f2008-11-05 20:51:48 +000037};
38
Argyrios Kyrtzidisc7ed9c62008-11-07 22:02:30 +000039~; // 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 Gregor9d350972008-12-12 08:25:50 +000042
43struct G {
44 ~G();
45};
46
47G::~G() { }
48