From: George Burgess IV Date: Wed, 4 Jan 2017 22:43:01 +0000 (+0000) Subject: [Parse] Don't ignore attributes after a late-parsed attr. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5465b0d08829d04fe61f7aa142707fc020d35062;p=clang [Parse] Don't ignore attributes after a late-parsed attr. 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 --- diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index ad40057473..ba24adefe6 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -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(); diff --git a/test/Sema/warn-thread-safety-analysis.c b/test/Sema/warn-thread-safety-analysis.c index a0c4026b91..425ce4c196 100644 --- a/test/Sema/warn-thread-safety-analysis.c +++ b/test/Sema/warn-thread-safety-analysis.c @@ -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}}