Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
-- >8 --
Now that cp_parser_constant_expression accepts a null non_constant_p,
we can transitively remove dummy arguments in the call chain.
Running dg.exp and counting the # of is_rvalue_constant_expression calls
from cp_parser_constant_expression:
pre-r14-2800: 2,459,145
this patch : 1,719,454
gcc/cp/ChangeLog:
* parser.cc (cp_parser_postfix_expression): Adjust the call to
cp_parser_braced_list.
(cp_parser_postfix_open_square_expression): Likewise.
(cp_parser_new_initializer): Likewise.
(cp_parser_assignment_expression): Adjust the call to
cp_parser_initializer_clause.
(cp_parser_lambda_introducer): Adjust the call to cp_parser_initializer.
(cp_parser_range_for): Adjust the call to cp_parser_braced_list.
(cp_parser_jump_statement): Likewise.
(cp_parser_mem_initializer): Likewise.
(cp_parser_template_argument): Likewise.
(cp_parser_default_argument): Adjust the call to cp_parser_initializer.
(cp_parser_initializer): Handle null is_direct_init and non_constant_p
arguments.
(cp_parser_initializer_clause): Handle null non_constant_p argument.
(cp_parser_braced_list): Likewise.
(cp_parser_initializer_list): Likewise.
(cp_parser_member_declaration): Adjust the call to
cp_parser_initializer_clause and cp_parser_initializer.
(cp_parser_yield_expression): Adjust the call to cp_parser_braced_list.
(cp_parser_functional_cast): Likewise.
(cp_parser_late_parse_one_default_arg): Adjust the call to
cp_parser_initializer.
(cp_parser_omp_for_loop_init): Likewise.
(cp_parser_omp_declare_reduction_exprs): Likewise.
---
gcc/cp/parser.cc | 102 +++
1 file changed, 41 insertions(+), 61 deletions(-)
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index b1d2e141e35..957eb705b2a 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -2483,11 +2483,11 @@ static tree cp_parser_default_argument
static void cp_parser_function_body
(cp_parser *, bool);
static tree cp_parser_initializer
- (cp_parser *, bool *, bool *, bool = false);
+ (cp_parser *, bool * = nullptr, bool * = nullptr, bool = false);
static cp_expr cp_parser_initializer_clause
- (cp_parser *, bool *);
+ (cp_parser *, bool * = nullptr);
static cp_expr cp_parser_braced_list
- (cp_parser*, bool*);
+ (cp_parser*, bool * = nullptr);
static vec *cp_parser_initializer_list
(cp_parser *, bool *, bool *);
@@ -7734,12 +7734,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool
address_p, bool cast_p,
/* If things aren't going well, there's no need to
keep going. */
if (!cp_parser_error_occurred (parser))
- {
- bool non_constant_p;
- /* Parse the brace-enclosed initializer list. */
- initializer = cp_parser_braced_list (parser,
-_constant_p);
- }
+ /* Parse the brace-enclosed initializer list. */
+ initializer = cp_parser_braced_list (parser);
/* If that worked, we're definitely looking at a
compound-literal expression. */
if (cp_parser_parse_definitely (parser))
@@ -8203,10 +8199,9 @@ cp_parser_postfix_open_square_expression (cp_parser
*parser,
}
else if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{
- bool expr_nonconst_p;
cp_lexer_set_source_position (parser->lexer);
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
- index = cp_parser_braced_list (parser, _nonconst_p);
+ index = cp_parser_braced_list (parser);
}
else
index = cp_parser_expression (parser, NULL, /*cast_p=*/false,
@@ -9640,12 +9635,10 @@ cp_parser_new_initializer (cp_parser* parser)
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{
- tree t;
- bool expr_non_constant_p;
cp_lexer_set_source_position (parser->lexer);
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
- t = cp_parser_braced_list (parser, _non_constant_p);
- CONSTRUCTOR_IS_DIRECT_INIT (t) = 1;
+ tree t = cp_parser_braced_list (parser);
+ CONSTRUCTOR_IS_DIRECT_INIT (t) = true;
expression_list = make_tree_vector_single (t);
}
else
@@ -10505,11 +10498,8 @@ cp_parser_assignment_expression (cp_parser* parser,
cp_id_kind * pidk,
= cp_parser_assignment_operator_opt (parser);
if (assignment_operator != ERROR_MARK)
{
- bool non_constant_p;
-
/* Parse the right-hand side of the assignment. */
- cp_expr rhs = cp_parser_initializer_clause (parser,
- _constant_p);
+ cp_expr rhs =