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.
llvm-svn: 208756
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 67c78ce..c43c881 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -10919,14 +10919,17 @@
}
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.
diff --git a/clang/test/Sema/struct-decl.c b/clang/test/Sema/struct-decl.c
index 8d3d74d..055f14b 100644
--- a/clang/test/Sema/struct-decl.c
+++ b/clang/test/Sema/struct-decl.c
@@ -66,3 +66,6 @@
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}}