+2012-12-07 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/54401
+ * parser.c (cp_parser_alias_declaration): Commit to tentative
+ parse when see the '=' token. Get out if the type-id is invalid.
+ Update function comment.
+ (cp_parser_member_declaration): Don't try to parse a using
+ declaration if we know that we expected an alias declaration; that
+ is, if we see the '=' token after the identifier.
+
2012-12-06 Jason Merrill <jason@redhat.com>
PR c++/54325
if (cp_parser_error_occurred (parser))
return error_mark_node;
+ cp_parser_commit_to_tentative_parse (parser);
+
/* Now we are going to parse the type-id of the declaration. */
/*
if (parser->num_template_parameter_lists)
parser->type_definition_forbidden_message = saved_message;
+ if (type == error_mark_node)
+ {
+ cp_parser_skip_to_end_of_block_or_statement (parser);
+ return error_mark_node;
+ }
+
cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
if (cp_parser_error_occurred (parser))
- return error_mark_node;
+ {
+ cp_parser_skip_to_end_of_block_or_statement (parser);
+ return error_mark_node;
+ }
/* A typedef-name can also be introduced by an alias-declaration. The
identifier following the using keyword becomes a typedef-name. It has
else
{
tree decl;
+ bool alias_decl_expected;
cp_parser_parse_tentatively (parser);
decl = cp_parser_alias_declaration (parser);
- if (cp_parser_parse_definitely (parser))
+ /* Note that if we actually see the '=' token after the
+ identifier, cp_parser_alias_declaration commits the
+ tentative parse. In that case, we really expects an
+ alias-declaration. Otherwise, we expect a using
+ declaration. */
+ alias_decl_expected =
+ !cp_parser_uncommitted_to_tentative_parse_p (parser);
+ cp_parser_parse_definitely (parser);
+
+ if (alias_decl_expected)
finish_member_declaration (decl);
else
cp_parser_using_declaration (parser,