diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index c119c4a7d12dc8e2257a155896d6b49ef53f4ba6..39a0ec825ae7c80c8af1fc1c660684d3ed74da33 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -1000,6 +1000,9 @@ def err_pragma_invalid_keyword : Error< def warn_pragma_unroll_cuda_value_in_parens : Warning< "argument to '#pragma unroll' should not be in parentheses in CUDA C/C++">, InGroup<CudaCompat>; + +def err_empty_attribute_block : Error<"empty attribute block is not allowed">; + } // end of Parse Issue category. let CategoryName = "Modules Issue" in { diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 9ed797f881dc506d3c02d2311dd1f77838a094af..f8992e8ed92122bdeb89a898d24960c2b34eaf1c 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -3780,7 +3780,7 @@ SourceLocation Parser::SkipCXX11Attributes() { return EndLoc; } -/// ParseMicrosoftAttributes - Parse Microsoft attributes [Attr] +/// Parse one or more Microsoft-style attributes [Attr] /// /// [MS] ms-attribute: /// '[' token-seq ']' @@ -3796,6 +3796,8 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes &attrs, // FIXME: If this is actually a C++11 attribute, parse it as one. BalancedDelimiterTracker T(*this, tok::l_square); T.consumeOpen(); + if (Tok.is(tok::r_square)) + Diag(T.getOpenLocation(), diag::err_empty_attribute_block); SkipUntil(tok::r_square, StopAtSemi | StopBeforeMatch); T.consumeClose(); if (endLoc) diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c index a29f6c0b54927a443c71eaed45f795f62eed85c4..be46159f43ad414aac8d91daaad9c5145bc5a36f 100644 --- a/test/Parser/MicrosoftExtensions.c +++ b/test/Parser/MicrosoftExtensions.c @@ -55,6 +55,8 @@ int foo1([SA_Post(attr=1)] void *param); [unbalanced(attribute) /* expected-note {{to match this '['}} */ void f(void); /* expected-error {{expected ']'}} */ +[] __interface I {}; /* expected-error {{empty attribute block is not allowed}} */ + void ms_intrinsics(int a) { __noop(); __assume(a);