[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / virtual-base-used.cpp
blobaa19010e4cee4b96f61eda82ee76f9cdf5a88f78
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 // PR7800
9 // The Microsoft ABI doesn't have the concept of key functions, so we have different
10 // expectations about when functions are first required for that case.
12 class NoDestroy { ~NoDestroy(); };
13 #if __cplusplus <= 199711L
14 // expected-note@-2 3 {{declared private here}}
15 #ifdef MSABI
16 // expected-note@-4 3 {{declared private here}}
17 #endif
18 #endif
20 struct A {
21 virtual ~A();
22 #if __cplusplus >= 201103L
23 // expected-note@-2 3 {{overridden virtual function is here}}
24 #endif
27 struct B : public virtual A {
28 #if __cplusplus >= 201103L
29 // expected-error@-2 {{deleted function '~B' cannot override a non-deleted function}}
30 // expected-note@-3 {{overridden virtual function is here}}
31 #endif
33 NoDestroy x;
34 #if __cplusplus <= 199711L
35 // expected-error@-2 {{field of type 'NoDestroy' has private destructor}}
36 #ifdef MSABI
37 // expected-error@-4 {{field of type 'NoDestroy' has private destructor}}
38 #endif
39 #else
40 // expected-note@-7 {{destructor of 'B' is implicitly deleted because field 'x' has an inaccessible destructor}}
41 #ifdef MSABI
42 // expected-note@-9 {{default constructor of 'B' is implicitly deleted because field 'x' has an inaccessible destructor}}
43 #endif
44 #endif
47 struct D : public virtual B {
48 #if __cplusplus <= 199711L
49 #ifdef MSABI
50 // expected-note@-3 {{implicit default constructor for 'B' first required here}}
51 // expected-note@-4 {{implicit destructor for 'B' first required here}}
52 #endif
53 #else
54 #ifdef MSABI
55 // expected-note@-8 {{default constructor of 'D' is implicitly deleted because base class 'B' has a deleted default constructor}}
56 #endif
57 #endif
58 virtual void foo();
59 ~D();
60 #if __cplusplus >= 201103L
61 //expected-error@-2 {{non-deleted function '~D' cannot override a deleted function}}
62 #endif
65 #ifdef MSABI
66 D d;
67 #if __cplusplus <= 199711L
68 // expected-note@-2 2{{implicit default constructor for 'D' first required here}}
69 #else
70 // expected-error@-4 {{call to implicitly-deleted default constructor of 'D'}}å
71 #endif
72 #else
73 void D::foo() {
74 #if __cplusplus <= 199711L
75 // expected-note@-2 {{implicit destructor for 'B' first required here}}
76 #endif
78 #endif
80 struct E : public virtual A {
81 #if __cplusplus >= 201103L
82 // expected-error@-2 {{deleted function '~E' cannot override a non-deleted function}}
83 #endif
85 NoDestroy x;
86 #if __cplusplus <= 199711L
87 // expected-error@-2 {{field of type 'NoDestroy' has private destructor}}
88 #ifdef MSABI
89 // expected-error@-4 {{field of type 'NoDestroy' has private destructor}}
90 #endif
91 #else
92 // expected-note@-7 {{destructor of 'E' is implicitly deleted because field 'x' has an inaccessible destructor}}
93 #ifdef MSABI
94 // expected-note@-9 {{default constructor of 'E' is implicitly deleted because field 'x' has an inaccessible destructor}}
95 #endif
96 #endif
99 struct F : public E {
100 #if __cplusplus <= 199711L
101 // expected-note@-2 {{implicit destructor for 'E' first required here}}
102 #ifdef MSABI
103 // expected-note@-4 {{implicit default constructor for 'E' first required here}}
104 #endif
105 #else
106 // expected-note@-7 {{overridden virtual function is here}}
107 #ifdef MSABI
108 // expected-note@-9 {{default constructor of 'F' is implicitly deleted because base class 'E' has a deleted default constructor}}
109 #endif
110 #endif
114 struct G : public virtual F {
115 #ifdef MSABI
116 #if __cplusplus <= 199711L
117 // expected-note@-3 {{implicit default constructor for 'F' first required here}}
118 // expected-note@-4 {{implicit destructor for 'F' first required here}}
119 #else
120 // expected-note@-6 {{default constructor of 'G' is implicitly deleted because base class 'F' has a deleted default constructor}}
121 #endif
122 #endif
124 virtual void foo();
125 ~G();
126 #if __cplusplus >= 201103L
127 //expected-error@-2 {{non-deleted function '~G' cannot override a deleted function}}
128 #endif
131 #ifdef MSABI
132 G g;
133 #if __cplusplus <= 199711L
134 // expected-note@-2 2{{implicit default constructor for 'G' first required here}}
135 #else
136 // expected-error@-4 {{call to implicitly-deleted default constructor of 'G'}}
137 #endif
138 #else
139 void G::foo() {
140 #if __cplusplus <= 199711L
141 // expected-note@-2 {{implicit destructor for 'F' first required here}}
142 #endif
144 #endif
146 struct H : public virtual A {
147 #if __cplusplus >= 201103L
148 // expected-error@-2 {{deleted function '~H' cannot override a non-deleted function}}
149 // expected-note@-3 {{overridden virtual function is here}}
150 #endif
152 NoDestroy x;
153 #if __cplusplus <= 199711L
154 // expected-error@-2 {{field of type 'NoDestroy' has private destructor}}
155 #ifdef MSABI
156 // expected-error@-4 {{field of type 'NoDestroy' has private destructor}}
157 #endif
158 #else
159 // expected-note@-7 {{destructor of 'H' is implicitly deleted because field 'x' has an inaccessible destructor}}
160 #ifdef MSABI
161 // expected-note@-9 {{default constructor of 'H' is implicitly deleted because field 'x' has an inaccessible destructor}}
162 #endif
163 #endif
166 struct I : public virtual H {
167 #ifdef MSABI
168 #if __cplusplus > 199711L
169 // expected-note@-3 {{default constructor of 'I' is implicitly deleted because base class 'H' has a deleted default constructor}}
170 #endif
171 #endif
173 ~I();
174 #if __cplusplus >= 201103L
175 // expected-error@-2 {{non-deleted function '~I' cannot override a deleted function}}
176 #endif
179 struct J : public I {
180 #ifdef MSABI
181 #if __cplusplus <= 199711L
182 // expected-note@-3 {{implicit default constructor for 'H' first required here}}
183 // expected-note@-4 {{implicit destructor for 'H' first required here}}
184 #else
185 // expected-note@-6 {{default constructor of 'J' is implicitly deleted because base class 'I' has a deleted default constructor}}
186 #endif
187 #endif
189 virtual void foo();
190 ~J();
193 #ifdef MSABI
194 J j;
195 #if __cplusplus <= 199711L
196 // expected-note@-2 2{{implicit default constructor for 'J' first required here}}
197 #else
198 // expected-error@-4 {{call to implicitly-deleted default constructor of 'J'}}
199 #endif
201 #else
202 void J::foo() {
203 #if __cplusplus <= 199711L
204 // expected-note@-2 {{implicit destructor for 'H' first required here}}
205 #endif
207 #endif