@@ -261,31 +261,26 @@ namespace SizeOf {
261
261
}
262
262
263
263
#if __cplusplus >= 201402L
264
- constexpr int IgnoredRejected () { // ref -error {{never produces a constant expression}}
264
+ constexpr int IgnoredRejected () { // both -error {{never produces a constant expression}}
265
265
int n = 0 ;
266
266
sizeof (int [n++]); // both-warning {{expression result unused}} \
267
- // ref -note 2{{subexpression not valid in a constant expression}}
267
+ // both -note 2{{subexpression not valid in a constant expression}}
268
268
return n;
269
269
}
270
- // / FIXME: This is rejected because the parameter so sizeof() is not constant.
271
- // / produce a proper diagnostic.
272
270
static_assert (IgnoredRejected() == 0, ""); // both-error {{not an integral constant expression}} \
273
- // ref -note {{in call to 'IgnoredRejected()'}}
271
+ // both -note {{in call to 'IgnoredRejected()'}}
274
272
#endif
275
273
276
274
277
275
#if __cplusplus >= 202002L
278
276
// / FIXME: The following code should be accepted.
279
- consteval int foo (int n) { // ref-error {{consteval function never produces a constant expression}}
280
- return sizeof (int [n]); // ref-note 3{{not valid in a constant expression}}
281
- }
282
- constinit int var = foo(5 ); // ref-error {{not a constant expression}} \
283
- // ref-note 2{{in call to}} \
284
- // ref-error {{does not have a constant initializer}} \
285
- // ref-note {{required by 'constinit' specifier}} \
286
- // expected-error {{is not a constant expression}} \
287
- // expected-error {{does not have a constant initializer}} \
288
- // expected-note {{required by 'constinit' specifier}} \
277
+ consteval int foo (int n) { // both-error {{consteval function never produces a constant expression}}
278
+ return sizeof (int [n]); // both-note 3{{not valid in a constant expression}}
279
+ }
280
+ constinit int var = foo(5 ); // both-error {{not a constant expression}} \
281
+ // both-note 2{{in call to}} \
282
+ // both-error {{does not have a constant initializer}} \
283
+ // both-note {{required by 'constinit' specifier}}
289
284
290
285
#endif
291
286
};
0 commit comments