[cfe-commits] r161997 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaCXX/warn-thread-safety-parsing.cpp

Chandler Carruth chandlerc at google.com
Wed Aug 15 15:47:22 PDT 2012


On Wed, Aug 15, 2012 at 3:41 PM, DeLesley Hutchins <delesley at google.com>wrote:

> 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)
>

Why not early return, completely out side of the for loop?


> +      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
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120815/0c3f22fa/attachment.html>


More information about the cfe-commits mailing list