forked from OSchip/llvm-project
Permit redeclaration of tags introduced by using decls
This valid construct appears in MSVC headers where it's used to provide a definition for the '::type_info' compiler builtin type. llvm-svn: 199490
This commit is contained in:
parent
bf2b652c05
commit
320374c4b1
|
@ -10681,7 +10681,8 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
|
|||
}
|
||||
|
||||
if (!Previous.empty()) {
|
||||
NamedDecl *PrevDecl = (*Previous.begin())->getUnderlyingDecl();
|
||||
NamedDecl *DirectPrevDecl = *Previous.begin();
|
||||
NamedDecl *PrevDecl = DirectPrevDecl->getUnderlyingDecl();
|
||||
|
||||
// It's okay to have a tag decl in the same scope as a typedef
|
||||
// which hides a tag decl in the same scope. Finding this
|
||||
|
@ -10713,7 +10714,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
|
|||
// in the same scope (so that the definition/declaration completes or
|
||||
// rementions the tag), reuse the decl.
|
||||
if (TUK == TUK_Reference || TUK == TUK_Friend ||
|
||||
isDeclInScope(PrevDecl, SearchDC, S,
|
||||
isDeclInScope(DirectPrevDecl, SearchDC, S,
|
||||
SS.isNotEmpty() || isExplicitSpecialization)) {
|
||||
// Make sure that this wasn't declared as an enum and now used as a
|
||||
// struct or something similar.
|
||||
|
|
|
@ -119,6 +119,27 @@ namespace foo
|
|||
};
|
||||
}
|
||||
|
||||
namespace using_tag_redeclaration
|
||||
{
|
||||
struct S;
|
||||
namespace N {
|
||||
using ::using_tag_redeclaration::S;
|
||||
struct S {}; // expected-note {{previous definition is here}}
|
||||
}
|
||||
void f() {
|
||||
N::S s1;
|
||||
S s2;
|
||||
}
|
||||
void g() {
|
||||
struct S; // expected-note {{forward declaration of 'S'}}
|
||||
S s3; // expected-error {{variable has incomplete type 'S'}}
|
||||
}
|
||||
void h() {
|
||||
using ::using_tag_redeclaration::S;
|
||||
struct S {}; // expected-error {{redefinition of 'S'}}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't suggest non-typenames for positions requiring typenames.
|
||||
namespace using_suggestion_tyname_val {
|
||||
namespace N { void FFF() {} }
|
||||
|
|
Loading…
Reference in New Issue