Message ID | 5627A31B.90402@oracle.com |
---|---|
State | New |
Headers | show |
On 10/21/2015 04:37 AM, Paolo Carlini wrote: > + "%qD is not an enumerator-name", identifier); This should be enum-name or "does not name an enumeration". We should also print the nested-name-specifier. > + error_at (type_start_token->location, "nested name specifier " > + "for enum declaration cannot depend on a template " > + "parameter, i.e., %qT", nested_name_specifier); It can in, e.g., template <class T> enum A<T>::E { ... }; We could hit this same ICE for anything that is not a class or namespace, i.e. any of WILDCARD_TYPE_P. That's the problem here: the nested-name-specifier on a definition needs to name a class or namespace. Jason
Index: cp/parser.c =================================================================== --- cp/parser.c (revision 229082) +++ cp/parser.c (working copy) @@ -16655,8 +16655,11 @@ 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 is not an enumerator-name", identifier); + nested_name_specifier = error_mark_node; + } } else { Index: testsuite/g++.dg/parse/enum13.C =================================================================== --- testsuite/g++.dg/parse/enum13.C (revision 0) +++ testsuite/g++.dg/parse/enum13.C (working copy) @@ -0,0 +1,8 @@ +// PR c++/66781 + +class foo +{ +public: + enum foo::bar{}; // { dg-error "not an enumerator-name" } + foo::bar baz; +};