destructor.cpp revision eaaebc7cf10dc1a2016183a262ad3256bc468759
1// RUN: clang-cc -fsyntax-only -verify %s
2class 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
26
27struct E;
28
29typedef E E_typedef;
30struct E {
31  ~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' (aka 'struct E') of the class name}}
32};
33
34struct F {
35  (~F)(); // expected-note {{previous declaration is here}}
36  ~F(); // expected-error {{destructor cannot be redeclared}}
37};
38
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}}
42
43struct G {
44  ~G();
45};
46
47G::~G() { }
48
49