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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208756 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
John McCall 2014-05-14 07:54:17 +00:00
parent dfb7a74bfe
commit 96766f9b36
2 changed files with 9 additions and 3 deletions

View File

@ -10919,14 +10919,17 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
}
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.

View File

@ -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}}