forked from OSchip/llvm-project
Fixit suggestion for adding missing tag name should have a space after the tag name. Fixes rdar://9295072
llvm-svn: 129917
This commit is contained in:
parent
99fbd4d1d8
commit
1f329402ae
|
@ -1143,21 +1143,25 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
|
||||||
//
|
//
|
||||||
// C++ doesn't need this, and isTagName doesn't take SS.
|
// C++ doesn't need this, and isTagName doesn't take SS.
|
||||||
if (SS == 0) {
|
if (SS == 0) {
|
||||||
const char *TagName = 0;
|
const char *TagName = 0, *FixitTagName = 0;
|
||||||
tok::TokenKind TagKind = tok::unknown;
|
tok::TokenKind TagKind = tok::unknown;
|
||||||
|
|
||||||
switch (Actions.isTagName(*Tok.getIdentifierInfo(), getCurScope())) {
|
switch (Actions.isTagName(*Tok.getIdentifierInfo(), getCurScope())) {
|
||||||
default: break;
|
default: break;
|
||||||
case DeclSpec::TST_enum: TagName="enum" ;TagKind=tok::kw_enum ;break;
|
case DeclSpec::TST_enum:
|
||||||
case DeclSpec::TST_union: TagName="union" ;TagKind=tok::kw_union ;break;
|
TagName="enum" ; FixitTagName = "enum " ; TagKind=tok::kw_enum ;break;
|
||||||
case DeclSpec::TST_struct:TagName="struct";TagKind=tok::kw_struct;break;
|
case DeclSpec::TST_union:
|
||||||
case DeclSpec::TST_class: TagName="class" ;TagKind=tok::kw_class ;break;
|
TagName="union" ; FixitTagName = "union " ;TagKind=tok::kw_union ;break;
|
||||||
|
case DeclSpec::TST_struct:
|
||||||
|
TagName="struct"; FixitTagName = "struct ";TagKind=tok::kw_struct;break;
|
||||||
|
case DeclSpec::TST_class:
|
||||||
|
TagName="class" ; FixitTagName = "class " ;TagKind=tok::kw_class ;break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TagName) {
|
if (TagName) {
|
||||||
Diag(Loc, diag::err_use_of_tag_name_without_tag)
|
Diag(Loc, diag::err_use_of_tag_name_without_tag)
|
||||||
<< Tok.getIdentifierInfo() << TagName << getLang().CPlusPlus
|
<< Tok.getIdentifierInfo() << TagName << getLang().CPlusPlus
|
||||||
<< FixItHint::CreateInsertion(Tok.getLocation(),TagName);
|
<< FixItHint::CreateInsertion(Tok.getLocation(),FixitTagName);
|
||||||
|
|
||||||
// Parse this as a tag as if the missing tag were present.
|
// Parse this as a tag as if the missing tag were present.
|
||||||
if (TagKind == tok::kw_enum)
|
if (TagKind == tok::kw_enum)
|
||||||
|
|
|
@ -48,3 +48,9 @@ enum Color {
|
||||||
Green = 17 // expected-error{{missing ',' between enumerators}}
|
Green = 17 // expected-error{{missing ',' between enumerators}}
|
||||||
Blue,
|
Blue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// rdar://9295072
|
||||||
|
struct test_struct {
|
||||||
|
// CHECK: struct test_struct *struct_ptr;
|
||||||
|
test_struct *struct_ptr; // expected-error {{must use 'struct' tag to refer to type 'test_struct'}}
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue