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
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];
}
}
+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