From f9d0ca4043e4c430324a655fdce3f8e4acefe5e3 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 5 Aug 2019 20:04:22 +0000 Subject: [PATCH] cp-tree.h (cp_expr_loc_or_input_loc): New. 2019-08-05 Paolo Carlini * cp-tree.h (cp_expr_loc_or_input_loc): New. (cxx_incomplete_type_diagnostic): Use it. * call.c (build_converted_constant_expr_internal, convert_like_real, convert_arg_to_ellipsis, convert_for_arg_passing, build_over_call, build_cxx_call, perform_implicit_conversion_flags, initialize_reference): Likewise. * constexpr.c (cxx_eval_internal_function, cxx_eval_call_expression, eval_and_check_array_index, cxx_eval_store_expression, cxx_eval_statement_list, cxx_eval_loop_expr, cxx_eval_constant_expression, potential_constant_expression_1): Likewise. * constraint.cc (check_for_logical_overloads, satisfy_predicate_constraint): Likewise. * cp-gimplify.c (cp_gimplify_expr): Likewise. * cvt.c (cp_convert_to_pointer, convert_to_reference, cp_convert_and_check, ocp_convert, maybe_warn_nodiscard): Likewise. * decl.c (pop_switch): Likewise. * decl2.c (delete_sanity): Likewise. * error.c (location_of): Likewise. * init.c (maybe_warn_list_ctor, build_aggr_init, warn_placement_new_too_small, build_new_1, build_vec_init): Likewise. * lex.c (unqualified_name_lookup_error): Likewise. * parser.c (cp_parser_initializer_list, cp_parser_omp_for_cond): Likewise. * pt.c (check_for_bare_parameter_packs, check_valid_ptrmem_cst_expr, unify_arg_conversion, convert_nontype_argument, tsubst_copy_and_build, resolve_typename_type): Likewise. * semantics.c (maybe_convert_cond, finish_call_expr, cp_build_vec_convert): Likewise. * typeck.c (decay_conversion, rationalize_conditional_expr, cp_build_unary_op, build_x_compound_expr_from_list, maybe_warn_about_returning_address_of_local, maybe_warn_pessimizing_move): Likewise. * typeck2.c (check_narrowing, digest_init_r, process_init_constructor_array): Likewise. From-SVN: r274124 --- gcc/cp/ChangeLog | 38 ++++++++++++++++++++++++++++++++++++++ gcc/cp/call.c | 16 ++++++++-------- gcc/cp/constexpr.c | 30 +++++++++++++++--------------- gcc/cp/constraint.cc | 4 ++-- gcc/cp/cp-gimplify.c | 2 +- gcc/cp/cp-tree.h | 8 +++++++- gcc/cp/cvt.c | 12 ++++++------ gcc/cp/decl.c | 2 +- gcc/cp/decl2.c | 9 ++++----- gcc/cp/error.c | 2 +- gcc/cp/init.c | 12 ++++++------ gcc/cp/lex.c | 2 +- gcc/cp/parser.c | 4 ++-- gcc/cp/pt.c | 24 +++++++++++------------- gcc/cp/semantics.c | 6 +++--- gcc/cp/typeck.c | 12 ++++++------ gcc/cp/typeck2.c | 6 +++--- 17 files changed, 115 insertions(+), 74 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0c3bdffbcab..6427c2dac86 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,41 @@ +2019-08-05 Paolo Carlini + + * cp-tree.h (cp_expr_loc_or_input_loc): New. + (cxx_incomplete_type_diagnostic): Use it. + * call.c (build_converted_constant_expr_internal, convert_like_real, + convert_arg_to_ellipsis, convert_for_arg_passing, build_over_call, + build_cxx_call, perform_implicit_conversion_flags, + initialize_reference): Likewise. + * constexpr.c (cxx_eval_internal_function, cxx_eval_call_expression, + eval_and_check_array_index, cxx_eval_store_expression, + cxx_eval_statement_list, cxx_eval_loop_expr, + cxx_eval_constant_expression, potential_constant_expression_1): + Likewise. + * constraint.cc (check_for_logical_overloads, + satisfy_predicate_constraint): Likewise. + * cp-gimplify.c (cp_gimplify_expr): Likewise. + * cvt.c (cp_convert_to_pointer, convert_to_reference, + cp_convert_and_check, ocp_convert, maybe_warn_nodiscard): Likewise. + * decl.c (pop_switch): Likewise. + * decl2.c (delete_sanity): Likewise. + * error.c (location_of): Likewise. + * init.c (maybe_warn_list_ctor, build_aggr_init, + warn_placement_new_too_small, build_new_1, build_vec_init): Likewise. + * lex.c (unqualified_name_lookup_error): Likewise. + * parser.c (cp_parser_initializer_list, cp_parser_omp_for_cond): + Likewise. + * pt.c (check_for_bare_parameter_packs, check_valid_ptrmem_cst_expr, + unify_arg_conversion, convert_nontype_argument, + tsubst_copy_and_build, resolve_typename_type): Likewise. + * semantics.c (maybe_convert_cond, finish_call_expr, + cp_build_vec_convert): Likewise. + * typeck.c (decay_conversion, rationalize_conditional_expr, + cp_build_unary_op, build_x_compound_expr_from_list, + maybe_warn_about_returning_address_of_local, + maybe_warn_pessimizing_move): Likewise. + * typeck2.c (check_narrowing, digest_init_r, + process_init_constructor_array): Likewise. + 2019-08-05 Tom Honermann * parser.c (cp_parser_template_declaration_after_parameters): Enable diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 38d229b1f33..61334a16248 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4184,7 +4184,7 @@ build_converted_constant_expr_internal (tree type, tree expr, conversion *conv; void *p; tree t; - location_t loc = cp_expr_loc_or_loc (expr, input_location); + location_t loc = cp_expr_loc_or_input_loc (expr); if (error_operand_p (expr)) return error_mark_node; @@ -6961,7 +6961,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, tree totype = convs->type; diagnostic_t diag_kind; int flags; - location_t loc = cp_expr_loc_or_loc (expr, input_location); + location_t loc = cp_expr_loc_or_input_loc (expr); if (convs->bad_p && !(complain & tf_error)) return error_mark_node; @@ -7481,7 +7481,7 @@ tree convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain) { tree arg_type; - location_t loc = cp_expr_loc_or_loc (arg, input_location); + location_t loc = cp_expr_loc_or_input_loc (arg); /* [expr.call] @@ -7789,7 +7789,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain) "argument of function call might be a candidate " "for a format attribute"); } - maybe_warn_parm_abi (type, cp_expr_loc_or_loc (val, input_location)); + maybe_warn_parm_abi (type, cp_expr_loc_or_input_loc (val)); } if (complain & tf_warning) @@ -8595,7 +8595,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) tree type = TREE_TYPE (to); tree as_base = CLASSTYPE_AS_BASE (type); tree arg = argarray[1]; - location_t loc = cp_expr_loc_or_loc (arg, input_location); + location_t loc = cp_expr_loc_or_input_loc (arg); if (is_really_empty_class (type, /*ignore_vptr*/true)) { @@ -9143,7 +9143,7 @@ build_cxx_call (tree fn, int nargs, tree *argarray, tree fndecl; /* Remember roughly where this call is. */ - location_t loc = cp_expr_loc_or_loc (fn, input_location); + location_t loc = cp_expr_loc_or_input_loc (fn); fn = build_call_a (fn, nargs, argarray); SET_EXPR_LOCATION (fn, loc); @@ -11183,7 +11183,7 @@ perform_implicit_conversion_flags (tree type, tree expr, { conversion *conv; void *p; - location_t loc = cp_expr_loc_or_loc (expr, input_location); + location_t loc = cp_expr_loc_or_input_loc (expr); if (TYPE_REF_P (type)) expr = mark_lvalue_use (expr); @@ -11532,7 +11532,7 @@ initialize_reference (tree type, tree expr, { conversion *conv; void *p; - location_t loc = cp_expr_loc_or_loc (expr, input_location); + location_t loc = cp_expr_loc_or_input_loc (expr); if (type == error_mark_node || error_operand_p (expr)) return error_mark_node; diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index c1b8b9b8a5d..75df9844dc6 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1527,7 +1527,7 @@ cxx_eval_internal_function (const constexpr_ctx *ctx, tree t, default: if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "call to internal function %qE", t); *non_constant_p = true; return t; @@ -1542,7 +1542,7 @@ cxx_eval_internal_function (const constexpr_ctx *ctx, tree t, if (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST) { - location_t loc = cp_expr_loc_or_loc (t, input_location); + location_t loc = cp_expr_loc_or_input_loc (t); tree type = TREE_TYPE (TREE_TYPE (t)); tree result = fold_binary_loc (loc, opcode, type, fold_convert_loc (loc, type, arg0), @@ -1584,7 +1584,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, bool lval, bool *non_constant_p, bool *overflow_p) { - location_t loc = cp_expr_loc_or_loc (t, input_location); + location_t loc = cp_expr_loc_or_input_loc (t); tree fun = get_function_named_in_call (t); constexpr_call new_call = { NULL, NULL, NULL, 0, ctx->manifestly_const_eval }; @@ -2580,7 +2580,7 @@ eval_and_check_array_index (const constexpr_ctx *ctx, tree t, bool allow_one_past, bool *non_constant_p, bool *overflow_p) { - location_t loc = cp_expr_loc_or_loc (t, input_location); + location_t loc = cp_expr_loc_or_input_loc (t); tree ary = TREE_OPERAND (t, 0); t = TREE_OPERAND (t, 1); tree index = cxx_eval_constant_expression (ctx, t, false, @@ -3909,7 +3909,7 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, if (cxx_dialect < cxx2a) { if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "change of the active member of a union " "from %qD to %qD", CONSTRUCTOR_ELT (*valp, 0)->index, @@ -4220,7 +4220,7 @@ cxx_eval_statement_list (const constexpr_ctx *ctx, tree t, /* We aren't communicating the jump to our caller, so give up. We don't need to support evaluation of jumps out of statement-exprs. */ if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (r, input_location), + error_at (cp_expr_loc_or_input_loc (r), "statement is not a constant expression"); *non_constant_p = true; } @@ -4320,7 +4320,7 @@ cxx_eval_loop_expr (const constexpr_ctx *ctx, tree t, if (++count >= constexpr_loop_limit) { if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "% loop iteration count exceeds limit of %d " "(use %<-fconstexpr-loop-limit=%> to increase the limit)", constexpr_loop_limit); @@ -4482,7 +4482,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, if (++*ctx->constexpr_ops_count >= constexpr_ops_limit) { if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "% evaluation operation count exceeds limit of " "%wd (use %<-fconstexpr-ops-limit=%> to increase the limit)", constexpr_ops_limit); @@ -5036,7 +5036,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, if (REINTERPRET_CAST_P (t)) { if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "% is not a constant expression"); *non_constant_p = true; return t; @@ -5077,7 +5077,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, if (TYPE_REF_P (type)) { if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "dereferencing a null pointer"); *non_constant_p = true; return t; @@ -5089,7 +5089,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, if (!can_convert (type, from, tf_none)) { if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "conversion of %qT null pointer to %qT " "is not a constant expression", from, type); @@ -5104,7 +5104,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, reinterpret_cast(sizeof 0) */ if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "%(%E)%> is not " "a constant expression", type, op); @@ -5178,7 +5178,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, case BASELINK: case OFFSET_REF: if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "expression %qE is not a constant expression", t); *non_constant_p = true; break; @@ -5196,7 +5196,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, || !DECL_P (get_base_address (TREE_OPERAND (obj, 0)))) { if (!ctx->quiet) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "expression %qE is not a constant expression", t); *non_constant_p = true; return t; @@ -5960,7 +5960,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, return false; if (t == NULL_TREE) return true; - location_t loc = cp_expr_loc_or_loc (t, input_location); + location_t loc = cp_expr_loc_or_input_loc (t); if (*jump_target) /* If we are jumping, ignore everything. This is simpler than the diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index cc578bb5b39..48ecb766507 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -805,7 +805,7 @@ check_for_logical_overloads (tree t) if (DECL_OVERLOADED_OPERATOR_P (fn)) { - location_t loc = cp_expr_loc_or_loc (t, input_location); + location_t loc = cp_expr_loc_or_input_loc (t); error_at (loc, "constraint %qE, uses overloaded operator", t); return true; } @@ -2016,7 +2016,7 @@ satisfy_predicate_constraint (tree t, tree args, tree type = cv_unqualified (TREE_TYPE (expr)); if (!same_type_p (type, boolean_type_node)) { - error_at (cp_expr_loc_or_loc (expr, input_location), + error_at (cp_expr_loc_or_input_loc (expr), "constraint %qE does not have type %qT", expr, boolean_type_node); return boolean_false_node; diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index bce01f5098e..b4863e2d592 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -644,7 +644,7 @@ int cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) { int saved_stmts_are_full_exprs_p = 0; - location_t loc = cp_expr_loc_or_loc (*expr_p, input_location); + location_t loc = cp_expr_loc_or_input_loc (*expr_p); enum tree_code code = TREE_CODE (*expr_p); enum gimplify_status ret; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index c6a1eff9ce1..d4e67cdfd96 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7509,11 +7509,17 @@ cp_expr_loc_or_loc (const_tree t, location_t or_loc) return loc; } +inline location_t +cp_expr_loc_or_input_loc (const_tree t) +{ + return cp_expr_loc_or_loc (t, input_location); +} + inline void cxx_incomplete_type_diagnostic (const_tree value, const_tree type, diagnostic_t diag_kind) { - cxx_incomplete_type_diagnostic (cp_expr_loc_or_loc (value, input_location), + cxx_incomplete_type_diagnostic (cp_expr_loc_or_input_loc (value), value, type, diag_kind); } diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 23d2aabc483..364af72e68d 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -77,7 +77,7 @@ cp_convert_to_pointer (tree type, tree expr, bool dofold, tree intype = TREE_TYPE (expr); enum tree_code form; tree rval; - location_t loc = cp_expr_loc_or_loc (expr, input_location); + location_t loc = cp_expr_loc_or_input_loc (expr); if (intype == error_mark_node) return error_mark_node; @@ -419,7 +419,7 @@ convert_to_reference (tree reftype, tree expr, int convtype, tree rval = NULL_TREE; tree rval_as_conversion = NULL_TREE; bool can_convert_intype_to_type; - location_t loc = cp_expr_loc_or_loc (expr, input_location); + location_t loc = cp_expr_loc_or_input_loc (expr); if (TREE_CODE (type) == FUNCTION_TYPE && TREE_TYPE (expr) == unknown_type_node) @@ -671,7 +671,7 @@ cp_convert_and_check (tree type, tree expr, tsubst_flags_t complain) folded_result = fold_simple (folded_result); if (!TREE_OVERFLOW_P (folded) && folded_result != error_mark_node) - warnings_for_convert_and_check (cp_expr_loc_or_loc (expr, input_location), + warnings_for_convert_and_check (cp_expr_loc_or_input_loc (expr), type, folded, folded_result); } @@ -690,7 +690,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags, enum tree_code code = TREE_CODE (type); const char *invalid_conv_diag; tree e1; - location_t loc = cp_expr_loc_or_loc (expr, input_location); + location_t loc = cp_expr_loc_or_input_loc (expr); bool dofold = (convtype & CONV_FOLD); if (error_operand_p (e) || type == error_mark_node) @@ -1013,7 +1013,7 @@ maybe_warn_nodiscard (tree expr, impl_conv_void implicit) tree call = expr; if (TREE_CODE (expr) == TARGET_EXPR) call = TARGET_EXPR_INITIAL (expr); - location_t loc = cp_expr_loc_or_loc (call, input_location); + location_t loc = cp_expr_loc_or_input_loc (call); tree callee = cp_get_callee (call); if (!callee) return; @@ -1093,7 +1093,7 @@ maybe_warn_nodiscard (tree expr, impl_conv_void implicit) tree convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain) { - location_t loc = cp_expr_loc_or_loc (expr, input_location); + location_t loc = cp_expr_loc_or_input_loc (expr); if (expr == error_mark_node || TREE_TYPE (expr) == error_mark_node) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e0102c0067d..5dda2e8e33d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3560,7 +3560,7 @@ pop_switch (void) location_t switch_location; /* Emit warnings as needed. */ - switch_location = cp_expr_loc_or_loc (cs->switch_stmt, input_location); + switch_location = cp_expr_loc_or_input_loc (cs->switch_stmt); const bool bool_cond_p = (SWITCH_STMT_TYPE (cs->switch_stmt) && TREE_CODE (SWITCH_STMT_TYPE (cs->switch_stmt)) == BOOLEAN_TYPE); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index de67c7c1cac..ad2459236b8 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -489,7 +489,7 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete, /* An array can't have been allocated by new, so complain. */ if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE && (complain & tf_warning)) - warning_at (cp_expr_loc_or_loc (exp, input_location), 0, + warning_at (cp_expr_loc_or_input_loc (exp), 0, "deleting array %q#E", exp); t = build_expr_type_conversion (WANT_POINTER, exp, true); @@ -497,7 +497,7 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete, if (t == NULL_TREE || t == error_mark_node) { if (complain & tf_error) - error_at (cp_expr_loc_or_loc (exp, input_location), + error_at (cp_expr_loc_or_input_loc (exp), "type %q#T argument given to %, expected pointer", TREE_TYPE (exp)); return error_mark_node; @@ -511,7 +511,7 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete, if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE) { if (complain & tf_error) - error_at (cp_expr_loc_or_loc (exp, input_location), + error_at (cp_expr_loc_or_input_loc (exp), "cannot delete a function. Only pointer-to-objects are " "valid arguments to %"); return error_mark_node; @@ -521,8 +521,7 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete, if (VOID_TYPE_P (TREE_TYPE (type))) { if (complain & tf_warning) - warning_at (cp_expr_loc_or_loc (exp, input_location), - OPT_Wdelete_incomplete, + warning_at (cp_expr_loc_or_input_loc (exp), OPT_Wdelete_incomplete, "deleting %qT is undefined", type); doing_vec = 0; } diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 5943762fd2d..56201345429 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -3053,7 +3053,7 @@ location_of (tree t) return DECL_SOURCE_LOCATION (t); if (TREE_CODE (t) == DEFERRED_PARSE) return defparse_location (t); - return cp_expr_loc_or_loc (t, input_location); + return cp_expr_loc_or_input_loc (t); } /* Now the interfaces from error et al to dump_type et al. Each takes an diff --git a/gcc/cp/init.c b/gcc/cp/init.c index d0f73ff1938..67e06568b2f 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -749,7 +749,7 @@ maybe_warn_list_ctor (tree member, tree init) if (!begin) return; - location_t loc = cp_expr_loc_or_loc (init, input_location); + location_t loc = cp_expr_loc_or_input_loc (init); warning_at (loc, OPT_Winit_list_lifetime, "initializing %qD from %qE does not extend the lifetime " "of the underlying array", member, begin); @@ -1749,7 +1749,7 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) return error_mark_node; location_t init_loc = (init - ? cp_expr_loc_or_loc (init, input_location) + ? cp_expr_loc_or_input_loc (init) : location_of (exp)); TREE_READONLY (exp) = 0; @@ -2578,7 +2578,7 @@ find_flexarray_init (tree t, tree init) static void warn_placement_new_too_small (tree type, tree nelts, tree size, tree oper) { - location_t loc = cp_expr_loc_or_loc (oper, input_location); + location_t loc = cp_expr_loc_or_input_loc (oper); /* The number of bytes to add to or subtract from the size of the provided buffer based on an offset into an array or an array element reference. @@ -2975,7 +2975,7 @@ build_new_1 (vec **placement, tree type, tree nelts, { if (complain & tf_error) { - error_at (cp_expr_loc_or_loc (inner_nelts, input_location), + error_at (cp_expr_loc_or_input_loc (inner_nelts), "array size in new-expression must be constant"); cxx_constant_value(inner_nelts); } @@ -3004,7 +3004,7 @@ build_new_1 (vec **placement, tree type, tree nelts, { if (complain & tf_warning_or_error) { - pedwarn (cp_expr_loc_or_loc (outer_nelts, input_location), OPT_Wvla, + pedwarn (cp_expr_loc_or_input_loc (outer_nelts), OPT_Wvla, typedef_variant_p (orig_type) ? G_("non-constant array new length must be specified " "directly, not by %") @@ -4140,7 +4140,7 @@ build_vec_init (tree base, tree maxindex, tree init, tree obase = base; bool xvalue = false; bool errors = false; - location_t loc = (init ? cp_expr_loc_or_loc (init, input_location) + location_t loc = (init ? cp_expr_loc_or_input_loc (init) : location_of (base)); if (TREE_CODE (atype) == ARRAY_TYPE && TYPE_DOMAIN (atype)) diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 5bfb1e51408..12567da39c4 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -502,7 +502,7 @@ tree unqualified_name_lookup_error (tree name, location_t loc) { if (loc == UNKNOWN_LOCATION) - loc = cp_expr_loc_or_loc (name, input_location); + loc = cp_expr_loc_or_input_loc (name); if (IDENTIFIER_ANY_OP_P (name)) error_at (loc, "%qD not defined", name); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index dd2fe79c95a..86857e7d468 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23186,7 +23186,7 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p, { if (IDENTIFIER_MARKED (designator)) { - error_at (cp_expr_loc_or_loc (val, input_location), + error_at (cp_expr_loc_or_input_loc (val), "%<.%s%> designator used multiple times in " "the same initializer list", IDENTIFIER_POINTER (designator)); @@ -36699,7 +36699,7 @@ cp_parser_omp_for_cond (cp_parser *parser, tree decl, enum tree_code code) || CLASS_TYPE_P (TREE_TYPE (decl)))) return cond; - return build_x_binary_op (cp_expr_loc_or_loc (cond, input_location), + return build_x_binary_op (cp_expr_loc_or_input_loc (cond), TREE_CODE (cond), TREE_OPERAND (cond, 0), ERROR_MARK, TREE_OPERAND (cond, 1), ERROR_MARK, diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 87d177c6824..e671fe1a91d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4059,7 +4059,7 @@ check_for_bare_parameter_packs (tree t, location_t loc /* = UNKNOWN_LOCATION */) if (parameter_packs) { if (loc == UNKNOWN_LOCATION) - loc = cp_expr_loc_or_loc (t, input_location); + loc = cp_expr_loc_or_input_loc (t); error_at (loc, "parameter packs not expanded with %<...%>:"); while (parameter_packs) { @@ -6306,7 +6306,7 @@ static bool check_valid_ptrmem_cst_expr (tree type, tree expr, tsubst_flags_t complain) { - location_t loc = cp_expr_loc_or_loc (expr, input_location); + location_t loc = cp_expr_loc_or_input_loc (expr); tree orig_expr = expr; STRIP_NOPS (expr); if (null_ptr_cst_p (expr)) @@ -6525,7 +6525,7 @@ unify_arg_conversion (bool explain_p, tree to_type, tree from_type, tree arg) { if (explain_p) - inform (cp_expr_loc_or_loc (arg, input_location), + inform (cp_expr_loc_or_input_loc (arg), " cannot convert %qE (type %qT) to type %qT", arg, from_type, to_type); return unify_invalid (explain_p); @@ -6765,7 +6765,7 @@ static tree convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) { tree expr_type; - location_t loc = cp_expr_loc_or_loc (expr, input_location); + location_t loc = cp_expr_loc_or_input_loc (expr); /* Detect immediately string literals as invalid non-type argument. This special-case is not needed for correctness (we would easily @@ -18965,10 +18965,10 @@ tsubst_copy_and_build (tree t, bool diag = true; if (in_lambda) - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), msg, function); else - diag = permerror (cp_expr_loc_or_loc (t, input_location), + diag = permerror (cp_expr_loc_or_input_loc (t), msg, function); if (diag) { @@ -18983,8 +18983,7 @@ tsubst_copy_and_build (tree t, /* Can't say anything more. */; else if (DECL_CLASS_SCOPE_P (fn)) { - location_t loc = cp_expr_loc_or_loc (t, - input_location); + location_t loc = cp_expr_loc_or_input_loc (t); inform (loc, "declarations in dependent base %qT are " "not found by unqualified lookup", @@ -19032,14 +19031,13 @@ tsubst_copy_and_build (tree t, gcc_assert (nargs == 1); if (vec_safe_length (call_args) != 1) { - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "wrong number of arguments to " "%<__builtin_launder%>"); ret = error_mark_node; } else - ret = finish_builtin_launder (cp_expr_loc_or_loc (t, - input_location), + ret = finish_builtin_launder (cp_expr_loc_or_input_loc (t), (*call_args)[0], complain); break; @@ -19047,7 +19045,7 @@ tsubst_copy_and_build (tree t, gcc_assert (nargs == 1); if (vec_safe_length (call_args) != 1) { - error_at (cp_expr_loc_or_loc (t, input_location), + error_at (cp_expr_loc_or_input_loc (t), "wrong number of arguments to " "%<__builtin_convertvector%>"); ret = error_mark_node; @@ -26602,7 +26600,7 @@ resolve_typename_type (tree type, bool only_current_p) [temp.names]: In a qualified-id of a declarator-id, the keyword template shall not appear at the top level. */ - pedwarn (cp_expr_loc_or_loc (fullname, input_location), OPT_Wpedantic, + pedwarn (cp_expr_loc_or_input_loc (fullname), OPT_Wpedantic, "keyword % not allowed in declarator-id"); tmpl = decl; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index fc90c8d6f0e..d151d3d4798 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -658,7 +658,7 @@ maybe_convert_cond (tree cond) if (TREE_CODE (cond) == MODIFY_EXPR && !TREE_NO_WARNING (cond) && warn_parentheses - && warning_at (cp_expr_loc_or_loc (cond, input_location), + && warning_at (cp_expr_loc_or_input_loc (cond), OPT_Wparentheses, "suggest parentheses around " "assignment used as truth value")) TREE_NO_WARNING (cond) = 1; @@ -2428,7 +2428,7 @@ finish_call_expr (tree fn, vec **args, bool disallow_virtual, || any_type_dependent_arguments_p (*args)) { result = build_min_nt_call_vec (orig_fn, *args); - SET_EXPR_LOCATION (result, cp_expr_loc_or_loc (fn, input_location)); + SET_EXPR_LOCATION (result, cp_expr_loc_or_input_loc (fn)); KOENIG_LOOKUP_P (result) = koenig_p; if (is_overloaded_fn (fn)) fn = get_fns (fn); @@ -10104,7 +10104,7 @@ cp_build_vec_convert (tree arg, location_t loc, tree type, tree ret = NULL_TREE; if (!type_dependent_expression_p (arg) && !dependent_type_p (type)) - ret = c_build_vec_convert (cp_expr_loc_or_loc (arg, input_location), arg, + ret = c_build_vec_convert (cp_expr_loc_or_input_loc (arg), arg, loc, type, (complain & tf_error) != 0); if (!processing_template_decl) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 77095953134..7e4ea3bee75 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2020,7 +2020,7 @@ decay_conversion (tree exp, { tree type; enum tree_code code; - location_t loc = cp_expr_loc_or_loc (exp, input_location); + location_t loc = cp_expr_loc_or_input_loc (exp); type = TREE_TYPE (exp); if (type == error_mark_node) @@ -2281,7 +2281,7 @@ static tree rationalize_conditional_expr (enum tree_code code, tree t, tsubst_flags_t complain) { - location_t loc = cp_expr_loc_or_loc (t, input_location); + location_t loc = cp_expr_loc_or_input_loc (t); /* For MIN_EXPR or MAX_EXPR, fold-const.c has arranged things so that the first operand is always the one to be used if both operands @@ -6206,7 +6206,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert, { /* No default_conversion here. It causes trouble for ADDR_EXPR. */ tree arg = xarg; - location_t location = cp_expr_loc_or_loc (arg, input_location); + location_t location = cp_expr_loc_or_input_loc (arg); tree argtype = 0; const char *errstring = NULL; tree val; @@ -6760,7 +6760,7 @@ build_x_compound_expr_from_list (tree list, expr_list_kind exp, && !CONSTRUCTOR_IS_DIRECT_INIT (expr)) { if (complain & tf_error) - pedwarn (cp_expr_loc_or_loc (expr, input_location), 0, + pedwarn (cp_expr_loc_or_input_loc (expr), 0, "list-initializer for non-class type must not " "be parenthesized"); else @@ -9210,7 +9210,7 @@ maybe_warn_about_returning_address_of_local (tree retval) { tree valtype = TREE_TYPE (DECL_RESULT (current_function_decl)); tree whats_returned = fold_for_warn (retval); - location_t loc = cp_expr_loc_or_loc (retval, input_location); + location_t loc = cp_expr_loc_or_input_loc (retval); for (;;) { @@ -9420,7 +9420,7 @@ maybe_warn_pessimizing_move (tree retval, tree functype) if (!(warn_pessimizing_move || warn_redundant_move)) return; - location_t loc = cp_expr_loc_or_loc (retval, input_location); + location_t loc = cp_expr_loc_or_input_loc (retval); /* C++98 doesn't know move. */ if (cxx_dialect < cxx11) diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index e8627dd38c0..02c3ad5efb0 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1006,7 +1006,7 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain, bool const_only) if (!ok) { - location_t loc = cp_expr_loc_or_loc (init, input_location); + location_t loc = cp_expr_loc_or_input_loc (init); if (cxx_dialect == cxx98) { if (complain & tf_warning) @@ -1085,7 +1085,7 @@ digest_init_r (tree type, tree init, int nested, int flags, complain)) return error_mark_node; - location_t loc = cp_expr_loc_or_loc (init, input_location); + location_t loc = cp_expr_loc_or_input_loc (init); tree stripped_init = init; @@ -1402,7 +1402,7 @@ process_init_constructor_array (tree type, tree init, int nested, int flags, if (nested == 2 && !domain && !vec_safe_is_empty (v)) { if (complain & tf_error) - error_at (cp_expr_loc_or_loc (init, input_location), + error_at (cp_expr_loc_or_input_loc (init), "initialization of flexible array member " "in a nested context"); return PICFLAG_ERRONEOUS; -- 2.30.2