[cfe-commits] r161997 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaCXX/warn-thread-safety-parsing.cpp
DeLesley Hutchins
delesley at google.com
Wed Aug 15 15:41:04 PDT 2012
Author: delesley
Date: Wed Aug 15 17:41:04 2012
New Revision: 161997
URL: http://llvm.org/viewvc/llvm-project?rev=161997&view=rev
Log:
Thread safety analysis: prevent a compiler error in cases where a
late-parsed attribute is attached to an invalid declaration.
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=161997&r1=161996&r2=161997&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Aug 15 17:41:04 2012
@@ -866,7 +866,8 @@
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];
}
Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp?rev=161997&r1=161996&r2=161997&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp Wed Aug 15 17:41:04 2012
@@ -1429,4 +1429,14 @@
}
+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
More information about the cfe-commits
mailing list