On Fri, 12 Feb 2021, Patrick Palka wrote: > Here, the problem ultimately seems to be that tsubst_copy_and_build, > when called with empty args as we do during non-dependent expression > folding, doesn't touch BASELINKs at all: it delegates to tsubst_copy > which then immediately exits early due to the empty args. This means > that the CAST_EXPR int(1) in the BASELINK A::condition<int(1)> never > gets folded (as part of folding of the overall CALL_EXPR), which later > causes us to crash when performing overload resolution of the rebuilt > CALL_EXPR (which is in terms of this still-templated BASELINK). > > This doesn't happen when condition() is a namespace-scope function > because then condition<int(1)> is represented as a TEMPLATE_ID_EXPR > rather than a BASELINK, which does get handled directly from > tsubst_copy_and_build. > > This patch fixes this issue by having tsubst_copy_and_build handle > BASELINK directly rather than delegating to tsubst_copy, so that it > processes BASELINKS even when args is empty. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? > > gcc/cp/ChangeLog: > > PR c++/95468 > * pt.c (tsubst_copy_and_build) <case BASELINK>: New case, copied > over from tsubst_copy. > > gcc/testsuite/ChangeLog: > > PR c++/95468 > * g++.dg/template/non-dependent15.C: New test. > --- > gcc/cp/pt.c | 5 +++++ > gcc/testsuite/g++.dg/template/non-dependent15.C | 12 ++++++++++++ > 2 files changed, 17 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/template/non-dependent15.C > > diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c > index 5102bf02d0f..5b2f43dc5c1 100644 > --- a/gcc/cp/pt.c > +++ b/gcc/cp/pt.c > @@ -19856,6 +19856,11 @@ tsubst_copy_and_build (tree t, > case SCOPE_REF: > RETURN (tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true, > /*address_p=*/false)); > + > + case BASELINK: > + return tsubst_baselink (t, current_nonlambda_class_type (), > + args, complain, in_decl);
Oops, this should use the RETURN macro instead of a bare 'return' so that input_location gets properly restored on function exit. And it looks like there's an existing instance of this bug in the LAMBDA_EXPR case of tsubst_copy_and_build. Perhaps it's a good time to replace these RETURN macros with the equivalent use of iloc_sentinel, like so? Bootstrapped and tested on x86_64-pc-linux-gnu. -- >8 -- Subject: [PATCH] c++: Replace RETURN macros with iloc_sentinel This replaces the C-era RETURN macro idiom used by some of the tsubsting functions with an iloc_sentinel declared at the start of each function. gcc/cp/ChangeLog: * pt.c (tsubst_decl): Delete the RETURN macro, and replace its uses with a plain 'return'. Set up an iloc_sentinel at the start of the function to set and restore input_location. (tsubst_expr): Likewise. Remove redundant break statements that immediately follow a return. (tsubst_copy_and_build): Likewise. Remove 'retval' local variable. Add gcc_unreachable to the end of the function. --- gcc/cp/pt.c | 316 ++++++++++++++++++++++++---------------------------- 1 file changed, 145 insertions(+), 171 deletions(-) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5b2f43dc5c1..32d1759258c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14414,15 +14414,12 @@ enclosing_instantiation_of (tree otctx) static tree tsubst_decl (tree t, tree args, tsubst_flags_t complain) { -#define RETURN(EXP) do { r = (EXP); goto out; } while(0) - location_t saved_loc; tree r = NULL_TREE; tree in_decl = t; hashval_t hash = 0; - /* Set the filename and linenumber to improve error-reporting. */ - saved_loc = input_location; - input_location = DECL_SOURCE_LOCATION (t); + /* Set the source position to improve error-reporting. */ + iloc_sentinel ils (DECL_SOURCE_LOCATION (t)); switch (TREE_CODE (t)) { @@ -14453,7 +14450,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) if (spec && TREE_CODE (spec) == PARM_DECL && TREE_CODE (TREE_TYPE (spec)) != TYPE_PACK_EXPANSION) - RETURN (spec); + return spec; /* Expand the TYPE_PACK_EXPANSION that provides the types for the parameters in this function parameter pack. */ @@ -14466,8 +14463,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) /* Zero-length parameter packs are boring. Just substitute into the chain. */ if (len == 0 && !cp_unevaluated_operand) - RETURN (tsubst (TREE_CHAIN (t), args, complain, - TREE_CHAIN (t))); + return tsubst (TREE_CHAIN (t), args, complain, + TREE_CHAIN (t)); } else { @@ -14587,7 +14584,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) type = tsubst (TREE_TYPE (t), args, complain, in_decl); if (type == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; TREE_TYPE (r) = type; cp_apply_type_quals_to_decl (cp_type_quals (type), r); @@ -14687,7 +14684,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) tree type = NULL_TREE; if (TREE_TYPE (t) == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; if (TREE_CODE (t) == TYPE_DECL && t == TYPE_MAIN_DECL (TREE_TYPE (t))) @@ -14699,7 +14696,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) we've copied the type for a typedef. */ type = tsubst (TREE_TYPE (t), args, complain, in_decl); if (type == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; r = TYPE_NAME (type); break; } @@ -14745,7 +14742,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) argvec, t, complain, /*all*/true, /*defarg*/true)); if (argvec == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; hash = hash_tmpl_and_args (gen_tmpl, argvec); spec = retrieve_specialization (gen_tmpl, argvec, hash); } @@ -14815,7 +14812,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) DECL_INITIALIZED_P (r) = 0; DECL_TEMPLATE_INSTANTIATED (r) = 0; if (type == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; if (TREE_CODE (type) == FUNCTION_TYPE) { /* It may seem that this case cannot occur, since: @@ -14835,7 +14832,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) /* R is not yet sufficiently initialized, so we just use its name. */ DECL_NAME (r)); - RETURN (error_mark_node); + return error_mark_node; } type = complete_type (type); /* Wait until cp_finish_decl to set this again, to handle @@ -14952,11 +14949,6 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) default: gcc_unreachable (); } -#undef RETURN - - out: - /* Restore the file and line information. */ - input_location = saved_loc; return r; } @@ -18120,21 +18112,17 @@ tree tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, bool integral_constant_expression_p) { -#define RETURN(EXP) do { r = (EXP); goto out; } while(0) #define RECUR(NODE) \ tsubst_expr ((NODE), args, complain, in_decl, \ integral_constant_expression_p) tree stmt, tmp; tree r; - location_t loc; if (t == NULL_TREE || t == error_mark_node) return t; - loc = input_location; - if (location_t eloc = cp_expr_location (t)) - input_location = eloc; + iloc_sentinel ils (cp_expr_location (t)); if (STATEMENT_CODE_P (TREE_CODE (t))) current_stmt_tree ()->stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t); @@ -18164,14 +18152,12 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, case CO_YIELD_EXPR: stmt = finish_co_yield_expr (input_location, RECUR (TREE_OPERAND (t, 0))); - RETURN (stmt); - break; + return stmt; case CO_AWAIT_EXPR: stmt = finish_co_await_expr (input_location, RECUR (TREE_OPERAND (t, 0))); - RETURN (stmt); - break; + return stmt; case EXPR_STMT: tmp = RECUR (EXPR_STMT_EXPR (t)); @@ -18836,7 +18822,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, error_at (OMP_CLAUSE_LOCATION (tmp), "%<#pragma omp critical%> with %<hint%> clause requires " "a name, except when %<omp_sync_hint_none%> is used"); - RETURN (error_mark_node); + return error_mark_node; } t = copy_node (t); OMP_BODY (t) = stmt; @@ -19062,7 +19048,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, stmt = build_transaction_expr (EXPR_LOCATION (t), RECUR (TRANSACTION_EXPR_BODY (t)), flags, NULL_TREE); - RETURN (stmt); + return stmt; } } break; @@ -19071,50 +19057,46 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, { tree op0 = RECUR (TREE_OPERAND (t, 0)); tree cond = RECUR (MUST_NOT_THROW_COND (t)); - RETURN (build_must_not_throw_expr (op0, cond)); + return build_must_not_throw_expr (op0, cond); } case EXPR_PACK_EXPANSION: error ("invalid use of pack expansion expression"); - RETURN (error_mark_node); + return error_mark_node; case NONTYPE_ARGUMENT_PACK: error ("use %<...%> to expand argument pack"); - RETURN (error_mark_node); + return error_mark_node; case COMPOUND_EXPR: tmp = RECUR (TREE_OPERAND (t, 0)); if (tmp == NULL_TREE) /* If the first operand was a statement, we're done with it. */ - RETURN (RECUR (TREE_OPERAND (t, 1))); - RETURN (build_x_compound_expr (EXPR_LOCATION (t), tmp, + return RECUR (TREE_OPERAND (t, 1)); + return build_x_compound_expr (EXPR_LOCATION (t), tmp, RECUR (TREE_OPERAND (t, 1)), - complain)); + complain); case ANNOTATE_EXPR: tmp = RECUR (TREE_OPERAND (t, 0)); - RETURN (build3_loc (EXPR_LOCATION (t), ANNOTATE_EXPR, - TREE_TYPE (tmp), tmp, - RECUR (TREE_OPERAND (t, 1)), - RECUR (TREE_OPERAND (t, 2)))); + return build3_loc (EXPR_LOCATION (t), ANNOTATE_EXPR, + TREE_TYPE (tmp), tmp, + RECUR (TREE_OPERAND (t, 1)), + RECUR (TREE_OPERAND (t, 2))); case PREDICT_EXPR: - RETURN (add_stmt (copy_node (t))); + return add_stmt (copy_node (t)); default: gcc_assert (!STATEMENT_CODE_P (TREE_CODE (t))); - RETURN (tsubst_copy_and_build (t, args, complain, in_decl, + return tsubst_copy_and_build (t, args, complain, in_decl, /*function_p=*/false, - integral_constant_expression_p)); + integral_constant_expression_p); } - RETURN (NULL_TREE); - out: - input_location = loc; - return r; + return NULL_TREE; #undef RECUR -#undef RETURN } /* Instantiate the special body of the artificial DECL_OMP_DECLARE_REDUCTION @@ -19485,21 +19467,17 @@ tsubst_copy_and_build (tree t, bool function_p, bool integral_constant_expression_p) { -#define RETURN(EXP) do { retval = (EXP); goto out; } while(0) #define RECUR(NODE) \ tsubst_copy_and_build (NODE, args, complain, in_decl, \ /*function_p=*/false, \ integral_constant_expression_p) - tree retval, op1; - location_t save_loc; + tree op1; if (t == NULL_TREE || t == error_mark_node) return t; - save_loc = input_location; - if (location_t eloc = cp_expr_location (t)) - input_location = eloc; + iloc_sentinel ils (cp_expr_location (t)); /* N3276 decltype magic only applies to calls at the top level or on the right side of a comma. */ @@ -19551,7 +19529,7 @@ tsubst_copy_and_build (tree t, unqualified_name_lookup_error (decl); decl = error_mark_node; } - RETURN (decl); + return decl; } case TEMPLATE_ID_EXPR: @@ -19566,30 +19544,30 @@ tsubst_copy_and_build (tree t, if (targs) targs = tsubst_template_args (targs, args, complain, in_decl); if (targs == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; if (TREE_CODE (templ) == SCOPE_REF) { tree name = TREE_OPERAND (templ, 1); tree tid = lookup_template_function (name, targs); TREE_OPERAND (templ, 1) = tid; - RETURN (templ); + return templ; } if (concept_definition_p (templ)) { tree check = build_concept_check (templ, targs, complain); if (check == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; tree id = unpack_concept_check (check); /* If we built a function concept check, return the underlying template-id. So we can evaluate it as a function call. */ if (function_concept_p (TREE_OPERAND (id, 0))) - RETURN (id); + return id; - RETURN (check); + return check; } if (variable_template_p (templ)) @@ -19597,7 +19575,7 @@ tsubst_copy_and_build (tree t, tree r = lookup_and_finish_template_variable (templ, targs, complain); r = maybe_wrap_with_location (r, EXPR_LOCATION (t)); - RETURN (r); + return r; } if (TREE_CODE (templ) == COMPONENT_REF) @@ -19611,17 +19589,17 @@ tsubst_copy_and_build (tree t, tree tid = lookup_template_function (templ, targs); if (object) - RETURN (build3 (COMPONENT_REF, TREE_TYPE (tid), - object, tid, NULL_TREE)); + return build3 (COMPONENT_REF, TREE_TYPE (tid), + object, tid, NULL_TREE); else if (identifier_p (templ)) { /* C++20 P0846: we can encounter an IDENTIFIER_NODE here when name lookup found nothing when parsing the template name. */ gcc_assert (cxx_dialect >= cxx20 || seen_error ()); - RETURN (tid); + return tid; } else - RETURN (baselink_for_fns (tid)); + return baselink_for_fns (tid); } case INDIRECT_REF: @@ -19642,14 +19620,14 @@ tsubst_copy_and_build (tree t, if (REF_PARENTHESIZED_P (t)) r = force_paren_expr (r); - RETURN (r); + return r; } case NOP_EXPR: { tree type = tsubst (TREE_TYPE (t), args, complain, in_decl); tree op0 = RECUR (TREE_OPERAND (t, 0)); - RETURN (build_nop (type, op0)); + return build_nop (type, op0); } case IMPLICIT_CONV_EXPR: @@ -19658,22 +19636,22 @@ tsubst_copy_and_build (tree t, tree expr = RECUR (TREE_OPERAND (t, 0)); if (dependent_type_p (type) || type_dependent_expression_p (expr)) { - retval = copy_node (t); - TREE_TYPE (retval) = type; - TREE_OPERAND (retval, 0) = expr; - RETURN (retval); + tree r = copy_node (t); + TREE_TYPE (r) = type; + TREE_OPERAND (r, 0) = expr; + return r; } if (IMPLICIT_CONV_EXPR_NONTYPE_ARG (t)) /* We'll pass this to convert_nontype_argument again, we don't need to actually perform any conversion here. */ - RETURN (expr); + return expr; int flags = LOOKUP_IMPLICIT; if (IMPLICIT_CONV_EXPR_DIRECT_INIT (t)) flags = LOOKUP_NORMAL; if (IMPLICIT_CONV_EXPR_BRACED_INIT (t)) flags |= LOOKUP_NO_NARROWING; - RETURN (perform_implicit_conversion_flags (type, expr, complain, - flags)); + return perform_implicit_conversion_flags (type, expr, complain, + flags); } case CONVERT_EXPR: @@ -19681,8 +19659,8 @@ tsubst_copy_and_build (tree t, tree type = tsubst (TREE_TYPE (t), args, complain, in_decl); tree op0 = RECUR (TREE_OPERAND (t, 0)); if (op0 == error_mark_node) - RETURN (error_mark_node); - RETURN (build1 (CONVERT_EXPR, type, op0)); + return error_mark_node; + return build1 (CONVERT_EXPR, type, op0); } case CAST_EXPR: @@ -19701,7 +19679,7 @@ tsubst_copy_and_build (tree t, if (complain & tf_error) error ("a cast to a type other than an integral or " "enumeration type cannot appear in a constant-expression"); - RETURN (error_mark_node); + return error_mark_node; } op = RECUR (TREE_OPERAND (t, 0)); @@ -19731,22 +19709,22 @@ tsubst_copy_and_build (tree t, gcc_unreachable (); } - RETURN (r); + return r; } case BIT_CAST_EXPR: { tree type = tsubst (TREE_TYPE (t), args, complain, in_decl); tree op0 = RECUR (TREE_OPERAND (t, 0)); - RETURN (cp_build_bit_cast (EXPR_LOCATION (t), type, op0, complain)); + return cp_build_bit_cast (EXPR_LOCATION (t), type, op0, complain); } case POSTDECREMENT_EXPR: case POSTINCREMENT_EXPR: op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0), args, complain, in_decl); - RETURN (build_x_unary_op (input_location, TREE_CODE (t), op1, - complain|decltype_flag)); + return build_x_unary_op (input_location, TREE_CODE (t), op1, + complain|decltype_flag); case PREDECREMENT_EXPR: case PREINCREMENT_EXPR: @@ -19757,9 +19735,9 @@ tsubst_copy_and_build (tree t, case UNARY_PLUS_EXPR: /* Unary + */ case REALPART_EXPR: case IMAGPART_EXPR: - RETURN (build_x_unary_op (input_location, TREE_CODE (t), - RECUR (TREE_OPERAND (t, 0)), - complain|decltype_flag)); + return build_x_unary_op (input_location, TREE_CODE (t), + RECUR (TREE_OPERAND (t, 0)), + complain|decltype_flag); case FIX_TRUNC_EXPR: gcc_unreachable (); @@ -19767,16 +19745,16 @@ tsubst_copy_and_build (tree t, case ADDR_EXPR: op1 = TREE_OPERAND (t, 0); if (TREE_CODE (op1) == LABEL_DECL) - RETURN (finish_label_address_expr (DECL_NAME (op1), - EXPR_LOCATION (op1))); + return finish_label_address_expr (DECL_NAME (op1), + EXPR_LOCATION (op1)); if (TREE_CODE (op1) == SCOPE_REF) op1 = tsubst_qualified_id (op1, args, complain, in_decl, /*done=*/true, /*address_p=*/true); else op1 = tsubst_non_call_postfix_expression (op1, args, complain, in_decl); - RETURN (build_x_unary_op (input_location, ADDR_EXPR, op1, - complain|decltype_flag)); + return build_x_unary_op (input_location, ADDR_EXPR, op1, + complain|decltype_flag); case PLUS_EXPR: case MINUS_EXPR: @@ -19839,23 +19817,23 @@ tsubst_copy_and_build (tree t, if (EXPR_P (r) && TREE_NO_WARNING (t)) TREE_NO_WARNING (r) = TREE_NO_WARNING (t); - RETURN (r); + return r; } case POINTER_PLUS_EXPR: { tree op0 = RECUR (TREE_OPERAND (t, 0)); if (op0 == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; tree op1 = RECUR (TREE_OPERAND (t, 1)); if (op1 == error_mark_node) - RETURN (error_mark_node); - RETURN (fold_build_pointer_plus (op0, op1)); + return error_mark_node; + return fold_build_pointer_plus (op0, op1); } case SCOPE_REF: - RETURN (tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true, - /*address_p=*/false)); + return tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true, + /*address_p=*/false); case BASELINK: return tsubst_baselink (t, current_nonlambda_class_type (), @@ -19864,14 +19842,14 @@ tsubst_copy_and_build (tree t, case ARRAY_REF: op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0), args, complain, in_decl); - RETURN (build_x_array_ref (EXPR_LOCATION (t), op1, - RECUR (TREE_OPERAND (t, 1)), - complain|decltype_flag)); + return build_x_array_ref (EXPR_LOCATION (t), op1, + RECUR (TREE_OPERAND (t, 1)), + complain|decltype_flag); case SIZEOF_EXPR: if (PACK_EXPANSION_P (TREE_OPERAND (t, 0)) || ARGUMENT_PACK_P (TREE_OPERAND (t, 0))) - RETURN (tsubst_copy (t, args, complain, in_decl)); + return tsubst_copy (t, args, complain, in_decl); /* Fall through */ case ALIGNOF_EXPR: @@ -19930,7 +19908,7 @@ tsubst_copy_and_build (tree t, } SET_EXPR_LOCATION (r, EXPR_LOCATION (t)); } - RETURN (r); + return r; } case AT_ENCODE_EXPR: @@ -19943,7 +19921,7 @@ tsubst_copy_and_build (tree t, /*integral_constant_expression_p=*/false); --cp_unevaluated_operand; --c_inhibit_evaluation_warnings; - RETURN (objc_build_encode_expr (op1)); + return objc_build_encode_expr (op1); } case NOEXCEPT_EXPR: @@ -19957,7 +19935,7 @@ tsubst_copy_and_build (tree t, --cp_unevaluated_operand; --c_inhibit_evaluation_warnings; --cp_noexcept_operand; - RETURN (finish_noexcept_expr (op1, complain)); + return finish_noexcept_expr (op1, complain); case MODOP_EXPR: { @@ -19976,7 +19954,7 @@ tsubst_copy_and_build (tree t, if (TREE_NO_WARNING (t)) TREE_NO_WARNING (r) = TREE_NO_WARNING (t); - RETURN (r); + return r; } case ARROW_EXPR: @@ -19985,8 +19963,8 @@ tsubst_copy_and_build (tree t, /* Remember that there was a reference to this entity. */ if (DECL_P (op1) && !mark_used (op1, complain) && !(complain & tf_error)) - RETURN (error_mark_node); - RETURN (build_x_arrow (input_location, op1, complain)); + return error_mark_node; + return build_x_arrow (input_location, op1, complain); case NEW_EXPR: { @@ -20000,7 +19978,7 @@ tsubst_copy_and_build (tree t, if (placement == NULL_TREE) placement_vec = NULL; else if (placement == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; else { placement_vec = make_tree_vector (); @@ -20017,7 +19995,7 @@ tsubst_copy_and_build (tree t, if (init == NULL_TREE && TREE_OPERAND (t, 3) == NULL_TREE) init_vec = NULL; else if (init == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; else { init_vec = make_tree_vector (); @@ -20044,17 +20022,17 @@ tsubst_copy_and_build (tree t, if (init_vec != NULL) release_tree_vector (init_vec); - RETURN (ret); + return ret; } case DELETE_EXPR: { tree op0 = RECUR (TREE_OPERAND (t, 0)); tree op1 = RECUR (TREE_OPERAND (t, 1)); - RETURN (delete_sanity (input_location, op0, op1, - DELETE_EXPR_USE_VEC (t), - DELETE_EXPR_USE_GLOBAL (t), - complain)); + return delete_sanity (input_location, op0, op1, + DELETE_EXPR_USE_VEC (t), + DELETE_EXPR_USE_GLOBAL (t), + complain); } case COMPOUND_EXPR: @@ -20063,10 +20041,10 @@ tsubst_copy_and_build (tree t, complain & ~tf_decltype, in_decl, /*function_p=*/false, integral_constant_expression_p); - RETURN (build_x_compound_expr (EXPR_LOCATION (t), - op0, - RECUR (TREE_OPERAND (t, 1)), - complain|decltype_flag)); + return build_x_compound_expr (EXPR_LOCATION (t), + op0, + RECUR (TREE_OPERAND (t, 1)), + complain|decltype_flag); } case CALL_EXPR: @@ -20080,7 +20058,7 @@ tsubst_copy_and_build (tree t, function = CALL_EXPR_FN (t); /* Internal function with no arguments. */ if (function == NULL_TREE && call_expr_nargs (t) == 0) - RETURN (t); + return t; /* When we parsed the expression, we determined whether or not Koenig lookup should be performed. */ @@ -20224,7 +20202,7 @@ tsubst_copy_and_build (tree t, if (CLASS_TYPE_P (TREE_TYPE (ret))) CALL_EXPR_RETURN_SLOT_OPT (ret) = true; - RETURN (ret); + return ret; } /* We do not perform argument-dependent lookup if normal @@ -20263,7 +20241,7 @@ tsubst_copy_and_build (tree t, (function, args, complain, in_decl, true, integral_constant_expression_p)); if (unq == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; if (unq != function) { @@ -20317,7 +20295,7 @@ tsubst_copy_and_build (tree t, "%qD declared here, later in the " "translation unit", fn); if (in_lambda) - RETURN (error_mark_node); + return error_mark_node; } function = unq; @@ -20327,7 +20305,7 @@ tsubst_copy_and_build (tree t, { if (complain & tf_error) unqualified_name_lookup_error (function); - RETURN (error_mark_node); + return error_mark_node; } } @@ -20335,7 +20313,7 @@ tsubst_copy_and_build (tree t, if (function != NULL_TREE && DECL_P (function) && !mark_used (function, complain) && !(complain & tf_error)) - RETURN (error_mark_node); + return error_mark_node; /* Put back tf_decltype for the actual call. */ complain |= decltype_flag; @@ -20372,7 +20350,7 @@ tsubst_copy_and_build (tree t, complain, in_decl), complain); if (TREE_CODE (ret) == VIEW_CONVERT_EXPR) - RETURN (ret); + return ret; break; default: @@ -20443,7 +20421,7 @@ tsubst_copy_and_build (tree t, } } - RETURN (ret); + return ret; } case COND_EXPR: @@ -20478,8 +20456,8 @@ tsubst_copy_and_build (tree t, } warning_sentinel s(warn_duplicated_branches); - RETURN (build_x_conditional_expr (EXPR_LOCATION (t), - cond, exp1, exp2, complain)); + return build_x_conditional_expr (EXPR_LOCATION (t), + cond, exp1, exp2, complain); } case PSEUDO_DTOR_EXPR: @@ -20487,12 +20465,12 @@ tsubst_copy_and_build (tree t, tree op0 = RECUR (TREE_OPERAND (t, 0)); tree op1 = RECUR (TREE_OPERAND (t, 1)); tree op2 = tsubst (TREE_OPERAND (t, 2), args, complain, in_decl); - RETURN (finish_pseudo_destructor_expr (op0, op1, op2, - input_location)); + return finish_pseudo_destructor_expr (op0, op1, op2, + input_location); } case TREE_LIST: - RETURN (tsubst_tree_list (t, args, complain, in_decl)); + return tsubst_tree_list (t, args, complain, in_decl); case COMPONENT_REF: { @@ -20506,7 +20484,7 @@ tsubst_copy_and_build (tree t, /* Remember that there was a reference to this entity. */ if (DECL_P (object) && !mark_used (object, complain) && !(complain & tf_error)) - RETURN (error_mark_node); + return error_mark_node; object_type = TREE_TYPE (object); member = TREE_OPERAND (t, 1); @@ -20517,14 +20495,14 @@ tsubst_copy_and_build (tree t, else member = tsubst_copy (member, args, complain, in_decl); if (member == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; if (TREE_CODE (member) == FIELD_DECL) { r = finish_non_static_data_member (member, object, NULL_TREE); if (TREE_CODE (r) == COMPONENT_REF) REF_PARENTHESIZED_P (r) = REF_PARENTHESIZED_P (t); - RETURN (r); + return r; } else if (type_dependent_expression_p (object)) /* We can't do much here. */; @@ -20544,7 +20522,7 @@ tsubst_copy_and_build (tree t, { dtor = TREE_OPERAND (dtor, 0); if (TYPE_P (dtor)) - RETURN (finish_pseudo_destructor_expr + return (finish_pseudo_destructor_expr (object, s, dtor, input_location)); } } @@ -20572,7 +20550,7 @@ tsubst_copy_and_build (tree t, { qualified_name_lookup_error (scope, tmpl, member, input_location); - RETURN (error_mark_node); + return error_mark_node; } } else if (TREE_CODE (member) == SCOPE_REF @@ -20588,7 +20566,7 @@ tsubst_copy_and_build (tree t, error ("%qD is not a class or namespace", TREE_OPERAND (member, 0)); } - RETURN (error_mark_node); + return error_mark_node; } r = finish_class_member_access_expr (object, member, @@ -20596,12 +20574,11 @@ tsubst_copy_and_build (tree t, complain); if (TREE_CODE (r) == COMPONENT_REF) REF_PARENTHESIZED_P (r) = REF_PARENTHESIZED_P (t); - RETURN (r); + return r; } case THROW_EXPR: - RETURN (build_throw - (input_location, RECUR (TREE_OPERAND (t, 0)))); + return build_throw (input_location, RECUR (TREE_OPERAND (t, 0))); case CONSTRUCTOR: { @@ -20615,7 +20592,7 @@ tsubst_copy_and_build (tree t, tree r; if (type == error_mark_node) - RETURN (error_mark_node); + return error_mark_node; /* We do not want to process the index of aggregate initializers as they are identifier nodes which will be @@ -20625,7 +20602,7 @@ tsubst_copy_and_build (tree t, if (null_member_pointer_value_p (t)) { gcc_assert (same_type_p (type, TREE_TYPE (t))); - RETURN (t); + return t; } n = vec_safe_copy (CONSTRUCTOR_ELTS (t)); @@ -20692,11 +20669,11 @@ tsubst_copy_and_build (tree t, fcl_t cl = fcl_functional; if (CONSTRUCTOR_C99_COMPOUND_LITERAL (t)) cl = fcl_c99; - RETURN (finish_compound_literal (type, r, complain, cl)); + return finish_compound_literal (type, r, complain, cl); } TREE_TYPE (r) = type; - RETURN (r); + return r; } case TYPEID_EXPR: @@ -20705,18 +20682,18 @@ tsubst_copy_and_build (tree t, if (TYPE_P (operand_0)) { operand_0 = tsubst (operand_0, args, complain, in_decl); - RETURN (get_typeid (operand_0, complain)); + return get_typeid (operand_0, complain); } else { operand_0 = RECUR (operand_0); - RETURN (build_typeid (operand_0, complain)); + return build_typeid (operand_0, complain); } } case VAR_DECL: if (!args) - RETURN (t); + return t; /* Fall through */ case PARM_DECL: @@ -20734,14 +20711,14 @@ tsubst_copy_and_build (tree t, /* If the original type was a reference, we'll be wrapped in the appropriate INDIRECT_REF. */ r = convert_from_reference (r); - RETURN (r); + return r; } case VA_ARG_EXPR: { tree op0 = RECUR (TREE_OPERAND (t, 0)); tree type = tsubst (TREE_TYPE (t), args, complain, in_decl); - RETURN (build_x_va_arg (EXPR_LOCATION (t), op0, type)); + return build_x_va_arg (EXPR_LOCATION (t), op0, type); } case OFFSETOF_EXPR: @@ -20750,14 +20727,14 @@ tsubst_copy_and_build (tree t, = tsubst_copy_and_build (TREE_OPERAND (t, 1), args, complain, in_decl, /*function_p=*/false, /*integral_constant_expression_p=*/false); - RETURN (finish_offsetof (object_ptr, - RECUR (TREE_OPERAND (t, 0)), - EXPR_LOCATION (t))); + return finish_offsetof (object_ptr, + RECUR (TREE_OPERAND (t, 0)), + EXPR_LOCATION (t)); } case ADDRESSOF_EXPR: - RETURN (cp_build_addressof (EXPR_LOCATION (t), - RECUR (TREE_OPERAND (t, 0)), complain)); + return cp_build_addressof (EXPR_LOCATION (t), + RECUR (TREE_OPERAND (t, 0)), complain); case TRAIT_EXPR: { @@ -20765,8 +20742,8 @@ tsubst_copy_and_build (tree t, complain, in_decl); tree type2 = tsubst (TRAIT_EXPR_TYPE2 (t), args, complain, in_decl); - RETURN (finish_trait_expr (TRAIT_EXPR_LOCATION (t), - TRAIT_EXPR_KIND (t), type1, type2)); + return finish_trait_expr (TRAIT_EXPR_LOCATION (t), + TRAIT_EXPR_KIND (t), type1, type2); } case STMT_EXPR: @@ -20785,7 +20762,7 @@ tsubst_copy_and_build (tree t, if (empty_expr_stmt_p (stmt_expr)) stmt_expr = void_node; - RETURN (stmt_expr); + return stmt_expr; } case LAMBDA_EXPR: @@ -20799,7 +20776,7 @@ tsubst_copy_and_build (tree t, } tree r = tsubst_lambda_expr (t, args, complain, in_decl); - RETURN (build_lambda_object (r)); + return build_lambda_object (r); } case TARGET_EXPR: @@ -20808,43 +20785,43 @@ tsubst_copy_and_build (tree t, { tree r = get_target_expr_sfinae (RECUR (TARGET_EXPR_INITIAL (t)), complain); - RETURN (r); + return r; } case TRANSACTION_EXPR: - RETURN (tsubst_expr(t, args, complain, in_decl, - integral_constant_expression_p)); + return tsubst_expr (t, args, complain, in_decl, + integral_constant_expression_p); case PAREN_EXPR: - RETURN (finish_parenthesized_expr (RECUR (TREE_OPERAND (t, 0)))); + return finish_parenthesized_expr (RECUR (TREE_OPERAND (t, 0))); case VEC_PERM_EXPR: { tree op0 = RECUR (TREE_OPERAND (t, 0)); tree op1 = RECUR (TREE_OPERAND (t, 1)); tree op2 = RECUR (TREE_OPERAND (t, 2)); - RETURN (build_x_vec_perm_expr (input_location, op0, op1, op2, - complain)); + return build_x_vec_perm_expr (input_location, op0, op1, op2, + complain); } case REQUIRES_EXPR: { tree r = tsubst_requires_expr (t, args, tf_none, in_decl); - RETURN (r); + return r; } case RANGE_EXPR: /* No need to substitute further, a RANGE_EXPR will always be built with constant operands. */ - RETURN (t); + return t; case NON_LVALUE_EXPR: case VIEW_CONVERT_EXPR: if (location_wrapper_p (t)) /* We need to do this here as well as in tsubst_copy so we get the other tsubst_copy_and_build semantics for a PARM_DECL operand. */ - RETURN (maybe_wrap_with_location (RECUR (TREE_OPERAND (t, 0)), - EXPR_LOCATION (t))); + return maybe_wrap_with_location (RECUR (TREE_OPERAND (t, 0)), + EXPR_LOCATION (t)); /* fallthrough. */ default: @@ -20854,16 +20831,13 @@ tsubst_copy_and_build (tree t, = objcp_tsubst_copy_and_build (t, args, complain, in_decl, /*function_p=*/false); if (subst) - RETURN (subst); + return subst; } - RETURN (tsubst_copy (t, args, complain, in_decl)); + return tsubst_copy (t, args, complain, in_decl); } + gcc_unreachable (); #undef RECUR -#undef RETURN - out: - input_location = save_loc; - return retval; } /* Verify that the instantiated ARGS are valid. For type arguments, -- 2.30.1.489.g328c109303