bool is_unnamed = false;
tree underlying_type = NULL_TREE;
cp_token *type_start_token = NULL;
- bool saved_colon_corrects_to_scope_p = parser->colon_corrects_to_scope_p;
-
- parser->colon_corrects_to_scope_p = false;
+ temp_override<bool> cleanup (parser->colon_corrects_to_scope_p, false);
/* Parse tentatively so that we can back up if we don't find a
enum-specifier. */
push_deferring_access_checks (dk_no_check);
nested_name_specifier
- = cp_parser_nested_name_specifier_opt (parser,
- /*typename_keyword_p=*/true,
- /*check_dependency_p=*/false,
- /*type_p=*/false,
- /*is_declaration=*/false);
+ = cp_parser_nested_name_specifier_opt (parser,
+ /*typename_keyword_p=*/true,
+ /*check_dependency_p=*/false,
+ /*type_p=*/false,
+ /*is_declaration=*/false);
if (nested_name_specifier)
{
tree name;
identifier = cp_parser_identifier (parser);
- name = cp_parser_lookup_name (parser, identifier,
- enum_type,
- /*is_template=*/false,
- /*is_namespace=*/false,
- /*check_dependency=*/true,
- /*ambiguous_decls=*/NULL,
- input_location);
+ name = cp_parser_lookup_name (parser, identifier,
+ enum_type,
+ /*is_template=*/false,
+ /*is_namespace=*/false,
+ /*check_dependency=*/true,
+ /*ambiguous_decls=*/NULL,
+ input_location);
if (name && name != error_mark_node)
{
type = TREE_TYPE (name);
{
if (cxx_dialect < cxx11 || (!scoped_enum_p && !underlying_type))
{
+ if (has_underlying_type)
+ cp_parser_commit_to_tentative_parse (parser);
cp_parser_error (parser, "expected %<{%>");
if (has_underlying_type)
- {
- type = NULL_TREE;
- goto out;
- }
+ return error_mark_node;
}
/* An opaque-enum-specifier must have a ';' here. */
if ((scoped_enum_p || underlying_type)
&& cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
{
+ if (has_underlying_type)
+ cp_parser_commit_to_tentative_parse (parser);
cp_parser_error (parser, "expected %<;%> or %<{%>");
if (has_underlying_type)
- {
- type = NULL_TREE;
- goto out;
- }
+ return error_mark_node;
}
}
push_scope (nested_name_specifier);
}
else if (TREE_CODE (nested_name_specifier) == NAMESPACE_DECL)
- {
- push_nested_namespace (nested_name_specifier);
- }
+ push_nested_namespace (nested_name_specifier);
}
/* Issue an error message if type-definitions are forbidden here. */
pop_scope (nested_name_specifier);
}
else if (TREE_CODE (nested_name_specifier) == NAMESPACE_DECL)
- {
- pop_nested_namespace (nested_name_specifier);
- }
+ pop_nested_namespace (nested_name_specifier);
}
- out:
- parser->colon_corrects_to_scope_p = saved_colon_corrects_to_scope_p;
return type;
}