Skip to content

Commit 5b36bf5

Browse files
committed
[clang][NFC] Tidy up extension warnings about _Static_assert
Some tests in `dr6xx.cpp` were using C11 `_Static_assert`, and were expecting extension warnings in C++98 mode because of that. This is noise, and we can do better than that.
1 parent 4138367 commit 5b36bf5

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

clang/test/CXX/drs/dr6xx.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
// RUN: %clang_cc1 -std=c++20 %s -verify=expected,cxx11-20,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
66
// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
77

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+
813
namespace cwg600 { // cwg600: 2.8
914
struct S {
1015
void f(int);
@@ -43,8 +48,7 @@ namespace cwg601 { // cwg601: yes
4348
#endif
4449

4550
#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");
4852
#endif
4953

5054
#if MAX > 0xFFFFFFFFFFFFFFFF && 0x8000000000000000 < -1
@@ -223,15 +227,12 @@ namespace cwg619 { // cwg619: yes
223227
struct S { static int x[10]; };
224228

225229
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, "");
228231
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, "");
231233

232234
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, "");
235236

236237
void f() {
237238
extern int x[];
@@ -325,12 +326,10 @@ const bool MB_EQ_WC =
325326
',' == L',' && '\\' == L'\\' && '"' == L'"' && '\'' == L'\'';
326327
#if __STDC_MB_MIGHT_NEQ_WC__
327328
#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");
330330
#endif
331331
#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");
334333
#endif
335334
}
336335

@@ -488,8 +487,7 @@ namespace cwg642 { // cwg642: yes
488487
const int i = 2;
489488
{
490489
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, "");
493491
}
494492
}
495493

0 commit comments

Comments
 (0)