]> granicus.if.org Git - clang/commitdiff
Improve the diagnostic given when referring to a tag type without a tag (in C)
authorJohn McCall <rjmccall@apple.com>
Sun, 14 Feb 2010 01:03:10 +0000 (01:03 +0000)
committerJohn McCall <rjmccall@apple.com>
Sun, 14 Feb 2010 01:03:10 +0000 (01:03 +0000)
or that's been hidden by a non-type (in C++).

The ideal C++ diagnostic here would note the hiding declaration, but this
is a good start.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96141 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseDecl.cpp
test/Parser/declarators.c

index 04e3daffe7b7fab72239a2faf29e63aa6f8aa671..bc26c3b0dad91197d09313a3dc2c7572c0dbffb8 100644 (file)
@@ -173,7 +173,7 @@ def err_friend_invalid_in_context : Error<
 def err_unknown_typename : Error<
   "unknown type name %0">;
 def err_use_of_tag_name_without_tag : Error<
-  "use of tagged type %0 without '%1' tag">;
+  "must use '%1' tag to refer to type %0%select{| in this scope}2">;
 def err_expected_ident_in_using : Error<
   "expected an identifier in using directive">;
 def err_unexected_colon_in_nested_name_spec : Error<
index 01156a1e969d3a1c282a7c114c38fa737acf7be2..8aa69363beeedd1bd8533a47fd232b257f0e57d9 100644 (file)
@@ -733,7 +733,7 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
 
     if (TagName) {
       Diag(Loc, diag::err_use_of_tag_name_without_tag)
-        << Tok.getIdentifierInfo() << TagName
+        << Tok.getIdentifierInfo() << TagName << getLang().CPlusPlus
         << CodeModificationHint::CreateInsertion(Tok.getLocation(),TagName);
 
       // Parse this as a tag as if the missing tag were present.
index 6dd32d9676b807fd1277f887e10eb5b82ce84dbb..91803c1c5d79ec33e90a2c613bffec112d747dca 100644 (file)
@@ -47,8 +47,8 @@ int test6() { return a; }  // a should be declared.
 // Use of tagged type without tag. rdar://6783347
 struct xyz { int y; };
 enum myenum { ASDFAS };
-xyz b;         // expected-error {{use of tagged type 'xyz' without 'struct' tag}}
-myenum c;      // expected-error {{use of tagged type 'myenum' without 'enum' tag}}
+xyz b;         // expected-error {{must use 'struct' tag to refer to type 'xyz'}}
+myenum c;      // expected-error {{must use 'enum' tag to refer to type 'myenum'}}
 
 float *test7() {
   // We should recover 'b' by parsing it with a valid type of "struct xyz", which