Commit c5d3d0ba by Jason Merrill Committed by Jason Merrill

re PR c++/41876 (Parse problems with catch)

	PR c++/41876
	* parser.c (cp_parser_type_specifier_seq): Rename is_condition to
	is_declaration.
	(cp_parser_exception_declaration): Pass true.
	(cp_parser_omp_for_loop): Likewise.

From-SVN: r153864
parent aa9b7569
2009-11-03 Jason Merrill <jason@redhat.com> 2009-11-03 Jason Merrill <jason@redhat.com>
PR c++/41876
* parser.c (cp_parser_type_specifier_seq): Rename is_condition to
is_declaration.
(cp_parser_exception_declaration): Pass true.
(cp_parser_omp_for_loop): Likewise.
PR c++/41927 PR c++/41927
* typeck.c (build_x_binary_op): Don't do warn_parentheses * typeck.c (build_x_binary_op): Don't do warn_parentheses
if we're in a SFINAE context. if we're in a SFINAE context.
......
...@@ -5803,7 +5803,7 @@ cp_parser_new_type_id (cp_parser* parser, tree *nelts) ...@@ -5803,7 +5803,7 @@ cp_parser_new_type_id (cp_parser* parser, tree *nelts)
parser->type_definition_forbidden_message parser->type_definition_forbidden_message
= "types may not be defined in a new-type-id"; = "types may not be defined in a new-type-id";
/* Parse the type-specifier-seq. */ /* Parse the type-specifier-seq. */
cp_parser_type_specifier_seq (parser, /*is_condition=*/false, cp_parser_type_specifier_seq (parser, /*is_declaration=*/false,
/*is_trailing_return=*/false, /*is_trailing_return=*/false,
&type_specifier_seq); &type_specifier_seq);
/* Restore the old message. */ /* Restore the old message. */
...@@ -8049,7 +8049,7 @@ cp_parser_condition (cp_parser* parser) ...@@ -8049,7 +8049,7 @@ cp_parser_condition (cp_parser* parser)
parser->type_definition_forbidden_message parser->type_definition_forbidden_message
= "types may not be defined in conditions"; = "types may not be defined in conditions";
/* Parse the type-specifier-seq. */ /* Parse the type-specifier-seq. */
cp_parser_type_specifier_seq (parser, /*is_condition==*/true, cp_parser_type_specifier_seq (parser, /*is_declaration==*/true,
/*is_trailing_return=*/false, /*is_trailing_return=*/false,
&type_specifiers); &type_specifiers);
/* Restore the saved message. */ /* Restore the saved message. */
...@@ -9691,7 +9691,7 @@ cp_parser_conversion_type_id (cp_parser* parser) ...@@ -9691,7 +9691,7 @@ cp_parser_conversion_type_id (cp_parser* parser)
/* Parse the attributes. */ /* Parse the attributes. */
attributes = cp_parser_attributes_opt (parser); attributes = cp_parser_attributes_opt (parser);
/* Parse the type-specifiers. */ /* Parse the type-specifiers. */
cp_parser_type_specifier_seq (parser, /*is_condition=*/false, cp_parser_type_specifier_seq (parser, /*is_declaration=*/false,
/*is_trailing_return=*/false, /*is_trailing_return=*/false,
&type_specifiers); &type_specifiers);
/* If that didn't work, stop. */ /* If that didn't work, stop. */
...@@ -12561,7 +12561,7 @@ cp_parser_enum_specifier (cp_parser* parser) ...@@ -12561,7 +12561,7 @@ cp_parser_enum_specifier (cp_parser* parser)
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Parse the type-specifier-seq. */ /* Parse the type-specifier-seq. */
cp_parser_type_specifier_seq (parser, /*is_condition=*/false, cp_parser_type_specifier_seq (parser, /*is_declaration=*/false,
/*is_trailing_return=*/false, /*is_trailing_return=*/false,
&type_specifiers); &type_specifiers);
...@@ -14531,7 +14531,7 @@ cp_parser_type_id_1 (cp_parser* parser, bool is_template_arg, ...@@ -14531,7 +14531,7 @@ cp_parser_type_id_1 (cp_parser* parser, bool is_template_arg,
cp_declarator *abstract_declarator; cp_declarator *abstract_declarator;
/* Parse the type-specifier-seq. */ /* Parse the type-specifier-seq. */
cp_parser_type_specifier_seq (parser, /*is_condition=*/false, cp_parser_type_specifier_seq (parser, /*is_declaration=*/false,
is_trailing_return, is_trailing_return,
&type_specifier_seq); &type_specifier_seq);
if (type_specifier_seq.type == error_mark_node) if (type_specifier_seq.type == error_mark_node)
...@@ -14593,8 +14593,8 @@ static tree cp_parser_trailing_type_id (cp_parser *parser) ...@@ -14593,8 +14593,8 @@ static tree cp_parser_trailing_type_id (cp_parser *parser)
type-specifier-seq: type-specifier-seq:
attributes type-specifier-seq [opt] attributes type-specifier-seq [opt]
If IS_CONDITION is true, we are at the start of a "condition", If IS_DECLARATION is true, we are at the start of a "condition" or
e.g., we've just seen "if (". exception-declaration, so we might be followed by a declarator-id.
If IS_TRAILING_RETURN is true, we are in a trailing-return-type, If IS_TRAILING_RETURN is true, we are in a trailing-return-type,
i.e. we've just seen "->". i.e. we've just seen "->".
...@@ -14603,7 +14603,7 @@ static tree cp_parser_trailing_type_id (cp_parser *parser) ...@@ -14603,7 +14603,7 @@ static tree cp_parser_trailing_type_id (cp_parser *parser)
static void static void
cp_parser_type_specifier_seq (cp_parser* parser, cp_parser_type_specifier_seq (cp_parser* parser,
bool is_condition, bool is_declaration,
bool is_trailing_return, bool is_trailing_return,
cp_decl_specifier_seq *type_specifier_seq) cp_decl_specifier_seq *type_specifier_seq)
{ {
...@@ -14679,7 +14679,7 @@ cp_parser_type_specifier_seq (cp_parser* parser, ...@@ -14679,7 +14679,7 @@ cp_parser_type_specifier_seq (cp_parser* parser,
would be clearer just to allow a decl-specifier-seq here, and would be clearer just to allow a decl-specifier-seq here, and
then add a semantic restriction that if any decl-specifiers then add a semantic restriction that if any decl-specifiers
that are not type-specifiers appear, the program is invalid. */ that are not type-specifiers appear, the program is invalid. */
if (is_condition && !is_cv_qualifier) if (is_declaration && !is_cv_qualifier)
flags |= CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES; flags |= CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES;
} }
...@@ -17330,7 +17330,7 @@ cp_parser_exception_declaration (cp_parser* parser) ...@@ -17330,7 +17330,7 @@ cp_parser_exception_declaration (cp_parser* parser)
= "types may not be defined in exception-declarations"; = "types may not be defined in exception-declarations";
/* Parse the type-specifier-seq. */ /* Parse the type-specifier-seq. */
cp_parser_type_specifier_seq (parser, /*is_condition=*/false, cp_parser_type_specifier_seq (parser, /*is_declaration=*/true,
/*is_trailing_return=*/false, /*is_trailing_return=*/false,
&type_specifiers); &type_specifiers);
/* If it's a `)', then there is no declarator. */ /* If it's a `)', then there is no declarator. */
...@@ -22104,7 +22104,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -22104,7 +22104,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
cp_parser_condition, from whence the bulk of this is copied. */ cp_parser_condition, from whence the bulk of this is copied. */
cp_parser_parse_tentatively (parser); cp_parser_parse_tentatively (parser);
cp_parser_type_specifier_seq (parser, /*is_condition=*/false, cp_parser_type_specifier_seq (parser, /*is_declaration=*/true,
/*is_trailing_return=*/false, /*is_trailing_return=*/false,
&type_specifiers); &type_specifiers);
if (cp_parser_parse_definitely (parser)) if (cp_parser_parse_definitely (parser))
......
2009-11-03 Jason Merrill <jason@redhat.com> 2009-11-03 Jason Merrill <jason@redhat.com>
PR c++/41876
* g++.dg/parse/eh-decl.C: New.
PR c++/41927 PR c++/41927
* g++.dg/template/sfinae16.C: New. * g++.dg/template/sfinae16.C: New.
......
// PR c++/41876
struct A;
void foo()
{
try {} catch(int A) {}
}
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