===================================================================
@@ -16655,8 +16655,12 @@ cp_parser_enum_specifier (cp_parser* parser)
else if (nested_name_specifier == error_mark_node)
/* We already issued an error. */;
else
- error_at (type_start_token->location,
- "%qD is not an enumerator-name", identifier);
+ {
+ error_at (type_start_token->location,
+ "%qD does not name an enumeration in %qT",
+ identifier, nested_name_specifier);
+ nested_name_specifier = error_mark_node;
+ }
}
else
{
===================================================================
@@ -0,0 +1,8 @@
+// PR c++/66781
+
+class foo
+{
+public:
+ enum foo::bar{}; // { dg-error "does not name an enumeration" }
+ foo::bar baz;
+};