forked from OSchip/llvm-project
clang: Fix static_assert in a few contexts in microsoft mode
Follow-up to D17444. Fixes PR48904. See bug for details. Differential Revision: https://reviews.llvm.org/D95559
This commit is contained in:
parent
7e88942d25
commit
764a7a2155
|
@ -4231,7 +4231,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
|
|||
}
|
||||
|
||||
// Parse _Static_assert declaration.
|
||||
if (Tok.is(tok::kw__Static_assert)) {
|
||||
if (Tok.isOneOf(tok::kw__Static_assert, tok::kw_static_assert)) {
|
||||
SourceLocation DeclEnd;
|
||||
ParseStaticAssertDeclaration(DeclEnd);
|
||||
continue;
|
||||
|
@ -5191,6 +5191,7 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) {
|
|||
case tok::kw_friend:
|
||||
|
||||
// static_assert-declaration
|
||||
case tok::kw_static_assert:
|
||||
case tok::kw__Static_assert:
|
||||
|
||||
// GNU typeof support.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -fms-compatibility -DMS -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -std=c99 -pedantic -fsyntax-only -verify=expected,ext %s
|
||||
// RUN: %clang_cc1 -xc++ -std=c++11 -pedantic -fsyntax-only -verify=expected,ext,cxx %s
|
||||
|
||||
|
@ -11,10 +12,17 @@ _Static_assert(1, "1 is nonzero"); // ext-warning {{'_Static_assert' is a C11 ex
|
|||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
|
||||
#ifdef MS
|
||||
static_assert(1, "1 is nonzero");
|
||||
#endif
|
||||
|
||||
void foo(void) {
|
||||
_Static_assert(1, "1 is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
#ifdef MS
|
||||
static_assert(1, "1 is nonzero");
|
||||
#endif
|
||||
}
|
||||
|
||||
_Static_assert(1, invalid); // expected-error {{expected string literal for diagnostic message in static_assert}} \
|
||||
|
@ -25,6 +33,9 @@ struct A {
|
|||
_Static_assert(1, "1 is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
#ifdef MS
|
||||
static_assert(1, "1 is nonzero");
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue