]> granicus.if.org Git - clang/commitdiff
[Parse] Don't ignore attributes after a late-parsed attr.
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Wed, 4 Jan 2017 22:43:01 +0000 (22:43 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Wed, 4 Jan 2017 22:43:01 +0000 (22:43 +0000)
Without this, we drop everything after the first late-parsed attribute
in a single __attribute__. (Where "drop" means "stuff everything into
LA->Toks.")

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291020 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/Sema/warn-thread-safety-analysis.c

index ad400574731043964a30a3c26968d7b129761633..ba24adefe6b0215586a55b02eb762b451a01ff8d 100644 (file)
@@ -177,8 +177,12 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs,
       if (!ClassStack.empty() && !LateAttrs->parseSoon())
         getCurrentClass().LateParsedDeclarations.push_back(LA);
 
-      // consume everything up to and including the matching right parens
-      ConsumeAndStoreUntil(tok::r_paren, LA->Toks, true, false);
+      // Be sure ConsumeAndStoreUntil doesn't see the start l_paren, since it
+      // recursively consumes balanced parens.
+      LA->Toks.push_back(Tok);
+      ConsumeParen();
+      // Consume everything up to and including the matching right parens.
+      ConsumeAndStoreUntil(tok::r_paren, LA->Toks, /*StopAtSemi=*/true);
 
       Token Eof;
       Eof.startToken();
index a0c4026b913626a59db5e4dc9b2dc39076c735cf..425ce4c196a6631a3435a5cb6894fbe61725e698 100644 (file)
@@ -127,3 +127,7 @@ int main() {
 
   return 0;
 }
+
+// We had a problem where we'd skip all attributes that follow a late-parsed
+// attribute in a single __attribute__.
+void run() __attribute__((guarded_by(mu1), guarded_by(mu1))); // expected-warning 2{{only applies to fields and global variables}}