diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -4647,6 +4647,7 @@ if (Spec.isSet() && Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected) << tok::identifier; + DS.SetTypeSpecError(); if (Tok.isNot(tok::l_brace)) { // Has no name and is not a definition. // Skip the rest of this declarator, up until the comma or semicolon. @@ -4663,6 +4664,7 @@ Tok.isNot(tok::colon)) { Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace; + DS.SetTypeSpecError(); // Skip the rest of this declarator, up until the comma or semicolon. SkipUntil(tok::comma, StopAtSemi); return; @@ -4838,6 +4840,7 @@ if (!Name && TUK != Sema::TUK_Definition) { Diag(Tok, diag::err_enumerator_unnamed_no_def); + DS.SetTypeSpecError(); // Skip the rest of this declarator, up until the comma or semicolon. SkipUntil(tok::comma, StopAtSemi); return; diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp --- a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp +++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp @@ -4,4 +4,4 @@ // will necessarily be ill-formed as a trailing return type for a function // definition), and recover with a "type cannot be defined in a trailing return // type" error. -auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} expected-error {{expected a type}} +auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} diff --git a/clang/test/CXX/drs/dr3xx.cpp b/clang/test/CXX/drs/dr3xx.cpp --- a/clang/test/CXX/drs/dr3xx.cpp +++ b/clang/test/CXX/drs/dr3xx.cpp @@ -30,7 +30,7 @@ typename T::template operator+ a; // expected-error {{typename specifier refers to a non-type template}} expected-error +{{}} // FIXME: This shouldn't say (null). class T::template operator+ b; // expected-error {{identifier followed by '<' indicates a class template specialization but (null) refers to a function template}} - enum T::template operator+ c; // expected-error {{expected identifier}} expected-error {{does not declare anything}} + enum T::template operator+ c; // expected-error {{expected identifier}} enum T::template operator+::E d; // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}} expected-error {{forward reference}} enum T::template X::E e; T::template operator+::foobar(); // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}} diff --git a/clang/test/Parser/cxx20-using-enum.cpp b/clang/test/Parser/cxx20-using-enum.cpp new file mode 100644 --- /dev/null +++ b/clang/test/Parser/cxx20-using-enum.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s + +namespace GH57347 { +namespace A {} + +void f() { + using enum A::+; // expected-error {{expected identifier}} + using enum; // expected-error {{expected identifier or '{'}} + using enum class; // expected-error {{expected identifier or '{'}} + using enum : blah; // expected-error {{unknown type name 'blah'}} expected-error {{unnamed enumeration must be a definition}} +} +} diff --git a/clang/test/Parser/recovery.cpp b/clang/test/Parser/recovery.cpp --- a/clang/test/Parser/recovery.cpp +++ b/clang/test/Parser/recovery.cpp @@ -209,7 +209,7 @@ namespace InvalidEmptyNames { // These shouldn't crash, the diagnostics aren't important. struct ::, struct ::; // expected-error 2 {{expected identifier}} expected-error 2 {{declaration of anonymous struct must be a definition}} expected-warning {{declaration does not declare anything}} -enum ::, enum ::; // expected-error 2 {{expected identifier}} expected-warning {{declaration does not declare anything}} +enum ::, enum ::; // expected-error 2 {{expected identifier}} struct ::__super, struct ::__super; // expected-error 2 {{expected identifier}} expected-error 2 {{expected '::' after '__super'}} struct ::template foo, struct ::template bar; // expected-error 2 {{expected identifier}} expected-error 2 {{declaration of anonymous struct must be a definition}} expected-warning {{declaration does not declare anything}} struct ::foo struct::; // expected-error {{no struct named 'foo' in the global namespace}} expected-error {{expected identifier}} expected-error {{declaration of anonymous struct must be a definition}} diff --git a/clang/test/Sema/enum.c b/clang/test/Sema/enum.c --- a/clang/test/Sema/enum.c +++ b/clang/test/Sema/enum.c @@ -160,7 +160,7 @@ } e; }; -enum struct GH42372_1 { // expected-error {{expected identifier or '{'}} expected-warning {{declaration does not declare anything}} +enum struct GH42372_1 { // expected-error {{expected identifier or '{'}} One }; diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp --- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp +++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp @@ -432,7 +432,7 @@ a::b c; // expected-error {{qualified name refers into a specialization of variable template 'a'}} class a {}; // expected-error {{identifier followed by '<' indicates a class template specialization but 'a' refers to a variable template}} - enum a {}; // expected-error {{expected identifier or '{'}} expected-warning {{does not declare anything}} + enum a {}; // expected-error {{expected identifier or '{'}} } namespace PR18530 { diff --git a/clang/test/SemaCXX/enum-scoped.cpp b/clang/test/SemaCXX/enum-scoped.cpp --- a/clang/test/SemaCXX/enum-scoped.cpp +++ b/clang/test/SemaCXX/enum-scoped.cpp @@ -114,8 +114,7 @@ long_enum_val = 10000 }; -enum : long x; // expected-error{{unnamed enumeration must be a definition}} \ -// expected-warning{{declaration does not declare anything}} +enum : long x; // expected-error{{unnamed enumeration must be a definition}} void PR9333() { enum class scoped_enum { yes, no, maybe };