]> granicus.if.org Git - clang/commitdiff
Clean up some error messages with anonymous structs/unions and member declaration...
authorDouglas Gregor <dgregor@apple.com>
Fri, 6 Mar 2009 23:28:18 +0000 (23:28 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 6 Mar 2009 23:28:18 +0000 (23:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66305 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticParseKinds.def
lib/Parse/ParseDecl.cpp
test/Parser/cxx-using-directive.cpp
test/Sema/anonymous-struct-union.c

index dc08aed29c3bbf1ed6c79ec4e47da85f93422aaa..ab56766a0f953e842f98d63dbac716b900d27346 100644 (file)
@@ -112,6 +112,8 @@ DIAG(err_expected_semi_decl_list, ERROR,
      "expected ';' at end of declaration list")
 DIAG(ext_expected_semi_decl_list, EXTENSION,
      "expected ';' at end of declaration list")
+DIAG(err_expected_member_name_or_semi, ERROR,
+     "expected member name or ';' after declaration specifiers")
 DIAG(err_function_declared_typedef, ERROR,
      "function definition declared 'typedef'")
 DIAG(err_expected_fn_body, ERROR,
index 50b6716df8cc8e301046f667e91c2798d34a95c8..bbe074a8fb0e0f2d48444deac8e5a6b0521e120d 100644 (file)
@@ -1868,7 +1868,10 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
     // portion is empty), if an abstract-declarator is allowed.
     D.SetIdentifier(0, Tok.getLocation());
   } else {
-    if (getLang().CPlusPlus)
+    if (D.getContext() == Declarator::MemberContext)
+      Diag(Tok, diag::err_expected_member_name_or_semi)
+        << D.getDeclSpec().getSourceRange();
+    else if (getLang().CPlusPlus)
       Diag(Tok, diag::err_expected_unqualified_id);
     else
       Diag(Tok, diag::err_expected_ident_lparen);
index b89436046be968ba9323188a0f372c86744466ad..bf89bb19211fdf3b460d22dc200ae1242e905b05 100644 (file)
@@ -13,7 +13,7 @@ namespace D {
   
   class C {
     
-    using namespace B ; // expected-error{{expected unqualified-id}}
+    using namespace B ; // expected-error{{expected member name or ';' after declaration specifiers}}
     //FIXME: this needs better error message
   };
   
index d8a445c6491323058d974587d80e1b8e4e2da516..9784236c8bfe4c0d08b3c97aadc073bb466ecf0b 100644 (file)
@@ -88,4 +88,11 @@ struct s1 {
   };
 };
 
+// PR3680
 struct {}; // expected-error{{declaration does not declare anything}}
+
+struct s2 {
+  union {
+    int a;
+  }
+}; // expected-error{{expected member name or ';' after declaration specifiers}}