@@ -58,13 +58,10 @@ static_assert(pointerAssign2() == 12, "");
58
58
59
59
constexpr int unInitLocal () {
60
60
int a;
61
- return a; // ref-note {{read of uninitialized object}} \
62
- // expected-note {{read of uninitialized object}}
61
+ return a; // both-note {{read of uninitialized object}}
63
62
}
64
- static_assert (unInitLocal() == 0, ""); // ref-error {{not an integral constant expression}} \
65
- // ref-note {{in call to 'unInitLocal()'}} \
66
- // expected-error {{not an integral constant expression}} \
67
- // expected-note {{in call to 'unInitLocal()'}} \
63
+ static_assert (unInitLocal() == 0, ""); // both-error {{not an integral constant expression}} \
64
+ // both-note {{in call to 'unInitLocal()'}}
68
65
69
66
constexpr int initializedLocal () {
70
67
int a;
@@ -75,25 +72,19 @@ static_assert(initializedLocal() == 20);
75
72
76
73
constexpr int initializedLocal2 () {
77
74
int a[2 ];
78
- return *a; // expected-note {{read of uninitialized object is not allowed in a constant expression}} \
79
- // ref-note {{read of uninitialized object is not allowed in a constant expression}}
75
+ return *a; // both-note {{read of uninitialized object is not allowed in a constant expression}}
80
76
}
81
- static_assert (initializedLocal2() == 20); // expected-error {{not an integral constant expression}} \
82
- // expected-note {{in call to}} \
83
- // ref-error {{not an integral constant expression}} \
84
- // ref-note {{in call to}}
77
+ static_assert (initializedLocal2() == 20); // both-error {{not an integral constant expression}} \
78
+ // both-note {{in call to}}
85
79
86
80
87
81
struct Int { int a; };
88
82
constexpr int initializedLocal3 () {
89
83
Int i;
90
- return i.a ; // ref-note {{read of uninitialized object is not allowed in a constant expression}} \
91
- // expected-note {{read of uninitialized object}}
84
+ return i.a ; // both-note {{read of uninitialized object is not allowed in a constant expression}}
92
85
}
93
- static_assert (initializedLocal3() == 20); // expected-error {{not an integral constant expression}} \
94
- // expected-note {{in call to}} \
95
- // ref-error {{not an integral constant expression}} \
96
- // ref-note {{in call to}}
86
+ static_assert (initializedLocal3() == 20); // both-error {{not an integral constant expression}} \
87
+ // both-note {{in call to}}
97
88
98
89
99
90
@@ -137,22 +128,16 @@ static_assert(!b4); // ref-error {{not an integral constant expression}} \
137
128
namespace UninitializedFields {
138
129
class A {
139
130
public:
140
- int a; // expected-note 4{{subobject declared here}} \
141
- // ref-note 4{{subobject declared here}}
131
+ int a; // both-note 4{{subobject declared here}}
142
132
constexpr A () {}
143
133
};
144
- constexpr A a; // expected-error {{must be initialized by a constant expression}} \
145
- // expected-note {{subobject 'a' is not initialized}} \
146
- // ref-error {{must be initialized by a constant expression}} \
147
- // ref-note {{subobject 'a' is not initialized}}
148
- constexpr A aarr[2 ]; // expected-error {{must be initialized by a constant expression}} \
149
- // expected-note {{subobject 'a' is not initialized}} \
150
- // ref-error {{must be initialized by a constant expression}} \
151
- // ref-note {{subobject 'a' is not initialized}}
134
+ constexpr A a; // both-error {{must be initialized by a constant expression}} \
135
+ // both-note {{subobject 'a' is not initialized}}
136
+ constexpr A aarr[2 ]; // both-error {{must be initialized by a constant expression}} \
137
+ // both-note {{subobject 'a' is not initialized}}
152
138
class F {
153
139
public:
154
- int f; // expected-note 3{{subobject declared here}} \
155
- // ref-note 3{{subobject declared here}}
140
+ int f; // both-note 3{{subobject declared here}}
156
141
157
142
constexpr F () {}
158
143
constexpr F (bool b) {
@@ -161,83 +146,64 @@ namespace UninitializedFields {
161
146
}
162
147
};
163
148
164
- constexpr F foo[2 ] = {true }; // expected-error {{must be initialized by a constant expression}} \
165
- // expected-note {{subobject 'f' is not initialized}} \
166
- // ref-error {{must be initialized by a constant expression}} \
167
- // ref-note {{subobject 'f' is not initialized}}
168
- constexpr F foo2[3 ] = {true , false , true }; // expected-error {{must be initialized by a constant expression}} \
169
- // expected-note {{subobject 'f' is not initialized}} \
170
- // ref-error {{must be initialized by a constant expression}} \
171
- // ref-note {{subobject 'f' is not initialized}}
172
- constexpr F foo3[3 ] = {true , true , F ()}; // expected-error {{must be initialized by a constant expression}} \
173
- // expected-note {{subobject 'f' is not initialized}} \
174
- // ref-error {{must be initialized by a constant expression}} \
175
- // ref-note {{subobject 'f' is not initialized}}
149
+ constexpr F foo[2 ] = {true }; // both-error {{must be initialized by a constant expression}} \
150
+ // both-note {{subobject 'f' is not initialized}}
151
+ constexpr F foo2[3 ] = {true , false , true }; // both-error {{must be initialized by a constant expression}} \
152
+ // both-note {{subobject 'f' is not initialized}}
153
+ constexpr F foo3[3 ] = {true , true , F ()}; // both-error {{must be initialized by a constant expression}} \
154
+ // both-note {{subobject 'f' is not initialized}}
176
155
177
156
178
157
179
158
class Base {
180
159
public:
181
160
bool b;
182
- int a; // expected-note {{subobject declared here}} \
183
- // ref-note {{subobject declared here}}
161
+ int a; // both-note {{subobject declared here}}
184
162
constexpr Base () : b(true ) {}
185
163
};
186
164
187
165
class Derived : public Base {
188
166
public:
189
167
constexpr Derived () : Base() {} };
190
168
191
- constexpr Derived D; // expected-error {{must be initialized by a constant expression}} \
192
- // expected-note {{subobject 'a' is not initialized}} \
193
- // ref-error {{must be initialized by a constant expression}} \
194
- // ref-note {{subobject 'a' is not initialized}}
169
+ constexpr Derived D; // both-error {{must be initialized by a constant expression}} \
170
+ // both-note {{subobject 'a' is not initialized}}
195
171
196
172
class C2 {
197
173
public:
198
174
A a;
199
175
constexpr C2 () {} };
200
- constexpr C2 c2; // expected-error {{must be initialized by a constant expression}} \
201
- // expected-note {{subobject 'a' is not initialized}} \
202
- // ref-error {{must be initialized by a constant expression}} \
203
- // ref-note {{subobject 'a' is not initialized}}
176
+ constexpr C2 c2; // both-error {{must be initialized by a constant expression}} \
177
+ // both-note {{subobject 'a' is not initialized}}
204
178
205
179
class C3 {
206
180
public:
207
181
A a[2 ];
208
182
constexpr C3 () {}
209
183
};
210
- constexpr C3 c3; // expected-error {{must be initialized by a constant expression}} \
211
- // expected-note {{subobject 'a' is not initialized}} \
212
- // ref-error {{must be initialized by a constant expression}} \
213
- // ref-note {{subobject 'a' is not initialized}}
184
+ constexpr C3 c3; // both-error {{must be initialized by a constant expression}} \
185
+ // both-note {{subobject 'a' is not initialized}}
214
186
215
187
class C4 {
216
188
public:
217
- bool B[2 ][3 ]; // expected-note {{subobject declared here}} \
218
- // ref-note {{subobject declared here}}
189
+ bool B[2 ][3 ]; // both-note {{subobject declared here}}
219
190
constexpr C4 (){}
220
191
};
221
- constexpr C4 c4; // expected-error {{must be initialized by a constant expression}} \
222
- // expected-note {{subobject 'B' is not initialized}} \
223
- // ref-error {{must be initialized by a constant expression}} \
224
- // ref-note {{subobject 'B' is not initialized}}
192
+ constexpr C4 c4; // both-error {{must be initialized by a constant expression}} \
193
+ // both-note {{subobject 'B' is not initialized}}
225
194
};
226
195
227
196
namespace ConstThis {
228
197
class Foo {
229
- const int T = 12 ; // expected-note {{declared const here}} \
230
- // ref-note {{declared const here}}
198
+ const int T = 12 ; // both-note {{declared const here}}
231
199
int a;
232
200
public:
233
201
constexpr Foo () {
234
202
this ->a = 10 ;
235
- T = 13 ; // expected-error {{cannot assign to non-static data member 'T' with const-qualified type}} \
236
- // ref-error {{cannot assign to non-static data member 'T' with const-qualified type}}
203
+ T = 13 ; // both-error {{cannot assign to non-static data member 'T' with const-qualified type}}
237
204
}
238
205
};
239
- constexpr Foo F; // expected-error {{must be initialized by a constant expression}} \
240
- // ref-error {{must be initialized by a constant expression}}
206
+ constexpr Foo F; // both-error {{must be initialized by a constant expression}}
241
207
242
208
243
209
class FooDtor {
@@ -264,8 +230,7 @@ namespace ConstThis {
264
230
constexpr ctor_test () {
265
231
if (Good)
266
232
a = 10 ;
267
- int local = 100 / a; // expected-note {{division by zero}} \
268
- // ref-note {{division by zero}}
233
+ int local = 100 / a; // both-note {{division by zero}}
269
234
}
270
235
};
271
236
@@ -277,22 +242,17 @@ namespace ConstThis {
277
242
constexpr ~dtor_test () {
278
243
if (Good)
279
244
a = 10 ;
280
- int local = 100 / a; // expected-note {{division by zero}} \
281
- // ref-note {{division by zero}}
245
+ int local = 100 / a; // both-note {{division by zero}}
282
246
}
283
247
};
284
248
285
249
constexpr ctor_test<true > good_ctor;
286
250
constexpr dtor_test<true > good_dtor;
287
251
288
- constexpr ctor_test<false > bad_ctor; // expected-error {{must be initialized by a constant expression}} \
289
- // expected-note {{in call to}} \
290
- // ref-error {{must be initialized by a constant expression}} \
291
- // ref-note {{in call to}}
292
- constexpr dtor_test<false > bad_dtor; // expected-error {{must have constant destruction}} \
293
- // expected-note {{in call to}} \
294
- // ref-error {{must have constant destruction}} \
295
- // ref-note {{in call to}}
252
+ constexpr ctor_test<false > bad_ctor; // both-error {{must be initialized by a constant expression}} \
253
+ // both-note {{in call to}}
254
+ constexpr dtor_test<false > bad_dtor; // both-error {{must have constant destruction}} \
255
+ // both-note {{in call to}}
296
256
};
297
257
298
258
namespace BaseInit {
@@ -311,10 +271,8 @@ namespace BaseInit {
311
271
};
312
272
313
273
static_assert (Final{1 , 2 , 3 }.c == 3 , " " ); // OK
314
- static_assert (Final{1 , 2 , 3 }.a == 0 , " " ); // expected-error {{not an integral constant expression}} \
315
- // expected-note {{read of uninitialized object}} \
316
- // ref-error {{not an integral constant expression}} \
317
- // ref-note {{read of uninitialized object}}
274
+ static_assert (Final{1 , 2 , 3 }.a == 0 , " " ); // both-error {{not an integral constant expression}} \
275
+ // both-note {{read of uninitialized object}}
318
276
319
277
320
278
struct Mixin {
@@ -333,10 +291,8 @@ namespace BaseInit {
333
291
334
292
static_assert (Final2{1 , 2 , 3 }.c == 3 , " " ); // OK
335
293
static_assert (Final2{1 , 2 , 3 }.b == 2 , " " ); // OK
336
- static_assert (Final2{1 , 2 , 3 }.a == 0 , " " ); // expected-error {{not an integral constant expression}} \
337
- // expected-note {{read of uninitialized object}} \
338
- // ref-error {{not an integral constant expression}} \
339
- // ref-note {{read of uninitialized object}}
294
+ static_assert (Final2{1 , 2 , 3 }.a == 0 , " " ); // both-error {{not an integral constant expression}} \
295
+ // both-note {{read of uninitialized object}}
340
296
341
297
342
298
struct Mixin3 {
@@ -352,10 +308,8 @@ namespace BaseInit {
352
308
353
309
static_assert (Final3{1 , 2 , 3 }.c == 3 , " " ); // OK
354
310
static_assert (Final3{1 , 2 , 3 }.b == 2 , " " ); // OK
355
- static_assert (Final3{1 , 2 , 3 }.a == 0 , " " ); // expected-error {{not an integral constant expression}} \
356
- // expected-note {{read of uninitialized object}} \
357
- // ref-error {{not an integral constant expression}} \
358
- // ref-note {{read of uninitialized object}}
311
+ static_assert (Final3{1 , 2 , 3 }.a == 0 , " " ); // both-error {{not an integral constant expression}} \
312
+ // both-note {{read of uninitialized object}}
359
313
};
360
314
361
315
namespace Destructors {
@@ -633,16 +587,13 @@ namespace ImplicitFunction {
633
587
634
588
// / The operator= call here will fail and the diagnostics should be fine.
635
589
b = a; // ref-note {{subobject 'a' is not initialized}} \
636
- // ref-note {{in call to}} \
637
590
// expected-note {{read of uninitialized object}} \
638
- // expected -note {{in call to}}
591
+ // both -note {{in call to}}
639
592
640
593
return 1 ;
641
594
}
642
- static_assert (callMe() == 1 , " " ); // ref-error {{not an integral constant expression}} \
643
- // ref-note {{in call to 'callMe()'}} \
644
- // expected-error {{not an integral constant expression}} \
645
- // expected-note {{in call to 'callMe()'}}
595
+ static_assert (callMe() == 1 , " " ); // both-error {{not an integral constant expression}} \
596
+ // both-note {{in call to 'callMe()'}}
646
597
}
647
598
648
599
// / FIXME: Unfortunately, the similar tests in test/SemaCXX/{compare-cxx2a.cpp use member pointers,
@@ -680,8 +631,7 @@ namespace ThreeWayCmp {
680
631
static_assert (1.0 <=> 2 .f == -1 , " " );
681
632
static_assert (1.0 <=> 1.0 == 0 , " " );
682
633
static_assert (2.0 <=> 1.0 == 1 , " " );
683
- constexpr int k = (1 <=> 1 , 0 ); // expected-warning {{comparison result unused}} \
684
- // ref-warning {{comparison result unused}}
634
+ constexpr int k = (1 <=> 1 , 0 ); // both-warning {{comparison result unused}}
685
635
static_assert (k== 0 , " " );
686
636
687
637
// / Pointers.
@@ -690,10 +640,8 @@ namespace ThreeWayCmp {
690
640
constexpr const int *pa1 = &a[1 ];
691
641
constexpr const int *pa2 = &a[2 ];
692
642
constexpr const int *pb1 = &b[1 ];
693
- static_assert (pa1 <=> pb1 != 0 , " " ); // expected-error {{not an integral constant expression}} \
694
- // expected-note {{has unspecified value}} \
695
- // ref-error {{not an integral constant expression}} \
696
- // ref-note {{has unspecified value}}
643
+ static_assert (pa1 <=> pb1 != 0 , " " ); // both-error {{not an integral constant expression}} \
644
+ // both-note {{has unspecified value}} \
697
645
static_assert(pa1 <=> pa1 == 0, "");
698
646
static_assert (pa1 <=> pa2 == -1 , " " );
699
647
static_assert (pa2 <=> pa1 == 1 , " " );
0 commit comments