+2019-08-05 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * 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 <tom@honermann.net>
* parser.c (cp_parser_template_declaration_after_parameters): Enable
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;
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;
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]
"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)
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))
{
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);
{
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);
{
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;
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;
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),
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 };
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,
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,
/* 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;
}
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),
"%<constexpr%> loop iteration count exceeds limit of %d "
"(use %<-fconstexpr-loop-limit=%> to increase the limit)",
constexpr_loop_limit);
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),
"%<constexpr%> evaluation operation count exceeds limit of "
"%wd (use %<-fconstexpr-ops-limit=%> to increase the limit)",
constexpr_ops_limit);
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),
"%<reinterpret_cast%> is not a constant expression");
*non_constant_p = true;
return 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;
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);
reinterpret_cast<void*>(sizeof 0)
*/
if (!ctx->quiet)
- error_at (cp_expr_loc_or_loc (t, input_location),
+ error_at (cp_expr_loc_or_input_loc (t),
"%<reinterpret_cast<%T>(%E)%> is not "
"a constant expression",
type, op);
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;
|| !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;
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
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;
}
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;
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;
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);
}
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;
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)
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);
}
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)
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;
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)
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);
/* 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);
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 %<delete%>, expected pointer",
TREE_TYPE (exp));
return error_mark_node;
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 %<delete%>");
return error_mark_node;
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;
}
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
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);
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;
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.
{
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);
}
{
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 %<typedef%>")
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))
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);
{
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));
|| 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,
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)
{
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))
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);
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
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)
{
/* 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",
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;
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;
[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 %<template%> not allowed in declarator-id");
tmpl = decl;
}
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;
|| 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);
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)
{
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)
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
{
/* 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;
&& !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
{
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 (;;)
{
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)
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)
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;
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;