Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1349,8 +1349,6 @@ "%0 cannot be defined in a type alias template">; def err_type_defined_in_condition : Error< "%0 cannot be defined in a condition">; -def err_type_defined_in_enum : Error< - "%0 cannot be defined in an enumeration">; def note_pure_virtual_function : Note< "unimplemented pure virtual method %0 in %1">; Index: clang/lib/Parse/ParseExpr.cpp =================================================================== --- clang/lib/Parse/ParseExpr.cpp +++ clang/lib/Parse/ParseExpr.cpp @@ -2373,7 +2373,7 @@ // Parse the type declarator. DeclSpec DS(AttrFactory); - ParseSpecifierQualifierList(DS); + ParseSpecifierQualifierList(DS, AS_none, DSC_type_specifier); Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); ParseDeclarator(DeclaratorInfo); Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14012,13 +14012,6 @@ Invalid = true; } - if (!Invalid && getLangOpts().CPlusPlus && TUK == TUK_Definition && - DC->getDeclKind() == Decl::Enum) { - Diag(New->getLocation(), diag::err_type_defined_in_enum) - << Context.getTagDeclType(New); - Invalid = true; - } - // Maybe add qualifier info. if (SS.isNotEmpty()) { if (SS.isSet()) { Index: clang/test/CXX/drs/dr5xx.cpp =================================================================== --- clang/test/CXX/drs/dr5xx.cpp +++ clang/test/CXX/drs/dr5xx.cpp @@ -424,7 +424,7 @@ while (const n = 0) {} // expected-error {{requires a type specifier}} for (const n = 0; // expected-error {{requires a type specifier}} const m = 0; ) {} // expected-error {{requires a type specifier}} - sizeof(const); // expected-error {{requires a type specifier}} + sizeof(const); // expected-error {{expected a type}} struct S { const n; // expected-error {{requires a type specifier}} operator const(); // expected-error {{expected a type}} Index: clang/test/SemaCXX/enum.cpp =================================================================== --- clang/test/SemaCXX/enum.cpp +++ clang/test/SemaCXX/enum.cpp @@ -114,7 +114,7 @@ // PR28903 struct PR28903 { enum { - PR28903_A = (enum { // expected-error-re {{'PR28903::(anonymous enum at {{.*}})' cannot be defined in an enumeration}} + PR28903_A = (enum { // expected-error-re {{'PR28903::(anonymous enum at {{.*}})' cannot be defined in a type specifier}} PR28903_B, PR28903_C = PR28903_B })