summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Basic/DiagnosticParseKinds.def2
-rw-r--r--clang/lib/Parse/ParseDecl.cpp5
-rw-r--r--clang/test/Parser/cxx-using-directive.cpp2
-rw-r--r--clang/test/Sema/anonymous-struct-union.c7
4 files changed, 14 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.def b/clang/include/clang/Basic/DiagnosticParseKinds.def
index dc08aed29c3..ab56766a0f9 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.def
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.def
@@ -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,
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 50b6716df8c..bbe074a8fb0 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -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);
diff --git a/clang/test/Parser/cxx-using-directive.cpp b/clang/test/Parser/cxx-using-directive.cpp
index b89436046be..bf89bb19211 100644
--- a/clang/test/Parser/cxx-using-directive.cpp
+++ b/clang/test/Parser/cxx-using-directive.cpp
@@ -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
};
diff --git a/clang/test/Sema/anonymous-struct-union.c b/clang/test/Sema/anonymous-struct-union.c
index d8a445c6491..9784236c8bf 100644
--- a/clang/test/Sema/anonymous-struct-union.c
+++ b/clang/test/Sema/anonymous-struct-union.c
@@ -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}}
OpenPOWER on IntegriCloud