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 |
8 | |
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. |
11 | |
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 |
19 | |
20 | struct A { |
21 | virtual ~A(); |
22 | #if __cplusplus >= 201103L |
23 | // expected-note@-2 3 {{overridden virtual function is here}} |
24 | #endif |
25 | }; |
26 | |
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 |
32 | |
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 |
45 | }; |
46 | |
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 |
63 | }; |
64 | |
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 |
77 | } |
78 | #endif |
79 | |
80 | struct E : public virtual A { |
81 | #if __cplusplus >= 201103L |
82 | // expected-error@-2 {{deleted function '~E' cannot override a non-deleted function}} |
83 | // expected-note@-3 {{overridden virtual function is here}} |
84 | #endif |
85 | |
86 | NoDestroy x; |
87 | #if __cplusplus <= 199711L |
88 | // expected-error@-2 {{field of type 'NoDestroy' has private destructor}} |
89 | #ifdef MSABI |
90 | // expected-error@-4 {{field of type 'NoDestroy' has private destructor}} |
91 | #endif |
92 | #else |
93 | // expected-note@-7 {{destructor of 'E' is implicitly deleted because field 'x' has an inaccessible destructor}} |
94 | #ifdef MSABI |
95 | // expected-note@-9 {{default constructor of 'E' is implicitly deleted because field 'x' has an inaccessible destructor}} |
96 | #endif |
97 | #endif |
98 | }; |
99 | |
100 | struct F : public E { |
101 | #if __cplusplus <= 199711L |
102 | // expected-note@-2 {{implicit destructor for 'E' first required here}} |
103 | #ifdef MSABI |
104 | // expected-note@-4 {{implicit default constructor for 'E' first required here}} |
105 | #endif |
106 | #else |
107 | // expected-error@-7 {{non-deleted function '~F' cannot override a deleted function}} |
108 | // expected-note@-8 {{while declaring the implicit destructor for 'F'}} |
109 | // expected-note@-9 {{overridden virtual function is here}} |
110 | #ifdef MSABI |
111 | // expected-note@-11 {{default constructor of 'F' is implicitly deleted because base class 'E' has a deleted default constructor}} |
112 | #endif |
113 | #endif |
114 | }; |
115 | |
116 | |
117 | struct G : public virtual F { |
118 | #ifdef MSABI |
119 | #if __cplusplus <= 199711L |
120 | // expected-note@-3 {{implicit default constructor for 'F' first required here}} |
121 | // expected-note@-4 {{implicit destructor for 'F' first required here}} |
122 | #else |
123 | // expected-note@-6 {{default constructor of 'G' is implicitly deleted because base class 'F' has a deleted default constructor}} |
124 | #endif |
125 | #endif |
126 | |
127 | virtual void foo(); |
128 | ~G(); |
129 | #if __cplusplus >= 201103L |
130 | //expected-error@-2 {{non-deleted function '~G' cannot override a deleted function}} |
131 | #endif |
132 | }; |
133 | |
134 | #ifdef MSABI |
135 | G g; |
136 | #if __cplusplus <= 199711L |
137 | // expected-note@-2 2{{implicit default constructor for 'G' first required here}} |
138 | #else |
139 | // expected-error@-4 {{call to implicitly-deleted default constructor of 'G'}} |
140 | #endif |
141 | #else |
142 | void G::foo() { |
143 | #if __cplusplus <= 199711L |
144 | // expected-note@-2 {{implicit destructor for 'F' first required here}} |
145 | #endif |
146 | } |
147 | #endif |
148 | |
149 | struct H : public virtual A { |
150 | #if __cplusplus >= 201103L |
151 | // expected-error@-2 {{deleted function '~H' cannot override a non-deleted function}} |
152 | // expected-note@-3 {{overridden virtual function is here}} |
153 | #endif |
154 | |
155 | NoDestroy x; |
156 | #if __cplusplus <= 199711L |
157 | // expected-error@-2 {{field of type 'NoDestroy' has private destructor}} |
158 | #ifdef MSABI |
159 | // expected-error@-4 {{field of type 'NoDestroy' has private destructor}} |
160 | #endif |
161 | #else |
162 | // expected-note@-7 {{destructor of 'H' is implicitly deleted because field 'x' has an inaccessible destructor}} |
163 | #ifdef MSABI |
164 | // expected-note@-9 {{default constructor of 'H' is implicitly deleted because field 'x' has an inaccessible destructor}} |
165 | #endif |
166 | #endif |
167 | }; |
168 | |
169 | struct I : public virtual H { |
170 | #ifdef MSABI |
171 | #if __cplusplus > 199711L |
172 | // expected-note@-3 {{default constructor of 'I' is implicitly deleted because base class 'H' has a deleted default constructor}} |
173 | #endif |
174 | #endif |
175 | |
176 | ~I(); |
177 | #if __cplusplus >= 201103L |
178 | // expected-error@-2 {{non-deleted function '~I' cannot override a deleted function}} |
179 | #endif |
180 | }; |
181 | |
182 | struct J : public I { |
183 | #ifdef MSABI |
184 | #if __cplusplus <= 199711L |
185 | // expected-note@-3 {{implicit default constructor for 'H' first required here}} |
186 | // expected-note@-4 {{implicit destructor for 'H' first required here}} |
187 | #else |
188 | // expected-note@-6 {{default constructor of 'J' is implicitly deleted because base class 'I' has a deleted default constructor}} |
189 | #endif |
190 | #endif |
191 | |
192 | virtual void foo(); |
193 | ~J(); |
194 | }; |
195 | |
196 | #ifdef MSABI |
197 | J j; |
198 | #if __cplusplus <= 199711L |
199 | // expected-note@-2 2{{implicit default constructor for 'J' first required here}} |
200 | #else |
201 | // expected-error@-4 {{call to implicitly-deleted default constructor of 'J'}} |
202 | #endif |
203 | |
204 | #else |
205 | void J::foo() { |
206 | #if __cplusplus <= 199711L |
207 | // expected-note@-2 {{implicit destructor for 'H' first required here}} |
208 | #endif |
209 | } |
210 | #endif |
211 | |