From 2a931365f7fecec2e69e3ed3f366d2777ed2c9d8 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 3 Oct 2014 08:50:26 +0000 Subject: [PATCH] parser.c (cp_parser_assignment_expression, [...]): Add default arguments. 2014-10-03 Paolo Carlini * parser.c (cp_parser_assignment_expression, cp_parser_constant_expression): Add default arguments. (cp_parser_primary_expression, cp_parser_postfix_open_square_expression, cp_parser_parenthesized_expression_list, cp_parser_question_colon_clause, cp_parser_expression, cp_parser_constant_expression, cp_parser_label_for_labeled_statement, cp_parser_static_assert, cp_parser_template_argument, cp_parser_enumerator_definition, cp_parser_member_declaration, cp_parser_constant_initializer, cp_parser_noexcept_specification_opt, cp_parser_throw_expression, cp_parser_std_attribute_spec, cp_parser_objc_message_args, cp_parser_objc_class_ivars, cp_parser_omp_clause_collapse, cp_parser_omp_clause_aligned, cp_parser_omp_clause_safelen, cp_parser_omp_clause_simdlen, cp_parser_omp_clause_dist_schedule, cp_parser_omp_for_incr, cp_parser_omp_for_loop_init, cp_parser_cilk_simd_vectorlength, cp_parser_cilk_simd_linear): Adjust. From-SVN: r215840 --- gcc/cp/ChangeLog | 20 ++++++++++ gcc/cp/parser.c | 95 ++++++++++++++++++------------------------------ 2 files changed, 56 insertions(+), 59 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b5b3f596bd8..80ed468ab5c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,23 @@ +2014-10-03 Paolo Carlini + + * parser.c (cp_parser_assignment_expression, + cp_parser_constant_expression): Add default arguments. + (cp_parser_primary_expression, + cp_parser_postfix_open_square_expression, + cp_parser_parenthesized_expression_list, + cp_parser_question_colon_clause, + cp_parser_expression, cp_parser_constant_expression, + cp_parser_label_for_labeled_statement, cp_parser_static_assert, + cp_parser_template_argument, cp_parser_enumerator_definition, + cp_parser_member_declaration, cp_parser_constant_initializer, + cp_parser_noexcept_specification_opt, cp_parser_throw_expression, + cp_parser_std_attribute_spec, cp_parser_objc_message_args, + cp_parser_objc_class_ivars, cp_parser_omp_clause_collapse, + cp_parser_omp_clause_aligned, cp_parser_omp_clause_safelen, + cp_parser_omp_clause_simdlen, cp_parser_omp_clause_dist_schedule, + cp_parser_omp_for_incr, cp_parser_omp_for_loop_init, + cp_parser_cilk_simd_vectorlength, cp_parser_cilk_simd_linear): Adjust. + 2014-10-02 Paolo Carlini PR c++/53025 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 63ed1c0dfea..0050b8d21a0 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1961,13 +1961,13 @@ static tree cp_parser_binary_expression static tree cp_parser_question_colon_clause (cp_parser *, tree); static tree cp_parser_assignment_expression - (cp_parser *, bool, cp_id_kind *); + (cp_parser *, cp_id_kind * = NULL, bool = false, bool = false); static enum tree_code cp_parser_assignment_operator_opt (cp_parser *); static tree cp_parser_expression (cp_parser *, cp_id_kind * = NULL, bool = false, bool = false); static tree cp_parser_constant_expression - (cp_parser *, bool, bool *); + (cp_parser *, bool = false, bool * = NULL); static tree cp_parser_builtin_offsetof (cp_parser *); static tree cp_parser_lambda_expression @@ -4451,8 +4451,7 @@ cp_parser_primary_expression (cp_parser *parser, /* Look for the opening `('. */ cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN); /* Now, parse the assignment-expression. */ - expression = cp_parser_assignment_expression (parser, - /*cast_p=*/false, NULL); + expression = cp_parser_assignment_expression (parser); /* Look for the `,'. */ cp_parser_require (parser, CPP_COMMA, RT_COMMA); type_location = cp_lexer_peek_token (parser->lexer)->location; @@ -6424,7 +6423,7 @@ cp_parser_postfix_open_square_expression (cp_parser *parser, Rather than open the barn door too wide right away, allow only integer constant expressions here. */ if (for_offsetof) - index = cp_parser_constant_expression (parser, false, NULL); + index = cp_parser_constant_expression (parser); else { if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) @@ -6807,8 +6806,8 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, break; } if (expr == NULL_TREE) - expr = cp_parser_assignment_expression (parser, cast_p, - NULL); + expr = cp_parser_assignment_expression (parser, /*pidk=*/NULL, + cast_p); } if (fold_expr_p) @@ -8239,7 +8238,7 @@ cp_parser_question_colon_clause (cp_parser* parser, tree logical_or_expr) /* The next token should be a `:'. */ cp_parser_require (parser, CPP_COLON, RT_COLON); /* Parse the assignment-expression. */ - assignment_expr = cp_parser_assignment_expression (parser, /*cast_p=*/false, NULL); + assignment_expr = cp_parser_assignment_expression (parser); c_inhibit_evaluation_warnings -= logical_or_expr == truthvalue_true_node; /* Build the conditional-expression. */ @@ -8262,8 +8261,8 @@ cp_parser_question_colon_clause (cp_parser* parser, tree logical_or_expr) Returns a representation for the expression. */ static tree -cp_parser_assignment_expression (cp_parser* parser, bool cast_p, - bool decltype_p, cp_id_kind * pidk) +cp_parser_assignment_expression (cp_parser* parser, cp_id_kind * pidk, + bool cast_p, bool decltype_p) { tree expr; @@ -8323,14 +8322,6 @@ cp_parser_assignment_expression (cp_parser* parser, bool cast_p, return expr; } -static tree -cp_parser_assignment_expression (cp_parser* parser, bool cast_p, - cp_id_kind * pidk) -{ - return cp_parser_assignment_expression (parser, cast_p, - /*decltype*/false, pidk); -} - /* Parse an (optional) assignment-operator. assignment-operator: one of @@ -8440,7 +8431,7 @@ cp_parser_expression (cp_parser* parser, cp_id_kind * pidk, /* Parse the next assignment-expression. */ assignment_expression - = cp_parser_assignment_expression (parser, cast_p, decltype_p, pidk); + = cp_parser_assignment_expression (parser, pidk, cast_p, decltype_p); /* We don't create a temporary for a call that is the immediate operand of decltype or on the RHS of a comma. But when we see a comma, we @@ -8532,7 +8523,7 @@ cp_parser_constant_expression (cp_parser* parser, For example, cp_parser_initializer_clauses uses this function to determine whether a particular assignment-expression is in fact constant. */ - expression = cp_parser_assignment_expression (parser, /*cast_p=*/false, NULL); + expression = cp_parser_assignment_expression (parser); /* Restore the old settings. */ parser->integral_constant_expression_p = saved_integral_constant_expression_p; @@ -9741,9 +9732,7 @@ cp_parser_label_for_labeled_statement (cp_parser* parser, tree attributes) /* Consume the `case' token. */ cp_lexer_consume_token (parser->lexer); /* Parse the constant-expression. */ - expr = cp_parser_constant_expression (parser, - /*allow_non_constant_p=*/false, - NULL); + expr = cp_parser_constant_expression (parser); ellipsis = cp_lexer_peek_token (parser->lexer); if (ellipsis->type == CPP_ELLIPSIS) @@ -9751,9 +9740,8 @@ cp_parser_label_for_labeled_statement (cp_parser* parser, tree attributes) /* Consume the `...' token. */ cp_lexer_consume_token (parser->lexer); expr_hi = - cp_parser_constant_expression (parser, - /*allow_non_constant_p=*/false, - NULL); + cp_parser_constant_expression (parser); + /* We don't need to emit warnings here, as the common code will do this for us. */ } @@ -14231,9 +14219,8 @@ cp_parser_template_argument (cp_parser* parser) because the argument could really be a type-id. */ if (maybe_type_id) cp_parser_parse_tentatively (parser); - argument = cp_parser_constant_expression (parser, - /*allow_non_constant_p=*/false, - /*non_constant_p=*/NULL); + argument = cp_parser_constant_expression (parser); + if (!maybe_type_id) return argument; if (!cp_parser_next_token_ends_template_argument_p (parser)) @@ -15894,9 +15881,7 @@ cp_parser_enumerator_definition (cp_parser* parser, tree type) /* Consume the `=' token. */ cp_lexer_consume_token (parser->lexer); /* Parse the value. */ - value = cp_parser_constant_expression (parser, - /*allow_non_constant_p=*/false, - NULL); + value = cp_parser_constant_expression (parser); } else value = NULL_TREE; @@ -20721,9 +20706,7 @@ cp_parser_member_declaration (cp_parser* parser) cp_lexer_consume_token (parser->lexer); /* Get the width of the bitfield. */ width - = cp_parser_constant_expression (parser, - /*allow_non_constant=*/false, - NULL); + = cp_parser_constant_expression (parser); /* Look for attributes that apply to the bitfield. */ attributes = cp_parser_attributes_opt (parser); @@ -21048,9 +21031,7 @@ cp_parser_constant_initializer (cp_parser* parser) return error_mark_node; } - return cp_parser_constant_expression (parser, - /*allow_non_constant=*/false, - NULL); + return cp_parser_constant_expression (parser); } /* Derived classes [gram.class.derived] */ @@ -21310,7 +21291,7 @@ cp_parser_noexcept_specification_opt (cp_parser* parser, parser->type_definition_forbidden_message = G_("types may not be defined in an exception-specification"); - expr = cp_parser_constant_expression (parser, false, NULL); + expr = cp_parser_constant_expression (parser); /* Restore the saved message. */ parser->type_definition_forbidden_message = saved_message; @@ -21621,8 +21602,7 @@ cp_parser_throw_expression (cp_parser* parser) || token->type == CPP_COLON) expression = NULL_TREE; else - expression = cp_parser_assignment_expression (parser, - /*cast_p=*/false, NULL); + expression = cp_parser_assignment_expression (parser); return build_throw (expression); } @@ -22346,8 +22326,7 @@ cp_parser_std_attribute_spec (cp_parser *parser) || alignas_expr == NULL_TREE); alignas_expr = - cp_parser_assignment_expression (parser, /*cast_p=*/false, - /**cp_id_kind=*/NULL); + cp_parser_assignment_expression (parser); if (alignas_expr == error_mark_node) cp_parser_skip_to_end_of_statement (parser); if (alignas_expr == NULL_TREE @@ -25540,7 +25519,7 @@ cp_parser_objc_message_args (cp_parser* parser) maybe_unary_selector_p = false; cp_parser_require (parser, CPP_COLON, RT_COLON); - arg = cp_parser_assignment_expression (parser, false, NULL); + arg = cp_parser_assignment_expression (parser); sel_args = chainon (sel_args, @@ -25555,7 +25534,7 @@ cp_parser_objc_message_args (cp_parser* parser) tree arg; cp_lexer_consume_token (parser->lexer); - arg = cp_parser_assignment_expression (parser, false, NULL); + arg = cp_parser_assignment_expression (parser); addl_args = chainon (addl_args, @@ -26419,9 +26398,7 @@ cp_parser_objc_class_ivars (cp_parser* parser) cp_lexer_consume_token (parser->lexer); /* Eat ':'. */ /* Get the width of the bitfield. */ width - = cp_parser_constant_expression (parser, - /*allow_non_constant=*/false, - NULL); + = cp_parser_constant_expression (parser); } else { @@ -27621,7 +27598,7 @@ cp_parser_omp_clause_collapse (cp_parser *parser, tree list, location_t location if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN)) return list; - num = cp_parser_constant_expression (parser, false, NULL); + num = cp_parser_constant_expression (parser); if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, @@ -28011,7 +27988,7 @@ cp_parser_omp_clause_schedule (cp_parser *parser, tree list, location_t location cp_lexer_consume_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer); - t = cp_parser_assignment_expression (parser, false, NULL); + t = cp_parser_assignment_expression (parser); if (t == error_mark_node) goto resync_fail; @@ -28167,7 +28144,7 @@ cp_parser_omp_clause_aligned (cp_parser *parser, tree list) if (colon) { - alignment = cp_parser_constant_expression (parser, false, NULL); + alignment = cp_parser_constant_expression (parser); if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, @@ -28237,7 +28214,7 @@ cp_parser_omp_clause_safelen (cp_parser *parser, tree list, if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN)) return list; - t = cp_parser_constant_expression (parser, false, NULL); + t = cp_parser_constant_expression (parser); if (t == error_mark_node || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) @@ -28266,7 +28243,7 @@ cp_parser_omp_clause_simdlen (cp_parser *parser, tree list, if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN)) return list; - t = cp_parser_constant_expression (parser, false, NULL); + t = cp_parser_constant_expression (parser); if (t == error_mark_node || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) @@ -28440,7 +28417,7 @@ cp_parser_omp_clause_dist_schedule (cp_parser *parser, tree list, { cp_lexer_consume_token (parser->lexer); - t = cp_parser_assignment_expression (parser, false, NULL); + t = cp_parser_assignment_expression (parser); if (t == error_mark_node) goto resync_fail; @@ -29390,7 +29367,7 @@ cp_parser_omp_for_incr (cp_parser *parser, tree decl) if (op != NOP_EXPR) { - rhs = cp_parser_assignment_expression (parser, false, NULL); + rhs = cp_parser_assignment_expression (parser); rhs = build2 (op, TREE_TYPE (decl), decl, rhs); return build2 (MODIFY_EXPR, TREE_TYPE (decl), decl, rhs); } @@ -29563,7 +29540,7 @@ cp_parser_omp_for_loop_init (cp_parser *parser, { /* Consume '='. */ cp_lexer_consume_token (parser->lexer); - init = cp_parser_assignment_expression (parser, false, NULL); + init = cp_parser_assignment_expression (parser); non_class: if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE) @@ -29599,7 +29576,7 @@ cp_parser_omp_for_loop_init (cp_parser *parser, cp_parser_parse_definitely (parser); cp_parser_require (parser, CPP_EQ, RT_EQ); - rhs = cp_parser_assignment_expression (parser, false, NULL); + rhs = cp_parser_assignment_expression (parser); finish_expr_stmt (build_x_modify_expr (EXPR_LOCATION (rhs), decl, NOP_EXPR, rhs, @@ -32125,7 +32102,7 @@ cp_parser_cilk_simd_vectorlength (cp_parser *parser, tree clauses, if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN)) return error_mark_node; - expr = cp_parser_constant_expression (parser, false, NULL); + expr = cp_parser_constant_expression (parser); expr = maybe_constant_value (expr); /* If expr == error_mark_node, then don't emit any errors nor @@ -32226,7 +32203,7 @@ cp_parser_cilk_simd_linear (cp_parser *parser, tree clauses) { cp_lexer_consume_token (parser->lexer); - e = cp_parser_assignment_expression (parser, false, NULL); + e = cp_parser_assignment_expression (parser); e = maybe_constant_value (e); if (e == error_mark_node) -- 2.30.2