From 1f329402ae184b661e4d6455cde0deabca2c5fe1 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 21 Apr 2011 17:29:47 +0000 Subject: [PATCH] Fixit suggestion for adding missing tag name should have a space after the tag name. Fixes rdar://9295072 llvm-svn: 129917 --- clang/lib/Parse/ParseDecl.cpp | 16 ++++++++++------ clang/test/FixIt/fixit.c | 6 ++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 702f8c7cfb1e..0b06d6a4fdb9 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1143,21 +1143,25 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS, // // C++ doesn't need this, and isTagName doesn't take SS. if (SS == 0) { - const char *TagName = 0; + const char *TagName = 0, *FixitTagName = 0; tok::TokenKind TagKind = tok::unknown; switch (Actions.isTagName(*Tok.getIdentifierInfo(), getCurScope())) { default: break; - case DeclSpec::TST_enum: TagName="enum" ;TagKind=tok::kw_enum ;break; - case DeclSpec::TST_union: TagName="union" ;TagKind=tok::kw_union ;break; - case DeclSpec::TST_struct:TagName="struct";TagKind=tok::kw_struct;break; - case DeclSpec::TST_class: TagName="class" ;TagKind=tok::kw_class ;break; + case DeclSpec::TST_enum: + TagName="enum" ; FixitTagName = "enum " ; TagKind=tok::kw_enum ;break; + case DeclSpec::TST_union: + 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) { Diag(Loc, diag::err_use_of_tag_name_without_tag) << 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. if (TagKind == tok::kw_enum) diff --git a/clang/test/FixIt/fixit.c b/clang/test/FixIt/fixit.c index 9c7443594283..1a6ef635570a 100644 --- a/clang/test/FixIt/fixit.c +++ b/clang/test/FixIt/fixit.c @@ -48,3 +48,9 @@ enum Color { Green = 17 // expected-error{{missing ',' between enumerators}} 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'}} +};