[cfe-commits] r129917 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/FixIt/fixit.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Apr 21 10:29:47 PDT 2011
Author: akirtzidis
Date: Thu Apr 21 12:29:47 2011
New Revision: 129917
URL: http://llvm.org/viewvc/llvm-project?rev=129917&view=rev
Log:
Fixit suggestion for adding missing tag name should have a space after the tag name. Fixes rdar://9295072
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/FixIt/fixit.c
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=129917&r1=129916&r2=129917&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Apr 21 12:29:47 2011
@@ -1143,21 +1143,25 @@
//
// 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)
Modified: cfe/trunk/test/FixIt/fixit.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.c?rev=129917&r1=129916&r2=129917&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit.c (original)
+++ cfe/trunk/test/FixIt/fixit.c Thu Apr 21 12:29:47 2011
@@ -48,3 +48,9 @@
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'}}
+};
More information about the cfe-commits
mailing list