[cfe-commits] r96141 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseDecl.cpp test/Parser/declarators.c

John McCall rjmccall at apple.com
Sat Feb 13 17:03:10 PST 2010


Author: rjmccall
Date: Sat Feb 13 19:03:10 2010
New Revision: 96141

URL: http://llvm.org/viewvc/llvm-project?rev=96141&view=rev
Log:
Improve the diagnostic given when referring to a tag type without a tag (in C)
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.


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/Parser/declarators.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=96141&r1=96140&r2=96141&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Sat Feb 13 19:03:10 2010
@@ -173,7 +173,7 @@
 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<

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=96141&r1=96140&r2=96141&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sat Feb 13 19:03:10 2010
@@ -733,7 +733,7 @@
 
     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.

Modified: cfe/trunk/test/Parser/declarators.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/declarators.c?rev=96141&r1=96140&r2=96141&view=diff

==============================================================================
--- cfe/trunk/test/Parser/declarators.c (original)
+++ cfe/trunk/test/Parser/declarators.c Sat Feb 13 19:03:10 2010
@@ -47,8 +47,8 @@
 // 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





More information about the cfe-commits mailing list