1 // RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++11 %s
4 // RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s
5 // RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++98 %s
6 // RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++11 %s
7 
8 struct A {
9   virtual ~A();
10 #if __cplusplus >= 201103L
11 // expected-note@-2 3 {{overridden virtual function is here}}
12 #endif
13 };
14 
15 struct B : A {
16 #if __cplusplus <= 199711L
17 // expected-error@-2 {{no suitable member 'operator delete' in 'B'}}
18 #else
19 // expected-error@-4 {{deleted function '~B' cannot override a non-deleted function}}
20 // expected-note@-5  {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
21 #ifdef MSABI
22 // expected-note@-7 {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
23 #endif
24 #endif
25   virtual void f();
26 
27   void operator delete (void *, int);
28 #if __cplusplus <= 199711L
29 // expected-note@-2 {{'operator delete' declared here}}
30 #endif
31 };
32 
33 #ifdef MSABI
34 B b;
35 #if __cplusplus <= 199711L
36 // expected-note@-2 {{implicit destructor for 'B' first required here}}
37 #else
38 // expected-error@-4 {{attempt to use a deleted function}}
39 #endif
40 
41 #else
f()42 void B::f() {
43 #if __cplusplus <= 199711L
44 // expected-note@-2 {{implicit destructor for 'B' first required here}}
45 #endif
46 }
47 #endif
48 
49 struct C : A {
50 #if __cplusplus <= 199711L
51 // expected-error@-2 {{no suitable member 'operator delete' in 'C'}}
52 #else
53 // expected-error@-4 {{deleted function '~C' cannot override a non-deleted function}}
54 // expected-note@-5  {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
55 #endif
56 
57   C();
58   void operator delete(void *, int);
59 #if __cplusplus <= 199711L
60 // expected-note@-2 {{'operator delete' declared here}}
61 #endif
62 };
63 
C()64 C::C() { }
65 #if __cplusplus <= 199711L
66 // expected-note@-2 {{implicit destructor for 'C' first required here}}
67 #endif
68 
69 struct D : A {
70 #if __cplusplus <= 199711L
71 // expected-error@-2 {{no suitable member 'operator delete' in 'D'}}
72 #else
73 // expected-error@-4 {{deleted function '~D' cannot override a non-deleted function}}
74 // expected-note@-5  {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
75 #endif
76   void operator delete(void *, int);
77 #if __cplusplus <= 199711L
78 // expected-note@-2 {{'operator delete' declared here}}
79 #endif
80 };
81 
f()82 void f() {
83   new D;
84 #if __cplusplus <= 199711L
85 // expected-note@-2 {{implicit destructor for 'D' first required here}}
86 #endif
87 }
88