<div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 15, 2012 at 3:41 PM, DeLesley Hutchins <span dir="ltr"><<a href="mailto:delesley@google.com" target="_blank" class="cremed">delesley@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: delesley<br>
Date: Wed Aug 15 17:41:04 2012<br>
New Revision: 161997<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=161997&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=161997&view=rev</a><br>
Log:<br>
Thread safety analysis: prevent a compiler error in cases where a<br>
late-parsed attribute is attached to an invalid declaration.<br>
<br>
Modified:<br>
cfe/trunk/lib/Parse/ParseDecl.cpp<br>
cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=161997&r1=161996&r2=161997&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=161997&r1=161996&r2=161997&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Aug 15 17:41:04 2012<br>
@@ -866,7 +866,8 @@<br>
void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,<br>
bool EnterScope, bool OnDefinition) {<br>
for (unsigned i = 0, ni = LAs.size(); i < ni; ++i) {<br>
- LAs[i]->addDecl(D);<br>
+ if (D)<br></blockquote><div><br></div><div>Why not early return, completely out side of the for loop?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ LAs[i]->addDecl(D);<br>
ParseLexedAttribute(*LAs[i], EnterScope, OnDefinition);<br>
delete LAs[i];<br>
}<br>
<br>
Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp?rev=161997&r1=161996&r2=161997&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp?rev=161997&r1=161996&r2=161997&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp Wed Aug 15 17:41:04 2012<br>
@@ -1429,4 +1429,14 @@<br>
}<br>
<br>
<br>
+namespace InvalidDeclTest {<br>
+<br>
+class Foo { };<br>
+namespace {<br>
+void Foo::bar(Mutex* mu) LOCKS_EXCLUDED(mu) { } // \<br>
+ // expected-error {{cannot define or redeclare 'bar' here because namespace '' does not enclose namespace 'Foo'}} \<br>
+ // expected-warning {{attribute locks_excluded ignored, because it is not attached to a declaration}}<br>
+}<br>
+<br>
+} // end namespace InvalidDeclTest<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" class="cremed">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>