[clang] bd63977 - [Parser] Fix attr infloop on "int x [[c"
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 10 06:03:16 PDT 2021
Author: Sam McCall
Date: 2021-08-10T15:03:08+02:00
New Revision: bd63977ca96acc7db2a546f56a5c0ed1fc93e22a
URL: https://github.com/llvm/llvm-project/commit/bd63977ca96acc7db2a546f56a5c0ed1fc93e22a
DIFF: https://github.com/llvm/llvm-project/commit/bd63977ca96acc7db2a546f56a5c0ed1fc93e22a.diff
LOG: [Parser] Fix attr infloop on "int x [[c"
Similar to ad2d6bbb1435cef0a048c9aed3dcf9617640f222
Differential Revision: https://reviews.llvm.org/D107693
Added:
Modified:
clang/lib/Parse/ParseDeclCXX.cpp
clang/test/Parser/cxx-attributes.cpp
Removed:
################################################################################
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 23d22c7b99e9d..bf01099f5f5ce 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -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.
diff --git a/clang/test/Parser/cxx-attributes.cpp b/clang/test/Parser/cxx-attributes.cpp
index d445e42bfe08e..bb222f91f3cb9 100644
--- a/clang/test/Parser/cxx-attributes.cpp
+++ b/clang/test/Parser/cxx-attributes.cpp
@@ -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 at +2 2 {{expected ']'}}
+// expected-error at +1 {{expected external declaration}}
+[[foo
More information about the cfe-commits
mailing list