diff options
author | DeLesley Hutchins <delesley@google.com> | 2012-08-15 22:41:04 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2012-08-15 22:41:04 +0000 |
commit | 95526a480f252514d63a00bb032a2cb205dbf021 (patch) | |
tree | aa2173eb82bd46c2bc34ba05cd65627992eae954 | |
parent | 7f660857309a14c036a80ef90b40bf8f68fda9da (diff) |
Thread safety analysis: prevent a compiler error in cases where a
late-parsed attribute is attached to an invalid declaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161997 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 3 | ||||
-rw-r--r-- | test/SemaCXX/warn-thread-safety-parsing.cpp | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index b830d9ccfd..a50f42bf8b 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -866,7 +866,8 @@ void Parser::ParseLexedAttributes(ParsingClass &Class) { void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D, bool EnterScope, bool OnDefinition) { for (unsigned i = 0, ni = LAs.size(); i < ni; ++i) { - LAs[i]->addDecl(D); + if (D) + LAs[i]->addDecl(D); ParseLexedAttribute(*LAs[i], EnterScope, OnDefinition); delete LAs[i]; } diff --git a/test/SemaCXX/warn-thread-safety-parsing.cpp b/test/SemaCXX/warn-thread-safety-parsing.cpp index 3f8a735908..8aa6a91a9d 100644 --- a/test/SemaCXX/warn-thread-safety-parsing.cpp +++ b/test/SemaCXX/warn-thread-safety-parsing.cpp @@ -1429,4 +1429,14 @@ class Foo { } +namespace InvalidDeclTest { + +class Foo { }; +namespace { +void Foo::bar(Mutex* mu) LOCKS_EXCLUDED(mu) { } // \ + // expected-error {{cannot define or redeclare 'bar' here because namespace '' does not enclose namespace 'Foo'}} \ + // expected-warning {{attribute locks_excluded ignored, because it is not attached to a declaration}} +} + +} // end namespace InvalidDeclTest |