Commit ea15e254 by Paolo Carlini Committed by Paolo Carlini

re PR c++/58980 (ICE with invalid enum declaration)

/cp
2014-01-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58980
	* parser.c (cp_parser_enum_specifier): Handle TYPENAME_TYPE as
	nested_name_specifier.

/testsuite
2014-01-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58980
	* g++.dg/parse/enum11.C: New.

From-SVN: r206979
parent f9a4c9a6
2014-01-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58980
* parser.c (cp_parser_enum_specifier): Handle TYPENAME_TYPE as
nested_name_specifier.
2014-01-23 Balaji V. Iyer <balaji.v.iyer@intel.com> 2014-01-23 Balaji V. Iyer <balaji.v.iyer@intel.com>
* parser.c (cp_parser_direct_declarator): When Cilk Plus is enabled * parser.c (cp_parser_direct_declarator): When Cilk Plus is enabled
......
...@@ -15474,9 +15474,18 @@ cp_parser_enum_specifier (cp_parser* parser) ...@@ -15474,9 +15474,18 @@ cp_parser_enum_specifier (cp_parser* parser)
error_at (type_start_token->location, "cannot add an enumerator " error_at (type_start_token->location, "cannot add an enumerator "
"list to a template instantiation"); "list to a template instantiation");
if (TREE_CODE (nested_name_specifier) == TYPENAME_TYPE)
{
error_at (type_start_token->location,
"%<%T::%E%> has not been declared",
TYPE_CONTEXT (nested_name_specifier),
nested_name_specifier);
type = error_mark_node;
}
/* If that scope does not contain the scope in which the /* If that scope does not contain the scope in which the
class was originally declared, the program is invalid. */ class was originally declared, the program is invalid. */
if (prev_scope && !is_ancestor (prev_scope, nested_name_specifier)) else if (prev_scope && !is_ancestor (prev_scope,
nested_name_specifier))
{ {
if (at_namespace_scope_p ()) if (at_namespace_scope_p ())
error_at (type_start_token->location, error_at (type_start_token->location,
...@@ -15485,7 +15494,8 @@ cp_parser_enum_specifier (cp_parser* parser) ...@@ -15485,7 +15494,8 @@ cp_parser_enum_specifier (cp_parser* parser)
type, prev_scope, nested_name_specifier); type, prev_scope, nested_name_specifier);
else else
error_at (type_start_token->location, error_at (type_start_token->location,
"declaration of %qD in %qD which does not enclose %qD", "declaration of %qD in %qD which does not "
"enclose %qD",
type, prev_scope, nested_name_specifier); type, prev_scope, nested_name_specifier);
type = error_mark_node; type = error_mark_node;
} }
...@@ -19877,12 +19887,12 @@ cp_parser_class_head (cp_parser* parser, ...@@ -19877,12 +19887,12 @@ cp_parser_class_head (cp_parser* parser,
if (cp_lexer_next_token_is (parser->lexer, CPP_COLON)) if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
{ {
/* PR59482: enter the class scope so that base-specifiers are looked /* PR59482: enter the class scope so that base-specifiers are looked
up correctly */ up correctly. */
if (type) if (type)
pushclass (type); pushclass (type);
bases = cp_parser_base_clause (parser); bases = cp_parser_base_clause (parser);
/* PR59482: get out of the previously pushed class scope so that the /* PR59482: get out of the previously pushed class scope so that the
subsequent pops pop the right thing */ subsequent pops pop the right thing. */
if (type) if (type)
popclass (); popclass ();
} }
......
2014-01-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58980
* g++.dg/parse/enum11.C: New.
2014-01-23 Alex Velenko <Alex.Velenko@arm.com> 2014-01-23 Alex Velenko <Alex.Velenko@arm.com>
* gcc.target/aarch64/sshr64_1.c: New testcase. * gcc.target/aarch64/sshr64_1.c: New testcase.
......
// PR c++/58980
template<typename> struct A
{
enum A::B::C {}; // { dg-error "has not been declared" }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment