|
5 | 5 | // RUN: %clang_cc1 -std=c++20 %s -verify=expected,cxx11-20,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
|
6 | 6 | // RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
|
7 | 7 |
|
| 8 | +#if __cplusplus == 199711L |
| 9 | +#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__) |
| 10 | +// cxx98-error@-1 {{variadic macros are a C99 feature}} |
| 11 | +#endif |
| 12 | + |
8 | 13 | namespace cwg600 { // cwg600: 2.8
|
9 | 14 | struct S {
|
10 | 15 | void f(int);
|
@@ -43,8 +48,7 @@ namespace cwg601 { // cwg601: yes
|
43 | 48 | #endif
|
44 | 49 |
|
45 | 50 | #if __INT_MAX__ == 0x7FFFFFFF
|
46 |
| -_Static_assert(0x80000000 < -1, "0x80000000 should be unsigned"); |
47 |
| -// expected-error@-1 {{'_Static_assert' is a C11 extension}} |
| 51 | +static_assert(0x80000000 < -1, "0x80000000 should be unsigned"); |
48 | 52 | #endif
|
49 | 53 |
|
50 | 54 | #if MAX > 0xFFFFFFFFFFFFFFFF && 0x8000000000000000 < -1
|
@@ -223,15 +227,12 @@ namespace cwg619 { // cwg619: yes
|
223 | 227 | struct S { static int x[10]; };
|
224 | 228 |
|
225 | 229 | int x[];
|
226 |
| - _Static_assert(sizeof(x) == sizeof(int) * 10, ""); |
227 |
| - // expected-error@-1 {{'_Static_assert' is a C11 extension}} |
| 230 | + static_assert(sizeof(x) == sizeof(int) * 10, ""); |
228 | 231 | extern int x[];
|
229 |
| - _Static_assert(sizeof(x) == sizeof(int) * 10, ""); |
230 |
| - // expected-error@-1 {{'_Static_assert' is a C11 extension}} |
| 232 | + static_assert(sizeof(x) == sizeof(int) * 10, ""); |
231 | 233 |
|
232 | 234 | int S::x[];
|
233 |
| - _Static_assert(sizeof(S::x) == sizeof(int) * 10, ""); |
234 |
| - // expected-error@-1 {{'_Static_assert' is a C11 extension}} |
| 235 | + static_assert(sizeof(S::x) == sizeof(int) * 10, ""); |
235 | 236 |
|
236 | 237 | void f() {
|
237 | 238 | extern int x[];
|
@@ -325,12 +326,10 @@ const bool MB_EQ_WC =
|
325 | 326 | ',' == L',' && '\\' == L'\\' && '"' == L'"' && '\'' == L'\'';
|
326 | 327 | #if __STDC_MB_MIGHT_NEQ_WC__
|
327 | 328 | #ifndef __FreeBSD__ // PR22208, FreeBSD expects us to give a bad (but conforming) answer here.
|
328 |
| -_Static_assert(!MB_EQ_WC, "__STDC_MB_MIGHT_NEQ_WC__ but all basic source characters have same representation"); |
329 |
| -// expected-error@-1 {{'_Static_assert' is a C11 extension}} |
| 329 | +static_assert(!MB_EQ_WC, "__STDC_MB_MIGHT_NEQ_WC__ but all basic source characters have same representation"); |
330 | 330 | #endif
|
331 | 331 | #else
|
332 |
| -_Static_assert(MB_EQ_WC, "!__STDC_MB_MIGHT_NEQ_WC__ but some character differs"); |
333 |
| -// expected-error@-1 {{'_Static_assert' is a C11 extension}} |
| 332 | +static_assert(MB_EQ_WC, "!__STDC_MB_MIGHT_NEQ_WC__ but some character differs"); |
334 | 333 | #endif
|
335 | 334 | }
|
336 | 335 |
|
@@ -488,8 +487,7 @@ namespace cwg642 { // cwg642: yes
|
488 | 487 | const int i = 2;
|
489 | 488 | {
|
490 | 489 | char i[i];
|
491 |
| - _Static_assert(sizeof(i) == 2, ""); |
492 |
| - // expected-error@-1 {{'_Static_assert' is a C11 extension}} |
| 490 | + static_assert(sizeof(i) == 2, ""); |
493 | 491 | }
|
494 | 492 | }
|
495 | 493 |
|
|
0 commit comments