1 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DTEST_SPELLING -verify=c2x %s
2 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DTEST_SPELLING -fms-compatibility -verify=c2x-ms %s
3 // RUN: %clang_cc1 -fsyntax-only -std=c2x -Wpre-c2x-compat -verify=c2x-compat %s
4 // RUN: %clang_cc1 -fsyntax-only -std=c99 -verify=c99 %s
5 // RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic -verify=c99-pedantic %s
6 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify=cxx17 -x c++ %s
7 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify=cxx17-pedantic -x c++ %s
8 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify=cxx98 -x c++ %s
9 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -pedantic -verify=cxx98-pedantic -x c++ %s
10 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wpre-c++17-compat -verify=cxx17-compat -x c++ %s
12 // cxx17-no-diagnostics
15 // Only test the C++ spelling in C mode in some of the tests, to reduce the
16 // amount of diagnostics to have to check. This spelling is allowed in MS-
17 // compatibility mode in C, but otherwise produces errors.
18 static_assert(1, ""); // c2x-error {{expected parameter declarator}} \
19 // c2x-error {{expected ')'}} \
20 // c2x-note {{to match this '('}} \
21 // c2x-warning {{type specifier missing, defaults to 'int'}} \
22 // c2x-ms-warning {{use of 'static_assert' without inclusion of <assert.h> is a Microsoft extension}}
25 // We support _Static_assert as an extension in older C modes and in all C++
26 // modes, but only as a pedantic warning.
27 _Static_assert(1, ""); // c99-pedantic-warning {{'_Static_assert' is a C11 extension}} \
28 // cxx17-pedantic-warning {{'_Static_assert' is a C11 extension}} \
29 // cxx98-pedantic-warning {{'_Static_assert' is a C11 extension}}
31 // _Static_assert without a message has more complex diagnostic logic:
32 // * In C++17 or C2x mode, it's supported by default.
33 // * But there is a special compat warning flag to warn about portability to
35 // * In older standard pedantic modes, warn about supporting without a
36 // message as an extension.
37 _Static_assert(1); // c99-pedantic-warning {{'_Static_assert' with no message is a C2x extension}} \
38 // c99-warning {{'_Static_assert' with no message is a C2x extension}} \
39 // cxx98-pedantic-warning {{'static_assert' with no message is a C++17 extension}} \
40 // cxx98-warning {{'static_assert' with no message is a C++17 extension}} \
41 // c2x-compat-warning {{'_Static_assert' with no message is incompatible with C standards before C2x}} \
42 // cxx17-compat-warning {{'static_assert' with no message is incompatible with C++ standards before C++17}} \
43 // c99-pedantic-warning {{'_Static_assert' is a C11 extension}} \
44 // cxx17-pedantic-warning {{'_Static_assert' is a C11 extension}} \
45 // cxx98-pedantic-warning {{'_Static_assert' is a C11 extension}}