Maybe add new warning for shadowing simple tag types

llvm-svn: 197408
This commit is contained in:
Kaelyn Uhrain 2013-12-16 19:19:13 +00:00
parent 0eb1ebeaac
commit a1c32d53fb
2 changed files with 11 additions and 1 deletions

View File

@ -3662,6 +3662,10 @@ def err_redefinition_different_type : Error<
"redefinition of %0 with a different type%diff{: $ vs $|}1,2">;
def err_redefinition_different_kind : Error<
"redefinition of %0 as different kind of symbol">;
def warn_declaration_shadows_tag_type : Warning<
"declaration of %0 shadows %1 %0; '%1' tag will be needed to refer to the %1">,
InGroup<Shadow>, DefaultIgnore;
def note_shadowed_tag_type_declaration : Note<"%1 %0 declared here">;
def warn_forward_class_redefinition : Warning<
"redefinition of forward class %0 of a typedef name of an object type is ignored">,
InGroup<DiagGroup<"objc-forward-class-redefinition">>;

View File

@ -4398,8 +4398,14 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D,
// tag type. Note that this does does not apply if we're declaring a
// typedef (C++ [dcl.typedef]p4).
if (Previous.isSingleTagDecl() &&
D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef)
D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef) {
TagDecl *TD = Previous.getAsSingle<TagDecl>();
Diag(D.getIdentifierLoc(), diag::warn_declaration_shadows_tag_type)
<< Name << TD->getKindName();
Diag(TD->getLocation(), diag::note_shadowed_tag_type_declaration)
<< Name << TD->getKindName();
Previous.clear();
}
// Check that there are no default arguments other than in the parameters
// of a function declaration (C++ only).