[Parser] Fix attr infloop on "int x [[c"
authorSam McCall <sam.mccall@gmail.com>
Sat, 7 Aug 2021 11:28:33 +0000 (13:28 +0200)
committerSam McCall <sam.mccall@gmail.com>
Tue, 10 Aug 2021 13:03:08 +0000 (15:03 +0200)
Similar to ad2d6bbb1435cef0a048c9aed3dcf9617640f222

Differential Revision: https://reviews.llvm.org/D107693

clang/lib/Parse/ParseDeclCXX.cpp
clang/test/Parser/cxx-attributes.cpp

index 23d22c7..bf01099 100644 (file)
@@ -4385,7 +4385,7 @@ void Parser::ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
   llvm::SmallDenseMap<IdentifierInfo*, SourceLocation, 4> SeenAttrs;
 
   bool AttrParsed = false;
-  while (!Tok.isOneOf(tok::r_square, tok::semi)) {
+  while (!Tok.isOneOf(tok::r_square, tok::semi, tok::eof)) {
     if (AttrParsed) {
       // If we parsed an attribute, a comma is required before parsing any
       // additional attributes.
index d445e42..bb222f9 100644 (file)
@@ -42,3 +42,6 @@ void fn() {
 [[,,maybe_unused,]] int Commas4; // ok
 [[foo bar]] int NoComma; // expected-error {{expected ','}} \
                          // expected-warning {{unknown attribute 'foo' ignored}}
+// expected-error@+2 2 {{expected ']'}}
+// expected-error@+1 {{expected external declaration}}
+[[foo