destructor.cpp revision c19f959d7fa5303f2fff5fa7a4968361cb7ef068
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 any parameters}}   \
22    // expected-error{{destructor cannot be variadic}}
23};
24
25struct D2 {
26  void ~D2() { } //                          \
27  // expected-error{{destructor cannot have a return type}}
28};
29
30
31struct E;
32
33typedef E E_typedef;
34struct E {
35  ~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' (aka 'struct E') of the class name}}
36};
37
38struct F {
39  (~F)(); // expected-note {{previous declaration is here}}
40  ~F(); // expected-error {{destructor cannot be redeclared}}
41};
42
43~; // expected-error {{expected the class name after '~' to name a destructor}}
44~undef(); // expected-error {{expected the class name after '~' to name a destructor}}
45~operator+(int, int);  // expected-error {{expected the class name after '~' to name a destructor}}
46~F(){} // expected-error {{destructor must be a non-static member function}}
47
48struct G {
49  ~G();
50};
51
52G::~G() { }
53
54// <rdar://problem/6841210>
55struct H {
56  ~H(void) { }
57};
58
59struct X {};
60
61struct Y {
62  ~X(); // expected-error {{expected the class name after '~' to name the enclosing class}}
63};
64