r208756 - Create a redeclaration when an elaborated type specifier

John McCall rjmccall at apple.com
Wed May 14 00:54:17 PDT 2014


Author: rjmccall
Date: Wed May 14 02:54:17 2014
New Revision: 208756

URL: http://llvm.org/viewvc/llvm-project?rev=208756&view=rev
Log:
Create a redeclaration when an elaborated type specifier
resolves to an existing declaration if there are attributes
present.

This gives us something to apply the attributes to.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/struct-decl.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=208756&r1=208755&r2=208756&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 14 02:54:17 2014
@@ -10919,14 +10919,17 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
         }
 
         if (!Invalid) {
-          // If this is a use, just return the declaration we found.
+          // If this is a use, just return the declaration we found, unless
+          // we have attributes.
 
           // FIXME: In the future, return a variant or some other clue
           // for the consumer of this Decl to know it doesn't own it.
           // For our current ASTs this shouldn't be a problem, but will
           // need to be changed with DeclGroups.
-          if ((TUK == TUK_Reference && (!PrevTagDecl->getFriendObjectKind() ||
-               getLangOpts().MicrosoftExt)) || TUK == TUK_Friend)
+          if (!Attr &&
+              ((TUK == TUK_Reference &&
+                (!PrevTagDecl->getFriendObjectKind() || getLangOpts().MicrosoftExt))
+               || TUK == TUK_Friend))
             return PrevTagDecl;
 
           // Diagnose attempts to redefine a tag.

Modified: cfe/trunk/test/Sema/struct-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/struct-decl.c?rev=208756&r1=208755&r2=208756&view=diff
==============================================================================
--- cfe/trunk/test/Sema/struct-decl.c (original)
+++ cfe/trunk/test/Sema/struct-decl.c Wed May 14 02:54:17 2014
@@ -66,3 +66,6 @@ void test_hiding() {
   struct hiding_1 *p = hiding_1();
   struct hiding_2 *q = hiding_2;
 }
+
+struct PreserveAttributes {};
+typedef struct __attribute__((noreturn)) PreserveAttributes PreserveAttributes_t; // expected-warning {{'noreturn' attribute only applies to functions and methods}}





More information about the cfe-commits mailing list