+2019-12-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * typeck.c (check_for_casting_away_constness): Add location_t
+ parameter and use it.
+ (maybe_warn_about_useless_cast): Likewise.
+ (maybe_warn_about_cast_ignoring_quals): Likewise.
+ (build_static_cast_1): Likewise.
+ (build_static_cast): Likewise; sets the location of the returned tree.
+ (build_reinterpret_cast_1): Likewise.
+ (build_reinterpret_cast): Likewise; sets the location of the returned
+ tree.
+ (build_const_cast_1): Likewise.
+ (build_const_cast): Likewise; sets the location of the returned tree.
+ (cp_build_c_cast): Likewise.
+ (build_c_cast): Adjust.
+ (build_ptrmemfunc): Adjust calls.
+ (cp_build_unary_op): Pass the location to invert_truthvalue_loc.
+ * rtti.c (build_dynamic_cast_1): Add location_t parameter and
+ use it.
+ (build_dynamic_cast): Likewise.
+ * cp-tree.h: Adjust declarations.
+ * parser.c (cp_parser_postfix_expression): Pass cp_cast_loc to
+ the various build_*_cast functions.
+ (get_cast_suggestion): Adjust calls.
+ (cp_parser_builtin_offsetof): Likewise.
+ * decl.c (reshape_init): Adjust call.
+ * method.c (forward_parm): Likewise.
+ (build_comparison_op): Likewise.
+ * pt.c (tsubst_copy_and_build): Likewise.
+ * semantics.c (finish_omp_reduction_clause): Likewise.
+ (cp_omp_finish_iterators): Likewise.
+ * tree.c (cp_stabilize_reference): Likewise.
+ (move): Likewise.
+ * typeck2.c (build_functional_cast): Likewise.
+
+ * typeck2.c (build_functional_cast_1): New.
+ (build_functional_cast_1): Calls the latter and sets the location
+ of the returned tree.
+
2019-12-08 Jakub Jelinek <jakub@redhat.com>
* cvt.c (maybe_warn_nodiscard): Add workaround for GCC 3.4-4.4 - cast
extern tree get_tinfo_decl (tree);
extern tree get_typeid (tree, tsubst_flags_t);
extern tree build_headof (tree);
-extern tree build_dynamic_cast (tree, tree, tsubst_flags_t);
+extern tree build_dynamic_cast (location_t, tree, tree,
+ tsubst_flags_t);
extern void emit_support_tinfos (void);
extern bool emit_tinfo_decl (tree);
tsubst_flags_t);
extern tree build_compound_expr (location_t, tree, tree);
extern tree cp_build_compound_expr (tree, tree, tsubst_flags_t);
-extern tree build_static_cast (tree, tree, tsubst_flags_t);
-extern tree build_reinterpret_cast (tree, tree, tsubst_flags_t);
-extern tree build_const_cast (tree, tree, tsubst_flags_t);
+extern tree build_static_cast (location_t, tree, tree,
+ tsubst_flags_t);
+extern tree build_reinterpret_cast (location_t, tree, tree,
+ tsubst_flags_t);
+extern tree build_const_cast (location_t, tree, tree,
+ tsubst_flags_t);
extern tree build_c_cast (location_t, tree, tree);
extern cp_expr build_c_cast (location_t loc, tree type,
cp_expr expr);
-extern tree cp_build_c_cast (tree, tree, tsubst_flags_t);
+extern tree cp_build_c_cast (location_t, tree, tree,
+ tsubst_flags_t);
extern cp_expr build_x_modify_expr (location_t, tree,
enum tree_code, tree,
tsubst_flags_t);
extern void check_template_keyword (tree);
extern bool check_raw_literal_operator (const_tree decl);
extern bool check_literal_operator_args (const_tree, bool *, bool *);
-extern void maybe_warn_about_useless_cast (tree, tree, tsubst_flags_t);
+extern void maybe_warn_about_useless_cast (location_t, tree, tree,
+ tsubst_flags_t);
extern tree cp_perform_integral_promotions (tree, tsubst_flags_t);
extern tree finish_left_unary_fold_expr (tree, int);
{
warning_sentinel w (warn_useless_cast);
warning_sentinel w2 (warn_ignored_qualifiers);
- return cp_build_c_cast (type, elt, tf_warning_or_error);
+ return cp_build_c_cast (input_location, type, elt,
+ tf_warning_or_error);
}
else
return error_mark_node;
if (!TYPE_REF_P (type))
type = cp_build_reference_type (type, /*rval=*/true);
warning_sentinel w (warn_useless_cast);
- exp = build_static_cast (type, exp, tf_warning_or_error);
+ exp = build_static_cast (input_location, type, exp,
+ tf_warning_or_error);
if (DECL_PACK_P (parm))
exp = make_pack_expansion (exp);
return exp;
if (TREE_CODE (comp) == SPACESHIP_EXPR)
TREE_TYPE (comp) = rettype;
else
- comp = build_static_cast (rettype, comp, complain);
+ comp = build_static_cast (input_location, rettype, comp,
+ complain);
info.check (comp);
if (info.defining)
{
{
tree seql = lookup_comparison_result (cc_strong_ordering,
"equal", complain);
- val = build_static_cast (rettype, seql, complain);
+ val = build_static_cast (input_location, rettype, seql,
+ complain);
}
finish_return_stmt (val);
}
break;
}
+ /* Construct a location e.g. :
+ reinterpret_cast <int *> (expr)
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ranging from the start of the "*_cast" token to the final closing
+ paren, with the caret at the start. */
+ location_t cp_cast_loc = make_location (start_loc, start_loc, end_loc);
+
switch (keyword)
{
case RID_DYNCAST:
postfix_expression
- = build_dynamic_cast (type, expression, tf_warning_or_error);
+ = build_dynamic_cast (cp_cast_loc, type, expression,
+ tf_warning_or_error);
break;
case RID_STATCAST:
postfix_expression
- = build_static_cast (type, expression, tf_warning_or_error);
+ = build_static_cast (cp_cast_loc, type, expression,
+ tf_warning_or_error);
break;
case RID_REINTCAST:
postfix_expression
- = build_reinterpret_cast (type, expression,
+ = build_reinterpret_cast (cp_cast_loc, type, expression,
tf_warning_or_error);
break;
case RID_CONSTCAST:
postfix_expression
- = build_const_cast (type, expression, tf_warning_or_error);
+ = build_const_cast (cp_cast_loc, type, expression,
+ tf_warning_or_error);
break;
default:
gcc_unreachable ();
}
-
- /* Construct a location e.g. :
- reinterpret_cast <int *> (expr)
- ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ranging from the start of the "*_cast" token to the final closing
- paren, with the caret at the start. */
- location_t cp_cast_loc = make_location (start_loc, start_loc, end_loc);
- postfix_expression.set_location (cp_cast_loc);
}
break;
return NULL;
/* First try const_cast. */
- trial = build_const_cast (dst_type, orig_expr, tf_none);
+ trial = build_const_cast (input_location, dst_type, orig_expr, tf_none);
if (trial != error_mark_node)
return "const_cast";
/* If that fails, try static_cast. */
- trial = build_static_cast (dst_type, orig_expr, tf_none);
+ trial = build_static_cast (input_location, dst_type, orig_expr, tf_none);
if (trial != error_mark_node)
return "static_cast";
/* Finally, try reinterpret_cast. */
- trial = build_reinterpret_cast (dst_type, orig_expr, tf_none);
+ trial = build_reinterpret_cast (input_location, dst_type, orig_expr,
+ tf_none);
if (trial != error_mark_node)
return "reinterpret_cast";
/* Build the (type *)null that begins the traditional offsetof macro. */
tree object_ptr
- = build_static_cast (build_pointer_type (type), null_pointer_node,
- tf_warning_or_error);
+ = build_static_cast (input_location, build_pointer_type (type),
+ null_pointer_node, tf_warning_or_error);
/* Parse the offsetof-member-designator. We begin as if we saw "expr->". */
expr = cp_parser_postfix_dot_deref_expression (parser, CPP_DEREF, object_ptr,
parser->lexer);
cast = build_functional_cast (combined_loc, type, expression_list,
tf_warning_or_error);
- cast.set_location (combined_loc);
/* [expr.const]/1: In an integral constant expression "only type
conversions to integral or enumeration type can be used". */
r = build_functional_cast (input_location, type, op, complain);
break;
case REINTERPRET_CAST_EXPR:
- r = build_reinterpret_cast (type, op, complain);
+ r = build_reinterpret_cast (input_location, type, op, complain);
break;
case CONST_CAST_EXPR:
- r = build_const_cast (type, op, complain);
+ r = build_const_cast (input_location, type, op, complain);
break;
case DYNAMIC_CAST_EXPR:
- r = build_dynamic_cast (type, op, complain);
+ r = build_dynamic_cast (input_location, type, op, complain);
break;
case STATIC_CAST_EXPR:
- r = build_static_cast (type, op, complain);
+ r = build_static_cast (input_location, type, op, complain);
break;
default:
gcc_unreachable ();
static tree ifnonnull (tree, tree, tsubst_flags_t);
static tree tinfo_name (tree, bool);
-static tree build_dynamic_cast_1 (tree, tree, tsubst_flags_t);
+static tree build_dynamic_cast_1 (location_t, tree, tree, tsubst_flags_t);
static tree throw_bad_cast (void);
static tree throw_bad_typeid (void);
static tree get_tinfo_ptr (tree);
paper. */
static tree
-build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain)
+build_dynamic_cast_1 (location_t loc, tree type, tree expr,
+ tsubst_flags_t complain)
{
enum tree_code tc = TREE_CODE (type);
tree exprtype;
tree binfo = lookup_base (TREE_TYPE (exprtype), TREE_TYPE (type),
ba_check, NULL, complain);
if (binfo)
- return build_static_cast (type, expr, complain);
+ return build_static_cast (loc, type, expr, complain);
}
/* Apply trivial conversion T -> T& for dereferenced ptrs. */
{
tree expr = throw_bad_cast ();
if (complain & tf_warning)
- warning (0, "%<dynamic_cast<%#T>(%#D)%> can never succeed",
- type, old_expr);
+ warning_at (loc, 0,
+ "%<dynamic_cast<%#T>(%#D)%> can never succeed",
+ type, old_expr);
/* Bash it to the expected type. */
TREE_TYPE (expr) = type;
return expr;
&& TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE)
{
if (complain & tf_warning)
- warning (0, "%<dynamic_cast<%#T>(%#D)%> can never succeed",
- type, op);
+ warning_at (loc, 0,
+ "%<dynamic_cast<%#T>(%#D)%> can never succeed",
+ type, op);
retval = build_int_cst (type, 0);
return retval;
}
if (!flag_rtti)
{
if (complain & tf_error)
- error ("%<dynamic_cast%> not permitted with %<-fno-rtti%>");
+ error_at (loc,
+ "%<dynamic_cast%> not permitted with %<-fno-rtti%>");
return error_mark_node;
}
fail:
if (complain & tf_error)
- error ("cannot %<dynamic_cast%> %qE (of type %q#T) to type %q#T (%s)",
- old_expr, TREE_TYPE (old_expr), type, errstr);
+ error_at (loc, "cannot %<dynamic_cast%> %qE (of type %q#T) "
+ "to type %q#T (%s)",
+ old_expr, TREE_TYPE (old_expr), type, errstr);
return error_mark_node;
}
tree
-build_dynamic_cast (tree type, tree expr, tsubst_flags_t complain)
+build_dynamic_cast (location_t loc, tree type, tree expr,
+ tsubst_flags_t complain)
{
tree r;
{
expr = build_min (DYNAMIC_CAST_EXPR, type, expr);
TREE_SIDE_EFFECTS (expr) = 1;
- return convert_from_reference (expr);
+ r = convert_from_reference (expr);
+ protected_set_expr_location (r, loc);
+ return r;
}
- r = convert_from_reference (build_dynamic_cast_1 (type, expr, complain));
+ r = convert_from_reference (build_dynamic_cast_1 (loc, type, expr,
+ complain));
if (r != error_mark_node)
- maybe_warn_about_useless_cast (type, expr, complain);
+ maybe_warn_about_useless_cast (loc, type, expr, complain);
+ protected_set_expr_location (r, loc);
return r;
}
if (need_static_cast)
{
tree rtype = build_reference_type (atype);
- omp_out = build_static_cast (rtype, omp_out,
+ omp_out = build_static_cast (input_location,
+ rtype, omp_out,
tf_warning_or_error);
- omp_in = build_static_cast (rtype, omp_in,
+ omp_in = build_static_cast (input_location,
+ rtype, omp_in,
tf_warning_or_error);
if (omp_out == error_mark_node || omp_in == error_mark_node)
return true;
return true;
}
tree rtype = build_reference_type (atype);
- omp_priv = build_static_cast (rtype, omp_priv,
+ omp_priv = build_static_cast (input_location,
+ rtype, omp_priv,
tf_warning_or_error);
- omp_orig = build_static_cast (rtype, omp_orig,
+ omp_orig = build_static_cast (input_location,
+ rtype, omp_orig,
tf_warning_or_error);
if (omp_priv == error_mark_node
|| omp_orig == error_mark_node)
begin = mark_rvalue_use (begin);
end = mark_rvalue_use (end);
step = mark_rvalue_use (step);
- begin = cp_build_c_cast (type, begin, tf_warning_or_error);
- end = cp_build_c_cast (type, end, tf_warning_or_error);
+ begin = cp_build_c_cast (input_location, type, begin,
+ tf_warning_or_error);
+ end = cp_build_c_cast (input_location, type, end,
+ tf_warning_or_error);
orig_step = step;
if (!processing_template_decl)
step = orig_step = save_expr (step);
tree stype = POINTER_TYPE_P (type) ? sizetype : type;
- step = cp_build_c_cast (stype, step, tf_warning_or_error);
+ step = cp_build_c_cast (input_location, stype, step,
+ tf_warning_or_error);
if (POINTER_TYPE_P (type) && !processing_template_decl)
{
begin = save_expr (begin);
/* This inhibits warnings in, eg, cxx_mark_addressable
(c++/60955). */
warning_sentinel s (extra_warnings);
- ref = build_static_cast (type, ref, tf_error);
+ ref = build_static_cast (input_location, type, ref,
+ tf_error);
}
}
tree type = TREE_TYPE (expr);
gcc_assert (!TYPE_REF_P (type));
type = cp_build_reference_type (type, /*rval*/true);
- return build_static_cast (type, expr, tf_warning_or_error);
+ return build_static_cast (input_location, type, expr,
+ tf_warning_or_error);
}
/* Used by the C++ front end to build qualified array types. However,
build_zero_cst (TREE_TYPE (arg)), complain);
arg = perform_implicit_conversion (boolean_type_node, arg,
complain);
- val = invert_truthvalue_loc (input_location, arg);
+ val = invert_truthvalue_loc (location, arg);
if (arg != error_mark_node)
return val;
errstring = _("in argument to unary !");
*/
static bool
-check_for_casting_away_constness (tree src_type, tree dest_type,
- enum tree_code cast, tsubst_flags_t complain)
+check_for_casting_away_constness (location_t loc, tree src_type,
+ tree dest_type, enum tree_code cast,
+ tsubst_flags_t complain)
{
/* C-style casts are allowed to cast away constness. With
WARN_CAST_QUAL, we still want to issue a warning. */
{
case CAST_EXPR:
if (complain & tf_warning)
- warning (OPT_Wcast_qual,
- "cast from type %qT to type %qT casts away qualifiers",
- src_type, dest_type);
+ warning_at (loc, OPT_Wcast_qual,
+ "cast from type %qT to type %qT casts away qualifiers",
+ src_type, dest_type);
return false;
-
+
case STATIC_CAST_EXPR:
if (complain & tf_error)
- error ("%<static_cast%> from type %qT to type %qT casts away "
- "qualifiers",
- src_type, dest_type);
+ error_at (loc, "%<static_cast%> from type %qT to type %qT casts "
+ "away qualifiers",
+ src_type, dest_type);
return true;
-
+
case REINTERPRET_CAST_EXPR:
if (complain & tf_error)
- error ("%<reinterpret_cast%> from type %qT to type %qT casts away "
- "qualifiers",
- src_type, dest_type);
+ error_at (loc, "%<reinterpret_cast%> from type %qT to type %qT "
+ "casts away qualifiers",
+ src_type, dest_type);
return true;
default:
/* Warns if the cast from expression EXPR to type TYPE is useless. */
void
-maybe_warn_about_useless_cast (tree type, tree expr, tsubst_flags_t complain)
+maybe_warn_about_useless_cast (location_t loc, tree type, tree expr,
+ tsubst_flags_t complain)
{
if (warn_useless_cast
&& complain & tf_warning)
? xvalue_p (expr) : lvalue_p (expr))
&& same_type_p (TREE_TYPE (expr), TREE_TYPE (type)))
|| same_type_p (TREE_TYPE (expr), type))
- warning (OPT_Wuseless_cast, "useless cast to type %q#T", type);
+ warning_at (loc, OPT_Wuseless_cast,
+ "useless cast to type %q#T", type);
}
}
/* Warns if the cast ignores cv-qualifiers on TYPE. */
-void
-maybe_warn_about_cast_ignoring_quals (tree type, tsubst_flags_t complain)
+static void
+maybe_warn_about_cast_ignoring_quals (location_t loc, tree type,
+ tsubst_flags_t complain)
{
if (warn_ignored_qualifiers
&& complain & tf_warning
&& !CLASS_TYPE_P (type)
&& (cp_type_quals (type) & (TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE)))
- {
- warning (OPT_Wignored_qualifiers, "type qualifiers ignored on cast "
- "result type");
- }
+ warning_at (loc, OPT_Wignored_qualifiers,
+ "type qualifiers ignored on cast result type");
}
/* Convert EXPR (an expression with pointer-to-member type) to TYPE
indicate whether or not the cast was valid. */
static tree
-build_static_cast_1 (tree type, tree expr, bool c_cast_p,
+build_static_cast_1 (location_t loc, tree type, tree expr, bool c_cast_p,
bool *valid_p, tsubst_flags_t complain)
{
tree intype;
if (sanitize_flags_p (SANITIZE_VPTR))
{
tree ubsan_check
- = cp_ubsan_maybe_instrument_downcast (input_location, type,
+ = cp_ubsan_maybe_instrument_downcast (loc, type,
intype, expr);
if (ubsan_check)
expr = ubsan_check;
return expr;
if (!c_cast_p
- && check_for_casting_away_constness (intype, type, STATIC_CAST_EXPR,
+ && check_for_casting_away_constness (loc, intype, type,
+ STATIC_CAST_EXPR,
complain))
return error_mark_node;
base = lookup_base (TREE_TYPE (type), TREE_TYPE (intype),
if (sanitize_flags_p (SANITIZE_VPTR))
{
tree ubsan_check
- = cp_ubsan_maybe_instrument_downcast (input_location, type,
+ = cp_ubsan_maybe_instrument_downcast (loc, type,
intype, expr);
if (ubsan_check)
expr = ubsan_check;
if (can_convert (t1, t2, complain) || can_convert (t2, t1, complain))
{
if (!c_cast_p
- && check_for_casting_away_constness (intype, type,
+ && check_for_casting_away_constness (loc, intype, type,
STATIC_CAST_EXPR,
complain))
return error_mark_node;
&& TYPE_PTROB_P (type))
{
if (!c_cast_p
- && check_for_casting_away_constness (intype, type, STATIC_CAST_EXPR,
+ && check_for_casting_away_constness (loc, intype, type,
+ STATIC_CAST_EXPR,
complain))
return error_mark_node;
if (processing_template_decl)
/* Return an expression representing static_cast<TYPE>(EXPR). */
tree
-build_static_cast (tree type, tree oexpr, tsubst_flags_t complain)
+build_static_cast (location_t loc, tree type, tree oexpr,
+ tsubst_flags_t complain)
{
tree expr = oexpr;
tree result;
expr = build_min (STATIC_CAST_EXPR, type, oexpr);
/* We don't know if it will or will not have side effects. */
TREE_SIDE_EFFECTS (expr) = 1;
- return convert_from_reference (expr);
+ result = convert_from_reference (expr);
+ protected_set_expr_location (result, loc);
+ return result;
}
else if (processing_template_decl)
expr = build_non_dependent_expr (expr);
&& TREE_TYPE (expr) == TREE_TYPE (TREE_OPERAND (expr, 0)))
expr = TREE_OPERAND (expr, 0);
- result = build_static_cast_1 (type, expr, /*c_cast_p=*/false, &valid_p,
- complain);
+ result = build_static_cast_1 (loc, type, expr, /*c_cast_p=*/false,
+ &valid_p, complain);
if (valid_p)
{
if (result != error_mark_node)
{
- maybe_warn_about_useless_cast (type, expr, complain);
- maybe_warn_about_cast_ignoring_quals (type, complain);
+ maybe_warn_about_useless_cast (loc, type, expr, complain);
+ maybe_warn_about_cast_ignoring_quals (loc, type, complain);
}
if (processing_template_decl)
goto tmpl;
+ protected_set_expr_location (result, loc);
return result;
}
if (complain & tf_error)
{
- error ("invalid %<static_cast%> from type %qT to type %qT",
- TREE_TYPE (expr), type);
+ error_at (loc, "invalid %<static_cast%> from type %qT to type %qT",
+ TREE_TYPE (expr), type);
if ((TYPE_PTR_P (type) || TYPE_REF_P (type))
&& CLASS_TYPE_P (TREE_TYPE (type))
&& !COMPLETE_TYPE_P (TREE_TYPE (type)))
indicate whether or not reinterpret_cast was valid. */
static tree
-build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p,
- bool *valid_p, tsubst_flags_t complain)
+build_reinterpret_cast_1 (location_t loc, tree type, tree expr,
+ bool c_cast_p, bool *valid_p,
+ tsubst_flags_t complain)
{
tree intype;
else if (!lvalue_p (expr))
{
if (complain & tf_error)
- error ("invalid cast of an rvalue expression of type "
- "%qT to type %qT",
- intype, type);
+ error_at (loc, "invalid cast of an rvalue expression of type "
+ "%qT to type %qT",
+ intype, type);
return error_mark_node;
}
&& (complain & tf_warning)
&& (comptypes (TREE_TYPE (intype), TREE_TYPE (type),
COMPARE_BASE | COMPARE_DERIVED)))
- warning (0, "casting %qT to %qT does not dereference pointer",
- intype, type);
+ warning_at (loc, 0, "casting %qT to %qT does not dereference pointer",
+ intype, type);
expr = cp_build_addr_expr (expr, complain);
if (expr != error_mark_node)
expr = build_reinterpret_cast_1
- (build_pointer_type (TREE_TYPE (type)), expr, c_cast_p,
+ (loc, build_pointer_type (TREE_TYPE (type)), expr, c_cast_p,
valid_p, complain);
if (expr != error_mark_node)
/* cp_build_indirect_ref isn't right for rvalue refs. */
if (TYPE_PRECISION (type) < TYPE_PRECISION (intype))
{
if (complain & tf_error)
- permerror (input_location, "cast from %qH to %qI loses precision",
+ permerror (loc, "cast from %qH to %qI loses precision",
intype, type);
else
return error_mark_node;
if ((complain & tf_warning)
&& !cxx_safe_function_type_cast_p (TREE_TYPE (type),
TREE_TYPE (intype)))
- warning (OPT_Wcast_function_type,
- "cast between incompatible function types"
- " from %qH to %qI", intype, type);
+ warning_at (loc, OPT_Wcast_function_type,
+ "cast between incompatible function types"
+ " from %qH to %qI", intype, type);
return build_nop_reinterpret (type, expr);
}
else if (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype))
&& !cxx_safe_function_type_cast_p
(TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE_RAW (type)),
TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE_RAW (intype))))
- warning (OPT_Wcast_function_type,
- "cast between incompatible pointer to member types"
- " from %qH to %qI", intype, type);
+ warning_at (loc, OPT_Wcast_function_type,
+ "cast between incompatible pointer to member types"
+ " from %qH to %qI", intype, type);
return build_nop_reinterpret (type, expr);
}
else if ((TYPE_PTRDATAMEM_P (type) && TYPE_PTRDATAMEM_P (intype))
|| (TYPE_PTROBV_P (type) && TYPE_PTROBV_P (intype)))
{
if (!c_cast_p
- && check_for_casting_away_constness (intype, type,
+ && check_for_casting_away_constness (loc, intype, type,
REINTERPRET_CAST_EXPR,
complain))
return error_mark_node;
&& COMPLETE_TYPE_P (TREE_TYPE (intype))
&& min_align_of_type (TREE_TYPE (type))
> min_align_of_type (TREE_TYPE (intype)))
- warning (OPT_Wcast_align, "cast from %qH to %qI "
- "increases required alignment of target type", intype, type);
+ warning_at (loc, OPT_Wcast_align, "cast from %qH to %qI "
+ "increases required alignment of target type",
+ intype, type);
if (warn_strict_aliasing <= 2)
/* strict_aliasing_warning STRIP_NOPs its expr. */
if (complain & tf_warning)
/* C++11 5.2.10 p8 says that "Converting a function pointer to an
object pointer type or vice versa is conditionally-supported." */
- warning (OPT_Wconditionally_supported,
- "casting between pointer-to-function and pointer-to-object "
- "is conditionally-supported");
+ warning_at (loc, OPT_Wconditionally_supported,
+ "casting between pointer-to-function and "
+ "pointer-to-object is conditionally-supported");
return build_nop_reinterpret (type, expr);
}
else if (gnu_vector_type_p (type))
if (valid_p)
*valid_p = false;
if (complain & tf_error)
- error ("invalid cast from type %qT to type %qT", intype, type);
+ error_at (loc, "invalid cast from type %qT to type %qT",
+ intype, type);
return error_mark_node;
}
}
tree
-build_reinterpret_cast (tree type, tree expr, tsubst_flags_t complain)
+build_reinterpret_cast (location_t loc, tree type, tree expr,
+ tsubst_flags_t complain)
{
tree r;
&& type_dependent_expression_p (expr))
/* There might turn out to be side effects inside expr. */
TREE_SIDE_EFFECTS (t) = 1;
- return convert_from_reference (t);
+ r = convert_from_reference (t);
+ protected_set_expr_location (r, loc);
+ return r;
}
- r = build_reinterpret_cast_1 (type, expr, /*c_cast_p=*/false,
+ r = build_reinterpret_cast_1 (loc, type, expr, /*c_cast_p=*/false,
/*valid_p=*/NULL, complain);
if (r != error_mark_node)
{
- maybe_warn_about_useless_cast (type, expr, complain);
- maybe_warn_about_cast_ignoring_quals (type, complain);
+ maybe_warn_about_useless_cast (loc, type, expr, complain);
+ maybe_warn_about_cast_ignoring_quals (loc, type, complain);
}
+ protected_set_expr_location (r, loc);
return r;
}
whether or not the conversion succeeded. */
static tree
-build_const_cast_1 (tree dst_type, tree expr, tsubst_flags_t complain,
- bool *valid_p)
+build_const_cast_1 (location_t loc, tree dst_type, tree expr,
+ tsubst_flags_t complain, bool *valid_p)
{
tree src_type;
tree reference_type;
if (!INDIRECT_TYPE_P (dst_type) && !TYPE_PTRDATAMEM_P (dst_type))
{
if (complain & tf_error)
- error ("invalid use of %<const_cast%> with type %qT, "
- "which is not a pointer, "
- "reference, nor a pointer-to-data-member type", dst_type);
+ error_at (loc, "invalid use of %<const_cast%> with type %qT, "
+ "which is not a pointer, reference, "
+ "nor a pointer-to-data-member type", dst_type);
return error_mark_node;
}
if (TREE_CODE (TREE_TYPE (dst_type)) == FUNCTION_TYPE)
{
if (complain & tf_error)
- error ("invalid use of %<const_cast%> with type %qT, "
- "which is a pointer or reference to a function type",
- dst_type);
- return error_mark_node;
+ error_at (loc, "invalid use of %<const_cast%> with type %qT, "
+ "which is a pointer or reference to a function type",
+ dst_type);
+ return error_mark_node;
}
/* A prvalue of non-class type is cv-unqualified. */
else
{
if (complain & tf_error)
- error ("invalid %<const_cast%> of an rvalue of type %qT "
- "to type %qT",
- src_type, dst_type);
- return error_mark_node;
+ error_at (loc, "invalid %<const_cast%> of an rvalue of type %qT "
+ "to type %qT",
+ src_type, dst_type);
+ return error_mark_node;
}
dst_type = build_pointer_type (TREE_TYPE (dst_type));
src_type = build_pointer_type (src_type);
*valid_p = true;
/* This cast is actually a C-style cast. Issue a warning if
the user is making a potentially unsafe cast. */
- check_for_casting_away_constness (src_type, dst_type,
+ check_for_casting_away_constness (loc, src_type, dst_type,
CAST_EXPR, complain);
/* ??? comp_ptr_ttypes_const ignores TYPE_ALIGN. */
if ((STRICT_ALIGNMENT || warn_cast_align == 2)
&& (complain & tf_warning)
&& min_align_of_type (TREE_TYPE (dst_type))
> min_align_of_type (TREE_TYPE (src_type)))
- warning (OPT_Wcast_align, "cast from %qH to %qI "
- "increases required alignment of target type",
- src_type, dst_type);
+ warning_at (loc, OPT_Wcast_align, "cast from %qH to %qI "
+ "increases required alignment of target type",
+ src_type, dst_type);
}
if (reference_type)
{
else if (valid_p
&& !at_least_as_qualified_p (TREE_TYPE (dst_type),
TREE_TYPE (src_type)))
- check_for_casting_away_constness (src_type, dst_type, CAST_EXPR,
- complain);
+ check_for_casting_away_constness (loc, src_type, dst_type,
+ CAST_EXPR, complain);
}
if (complain & tf_error)
- error ("invalid %<const_cast%> from type %qT to type %qT",
- src_type, dst_type);
+ error_at (loc, "invalid %<const_cast%> from type %qT to type %qT",
+ src_type, dst_type);
return error_mark_node;
}
tree
-build_const_cast (tree type, tree expr, tsubst_flags_t complain)
+build_const_cast (location_t loc, tree type, tree expr,
+ tsubst_flags_t complain)
{
tree r;
&& type_dependent_expression_p (expr))
/* There might turn out to be side effects inside expr. */
TREE_SIDE_EFFECTS (t) = 1;
- return convert_from_reference (t);
+ r = convert_from_reference (t);
+ protected_set_expr_location (r, loc);
+ return r;
}
- r = build_const_cast_1 (type, expr, complain, /*valid_p=*/NULL);
+ r = build_const_cast_1 (loc, type, expr, complain, /*valid_p=*/NULL);
if (r != error_mark_node)
{
- maybe_warn_about_useless_cast (type, expr, complain);
- maybe_warn_about_cast_ignoring_quals (type, complain);
+ maybe_warn_about_useless_cast (loc, type, expr, complain);
+ maybe_warn_about_cast_ignoring_quals (loc, type, complain);
}
+ protected_set_expr_location (r, loc);
return r;
}
/* Like cp_build_c_cast, but for the c-common bits. */
tree
-build_c_cast (location_t /*loc*/, tree type, tree expr)
+build_c_cast (location_t loc, tree type, tree expr)
{
- return cp_build_c_cast (type, expr, tf_warning_or_error);
+ return cp_build_c_cast (loc, type, expr, tf_warning_or_error);
}
/* Like the "build_c_cast" used for c-common, but using cp_expr to
cp_expr
build_c_cast (location_t loc, tree type, cp_expr expr)
{
- cp_expr result = cp_build_c_cast (type, expr, tf_warning_or_error);
+ cp_expr result = cp_build_c_cast (loc, type, expr, tf_warning_or_error);
result.set_location (loc);
return result;
}
TYPE of expression EXPR. */
tree
-cp_build_c_cast (tree type, tree expr, tsubst_flags_t complain)
+cp_build_c_cast (location_t loc, tree type, tree expr,
+ tsubst_flags_t complain)
{
tree value = expr;
tree result;
if (TYPE_PTR_P (TREE_TYPE (expr)))
{
if (complain & tf_error)
- permerror (input_location, "ISO C++ forbids casting to an array type %qT", type);
+ permerror (loc, "ISO C++ forbids casting to an array type %qT",
+ type);
else
return error_mark_node;
type = build_pointer_type (TREE_TYPE (type));
else
{
if (complain & tf_error)
- error ("ISO C++ forbids casting to an array type %qT", type);
+ error_at (loc, "ISO C++ forbids casting to an array type %qT",
+ type);
return error_mark_node;
}
}
if (FUNC_OR_METHOD_TYPE_P (type))
{
if (complain & tf_error)
- error ("invalid cast to function type %qT", type);
+ error_at (loc, "invalid cast to function type %qT", type);
return error_mark_node;
}
&& TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (value))
/* Don't warn about converting any constant. */
&& !TREE_CONSTANT (value))
- warning_at (input_location, OPT_Wint_to_pointer_cast,
+ warning_at (loc, OPT_Wint_to_pointer_cast,
"cast to pointer from integer of different size");
/* A C-style cast can be a const_cast. */
- result = build_const_cast_1 (type, value, complain & tf_warning,
+ result = build_const_cast_1 (loc, type, value, complain & tf_warning,
&valid_p);
if (valid_p)
{
if (result != error_mark_node)
{
- maybe_warn_about_useless_cast (type, value, complain);
- maybe_warn_about_cast_ignoring_quals (type, complain);
+ maybe_warn_about_useless_cast (loc, type, value, complain);
+ maybe_warn_about_cast_ignoring_quals (loc, type, complain);
}
return result;
}
/* Or a static cast. */
- result = build_static_cast_1 (type, value, /*c_cast_p=*/true,
+ result = build_static_cast_1 (loc, type, value, /*c_cast_p=*/true,
&valid_p, complain);
/* Or a reinterpret_cast. */
if (!valid_p)
- result = build_reinterpret_cast_1 (type, value, /*c_cast_p=*/true,
+ result = build_reinterpret_cast_1 (loc, type, value, /*c_cast_p=*/true,
&valid_p, complain);
/* The static_cast or reinterpret_cast may be followed by a
const_cast. */
{
tree result_type;
- maybe_warn_about_useless_cast (type, value, complain);
- maybe_warn_about_cast_ignoring_quals (type, complain);
+ maybe_warn_about_useless_cast (loc, type, value, complain);
+ maybe_warn_about_cast_ignoring_quals (loc, type, complain);
/* Non-class rvalues always have cv-unqualified type. */
if (!CLASS_TYPE_P (type))
to succeed. */
if (!same_type_p (non_reference (type), non_reference (result_type)))
{
- result = build_const_cast_1 (type, result, false, &valid_p);
+ result = build_const_cast_1 (loc, type, result, false, &valid_p);
gcc_assert (valid_p);
}
return result;
if (same_type_p (to_type, pfn_type))
return pfn;
else if (integer_zerop (n) && TREE_CODE (pfn) != CONSTRUCTOR)
- return build_reinterpret_cast (to_type, pfn,
+ return build_reinterpret_cast (input_location, to_type, pfn,
complain);
}
/* Handle null pointer to member function conversions. */
if (null_ptr_cst_p (pfn))
{
- pfn = cp_build_c_cast (type, pfn, complain);
+ pfn = cp_build_c_cast (input_location, type, pfn, complain);
return build_ptrmemfunc1 (to_type,
integer_zero_node,
pfn);
{
warning_sentinel w (warn_useless_cast);
warning_sentinel w2 (warn_ignored_qualifiers);
- rhs = cp_build_c_cast (type, elt, complain);
+ rhs = cp_build_c_cast (rhs_loc, type, elt, complain);
}
else
rhs = error_mark_node;
/* Return a tree node for the expression TYPENAME '(' PARMS ')'. */
-tree
-build_functional_cast (location_t loc, tree exp, tree parms,
- tsubst_flags_t complain)
+static tree
+build_functional_cast_1 (location_t loc, tree exp, tree parms,
+ tsubst_flags_t complain)
{
/* This is either a call to a constructor,
or a C cast in C++'s `functional' notation. */
/* This must build a C cast. */
parms = build_x_compound_expr_from_list (parms, ELK_FUNC_CAST, complain);
- return cp_build_c_cast (type, parms, complain);
+ return cp_build_c_cast (loc, type, parms, complain);
}
/* Prepare to evaluate as a call to a constructor. If this expression
conversion is equivalent (in definedness, and if defined in
meaning) to the corresponding cast expression. */
if (parms && TREE_CHAIN (parms) == NULL_TREE)
- return cp_build_c_cast (type, TREE_VALUE (parms), complain);
+ return cp_build_c_cast (loc, type, TREE_VALUE (parms), complain);
/* [expr.type.conv]
return build_cplus_new (type, exp, complain);
}
+
+tree
+build_functional_cast (location_t loc, tree exp, tree parms,
+ tsubst_flags_t complain)
+{
+ tree result = build_functional_cast_1 (loc, exp, parms, complain);
+ protected_set_expr_location (result, loc);
+ return result;
+}
\f
/* Add new exception specifier SPEC, to the LIST we currently have.
+2019-12-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * c-c++-common/Wcast-align.c: Check location(s) too.
+ * c-c++-common/Wcast-function-type.c: Likewise.
+ * c-c++-common/Wint-to-pointer-cast-1.c: Likewise.
+ * c-c++-common/Wint-to-pointer-cast-2.c: Likewise.
+ * c-c++-common/Wint-to-pointer-cast-3.c: Likewise.
+ * g++.dg/Wcast-function-type.C: Likewise.
+ * g++.dg/addr_builtin-1.C: Likewise.
+ * g++.dg/conversion/const2.C: Likewise.
+ * g++.dg/conversion/dynamic1.C: Likewise.
+ * g++.dg/conversion/ptrmem2.C: Likewise.
+ * g++.dg/conversion/ptrmem3.C: Likewise.
+ * g++.dg/conversion/qual3.C: Likewise.
+ * g++.dg/conversion/reinterpret3.C: Likewise.
+ * g++.dg/cpp0x/constexpr-cast.C: Likewise.
+ * g++.dg/cpp0x/lambda/lambda-conv11.C: Likewise.
+ * g++.dg/cpp0x/nullptr04.C: Likewise.
+ * g++.dg/cpp0x/reinterpret_cast2.C: Likewise.
+ * g++.dg/cpp0x/rv-cast2.C: Likewise.
+ * g++.dg/cpp1y/lambda-conv1.C: Likewise.
+ * g++.dg/cpp1z/noexcept-type7.C: Likewise.
+ * g++.dg/cpp2a/array-conv9.C: Likewise.
+ * g++.dg/expr/cast11.C: Likewise.
+ * g++.dg/expr/static_cast8.C: Likewise.
+ * g++.dg/ext/vector6.C: Likewise.
+ * g++.dg/other/conversion1.C: Likewise.
+ * g++.dg/parse/pr26997.C: Likewise.
+ * g++.dg/rtti/no-rtti.C: Likewise.
+ * g++.dg/tc1/dr137.C: Likewise.
+ * g++.dg/template/cast4.C: Likewise.
+ * g++.dg/warn/Wcast-qual1.C: Likewise.
+ * g++.dg/warn/Wcast-qual2.C: Likewise.
+ * g++.dg/warn/Wconditionally-supported-1.C: Likewise.
+ * g++.dg/warn/Wuseless-cast.C: Likewise.
+ * g++.dg/warn/pr35711.C: Likewise.
+ * g++.old-deja/g++.bugs/900227_01.C: Likewise.
+ * g++.old-deja/g++.bugs/900404_07.C: Likewise.
+ * g++.old-deja/g++.jason/overload1.C: Likewise.
+ * g++.old-deja/g++.jason/rfg26.C: Likewise.
+ * g++.old-deja/g++.jason/rvalue3.C: Likewise.
+ * g++.old-deja/g++.jason/warning2.C: Likewise.
+ * g++.old-deja/g++.mike/dyncast4.C: Likewise.
+ * g++.old-deja/g++.mike/dyncast6.C: Likewise.
+ * g++.old-deja/g++.mike/p11482.C: Likewise.
+ * g++.old-deja/g++.mike/p2573.C: Likewise.
+ * g++.old-deja/g++.mike/p2855.C: Likewise.
+ * g++.old-deja/g++.mike/p7476.C: Likewise.
+ * g++.old-deja/g++.mike/p8039.C: Likewise.
+ * g++.old-deja/g++.other/cast2.C: Likewise.
+ * g++.old-deja/g++.other/cast3.C: Likewise.
+ * g++.old-deja/g++.other/dcast1.C: Likewise.
+ * g++.old-deja/g++.other/dcast2.C: Likewise.
+
2019-12-09 Lewis Hyatt <lhyatt@gmail.com>
PR preprocessor/49973
void
foo (void)
{
- y = (c *) x; /* { dg-warning "alignment" } */
- z = (d *) x; /* { dg-warning "alignment" } */
+ y = (c *) x; /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" } */
+ z = (d *) x; /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" } */
(long long *) p; /* { dg-bogus "alignment" } */
(double *) q; /* { dg-bogus "alignment" } */
}
foo (void)
{
a = (f1 *) f; /* { dg-bogus "incompatible function types" } */
- b = (f2 *) f; /* { dg-warning "incompatible function types" } */
+ b = (f2 *) f; /* { dg-warning "7:cast between incompatible function types" } */
c = (f3 *) f; /* { dg-bogus "incompatible function types" } */
- d = (f4 *) f; /* { dg-warning "incompatible function types" } */
+ d = (f4 *) f; /* { dg-warning "7:cast between incompatible function types" } */
e = (f5 *) f; /* { dg-bogus "incompatible function types" } */
}
void *
f (void)
{
- return (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */
+ return (void *) c; /* { dg-warning "10:cast to pointer from integer of different size" } */
}
void *
f (void)
{
- return (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */
+ return (void *) c; /* { dg-warning "10:cast to pointer from integer of different size" } */
}
g (void)
{
return (char) p;
-/* { dg-warning "cast from pointer to integer of different size" "" { target c } .-1 } */
-/* { dg-error "cast from 'void\\*' to 'char' loses precision" "" { target c++ } .-2 } */
+/* { dg-warning "10:cast from pointer to integer of different size" "" { target c } .-1 } */
+/* { dg-error "10:cast from 'void\\*' to 'char' loses precision" "" { target c++ } .-2 } */
}
void
foo (void)
{
- MF p1 = (MF)&S::foo; /* { dg-warning "pointer to member" } */
+ MF p1 = (MF)&S::foo; /* { dg-warning "11:cast between incompatible pointer to member" } */
MF p2 = (MF)&S::bar; /* { dg-bogus "pointer to member" } */
}
// Expect a diagnostic for an invalid static_cast of a function to
// either uintptr_t or enum, rather than one for the argument being
// a built-in function, since the former is more relevant than the latter.
- a = static_cast<uintptr_t>(__builtin_trap); // { dg-error "invalid" }
- a = static_cast<UINTPTR_E>(__builtin_trap); // { dg-error "invalid" }
+ a = static_cast<uintptr_t>(__builtin_trap); // { dg-error "7:invalid .static_cast." }
+ a = static_cast<UINTPTR_E>(__builtin_trap); // { dg-error "7:invalid .static_cast." }
// Reinterpret cast can cast a function to uintptr_t or enum,
// so verify that a diagnostic is issued for the use of a builtin.
bm bp;
void f() {
- const_cast<dm>(bp); // { dg-error "" }
+ const_cast<dm>(bp); // { dg-error "3:invalid .const_cast." }
}
void baz()
{
- dynamic_cast<A&>( bar().foo ); // { dg-error "cannot 'dynamic_cast'" }
+ dynamic_cast<A&>( bar().foo ); // { dg-error "3:cannot 'dynamic_cast'" }
}
const int D::*p10 = static_cast<const int D::*>(&B::x);
// Invalid conversions which decrease cv-qualification.
-int B::*p11 = static_cast<int B::*>(p10); // { dg-error "casts away qualifiers" }
-int D::*p12 = static_cast<int D::*>(p9); // { dg-error "casts away qualifiers" }
+int B::*p11 = static_cast<int B::*>(p10); // { dg-error "15:.static_cast. from type .const int D::\\*. to type .int B::\\*. casts away qualifiers" }
+int D::*p12 = static_cast<int D::*>(p9); // { dg-error "15:.static_cast. from type .const int B::\\*. to type .int D::\\*. casts away qualifiers" }
// Attempts to change member type.
-float B::*p13 = static_cast<float B::*>(&D::x); // { dg-error "invalid .static_cast." }
-float D::*p14 = static_cast<float D::*>(&B::x); // { dg-error "invalid .static_cast." }
+float B::*p13 = static_cast<float B::*>(&D::x); // { dg-error "17:invalid .static_cast." }
+float D::*p14 = static_cast<float D::*>(&B::x); // { dg-error "17:invalid .static_cast." }
int (D::*p8)() = static_cast<int (D::*)()>(&A::f); // { dg-error "" }
// Attempts to change member type.
-float (B::*p13)() = static_cast<float (B::*)()>(&D::f); // { dg-error "" }
-float (D::*p14)() = static_cast<float (D::*)()>(&B::f); // { dg-error "" }
+float (B::*p13)() = static_cast<float (B::*)()>(&D::f); // { dg-error "21:invalid .static_cast." }
+float (D::*p14)() = static_cast<float (D::*)()>(&B::f); // { dg-error "21:invalid .static_cast." }
const_cast<P>(q2);
const_cast<Q>(p);
const_cast<Q2>(p);
- const_cast<S>(p); // { dg-error "invalid .const_cast." }
- const_cast<P>(s); // { dg-error "invalid .const_cast." }
- const_cast<S>(q); // { dg-error "invalid .const_cast." }
- const_cast<S>(q2); // { dg-error "invalid .const_cast." }
- const_cast<Q>(s); // { dg-error "invalid .const_cast." }
- const_cast<Q2>(s); // { dg-error "invalid .const_cast." }
+ const_cast<S>(p); // { dg-error "3:invalid .const_cast." }
+ const_cast<P>(s); // { dg-error "3:invalid .const_cast." }
+ const_cast<S>(q); // { dg-error "3:invalid .const_cast." }
+ const_cast<S>(q2); // { dg-error "3:invalid .const_cast." }
+ const_cast<Q>(s); // { dg-error "3:invalid .const_cast." }
+ const_cast<Q2>(s); // { dg-error "3:invalid .const_cast." }
const_cast<T>(s);
const_cast<S>(t);
- const_cast<T>(q); // { dg-error "invalid .const_cast." }
- const_cast<Q>(t); // { dg-error "invalid .const_cast." }
+ const_cast<T>(q); // { dg-error "3:invalid .const_cast." }
+ const_cast<Q>(t); // { dg-error "3:invalid .const_cast." }
// Test reinterpret_cast.
- reinterpret_cast<P>(q); // { dg-error "casts away qualifiers" }
- reinterpret_cast<P>(q2); // { dg-error "casts away qualifiers" }
+ reinterpret_cast<P>(q); // { dg-error "3:.reinterpret_cast. \[^\n\r]* casts away qualifiers" }
+ reinterpret_cast<P>(q2); // { dg-error "3:.reinterpret_cast. \[^\n\r]* casts away qualifiers" }
reinterpret_cast<Q>(p);
reinterpret_cast<Q2>(p);
reinterpret_cast<S>(p);
- reinterpret_cast<P>(s); // { dg-error "casts away qualifiers" }
+ reinterpret_cast<P>(s); // { dg-error "3:.reinterpret_cast. \[^\n\r]* casts away qualifiers" }
reinterpret_cast<S>(q);
reinterpret_cast<S>(q2);
reinterpret_cast<Q>(s);
reinterpret_cast<Q2>(s);
- reinterpret_cast<T>(s); // { dg-error "casts away qualifiers" }
+ reinterpret_cast<T>(s); // { dg-error "3:.reinterpret_cast. \[^\n\r]* casts away qualifiers" }
reinterpret_cast<S>(t);
- reinterpret_cast<T>(q); // { dg-error "casts away qualifiers" }
+ reinterpret_cast<T>(q); // { dg-error "3:.reinterpret_cast. \[^\n\r]* casts away qualifiers" }
reinterpret_cast<Q>(t);
}
S s;
void f() {
- reinterpret_cast<const S>(s); // { dg-error "" }
+ reinterpret_cast<const S>(s); // { dg-error "3:invalid cast" }
}
constexpr bool f ()
{
#if __cplusplus > 201103L
- T *p = reinterpret_cast<T*>(sizeof (T));
+ T *p = reinterpret_cast<T*>(sizeof (T)); // { dg-error "not a constant expression" "" { target c++14 } }
return p;
#else
- return *reinterpret_cast<T*>(sizeof (T));
+ return *reinterpret_cast<T*>(sizeof (T)); // { dg-error "not a constant expression" "" { target c++11_only } }
#endif
}
-constexpr bool b = f<int>(); // { dg-error "not a constant expression|in .constexpr. expansion of " }
+constexpr bool b = f<int>(); // { dg-message "in .constexpr. expansion of " }
void foo()
{
int i;
- static_cast<void(*)()>([i]{}); // { dg-error "invalid 'static_cast'" }
- static_cast<void(*)()>([=]{}); // { dg-error "invalid 'static_cast'" }
- static_cast<void(*)()>([&]{}); // { dg-error "invalid 'static_cast'" }
+ static_cast<void(*)()>([i]{}); // { dg-error "3:invalid 'static_cast'" }
+ static_cast<void(*)()>([=]{}); // { dg-error "3:invalid 'static_cast'" }
+ static_cast<void(*)()>([&]{}); // { dg-error "3:invalid 'static_cast'" }
}
__extension__ typedef __INTPTR_TYPE__ intptr_t;
-const int n4 = static_cast<const int>(nullptr); // { dg-error "invalid 'static_cast' " }
-const short int n5 = reinterpret_cast<short int>(nullptr); // { dg-error "loses precision" }
+const int n4 = static_cast<const int>(nullptr); // { dg-error "16:invalid 'static_cast' " }
+const short int n5 = reinterpret_cast<short int>(nullptr); // { dg-error "22:cast from .std::nullptr_t. to .short int. loses precision" }
const intptr_t n6 = reinterpret_cast<intptr_t>(nullptr);
const intptr_t n7 = (intptr_t)nullptr;
decltype(nullptr) mynull = 0;
-const int n8 = static_cast<const int>(mynull); // { dg-error "invalid 'static_cast' " }
-const short int n9 = reinterpret_cast<short int>(mynull); // { dg-error "loses precision" }
+const int n8 = static_cast<const int>(mynull); // { dg-error "16:invalid 'static_cast' " }
+const short int n9 = reinterpret_cast<short int>(mynull); // { dg-error "22:cast from .std::nullptr_t. to .short int. loses precision" }
const intptr_t n10 = reinterpret_cast<intptr_t>(mynull);
const intptr_t n11 = (intptr_t)mynull;
void
foo ()
{
- auto a = reinterpret_cast<S&&>(foo ()); // { dg-error "invalid cast of an rvalue expression of type 'void' to type" }
+ auto a = reinterpret_cast<S&&>(foo ()); // { dg-error "12:invalid cast of an rvalue expression of type 'void' to type" }
}
int main()
{
const_cast<int&>(lval<int>());
- const_cast<int&>(xval<int>()); // { dg-error "" }
- const_cast<int&>(prval<int>()); // { dg-error "" }
+ const_cast<int&>(xval<int>()); // { dg-error "3:invalid .const_cast. of an rvalue" }
+ const_cast<int&>(prval<int>()); // { dg-error "3:invalid .const_cast. of an rvalue" }
const_cast<int&&>(lval<int>());
const_cast<int&&>(xval<int>());
- const_cast<int&&>(prval<int>()); // { dg-error "" }
+ const_cast<int&&>(prval<int>()); // { dg-error "3:invalid .const_cast. of an rvalue" }
const_cast<A&&>(lval<A>());
const_cast<A&&>(xval<A>());
const_cast<A&&>(prval<A>());
void foo()
{
int i;
- static_cast<void(*)(int)>([i](auto){}); // { dg-error "invalid 'static_cast'" }
- static_cast<void(*)(int)>([=](auto){}); // { dg-error "invalid 'static_cast'" }
- static_cast<void(*)(int)>([&](auto){}); // { dg-error "invalid 'static_cast'" }
- static_cast<float(*)(float)>([i](auto x){ return x; }); // { dg-error "invalid 'static_cast'" }
- static_cast<float(*)(float)>([=](auto x){ return x; }); // { dg-error "invalid 'static_cast'" }
- static_cast<float(*)(float)>([&](auto x){ return x; }); // { dg-error "invalid 'static_cast'" }
+ static_cast<void(*)(int)>([i](auto){}); // { dg-error "3:invalid 'static_cast'" }
+ static_cast<void(*)(int)>([=](auto){}); // { dg-error "3:invalid 'static_cast'" }
+ static_cast<void(*)(int)>([&](auto){}); // { dg-error "3:invalid 'static_cast'" }
+ static_cast<float(*)(float)>([i](auto x){ return x; }); // { dg-error "3:invalid 'static_cast'" }
+ static_cast<float(*)(float)>([=](auto x){ return x; }); // { dg-error "3:invalid 'static_cast'" }
+ static_cast<float(*)(float)>([&](auto x){ return x; }); // { dg-error "3:invalid 'static_cast'" }
}
NP np;
static_cast<P>(np);
- static_cast<NP>(p); // { dg-error "" }
+ static_cast<NP>(p); // { dg-error "3:invalid .static_cast." }
}
test ()
{
int (&r)[1] = const_cast<int(&)[1]>(arr);
- int (&r2)[] = const_cast<int(&)[]>(arr); // { dg-error "invalid" }
+ int (&r2)[] = const_cast<int(&)[]>(arr); // { dg-error "17:invalid .const_cast." }
int (&r3)[1] = (int(&)[1]) arr;
int (&r4)[] = (int(&)[]) arr;
int (&r5)[1] = static_cast<int(&)[1]>(arr);
int(*p6)[] = (int(*)[1]) (int(*)[]) &arr;
int(*p7)[] = static_cast<int(*)[]>(&arr);
int(*p8)[] = static_cast<int(*)[1]>(&arr);
- int(*p9)[] = static_cast<int(*)[1]>(&arr2); // { dg-error "invalid" }
+ int(*p9)[] = static_cast<int(*)[1]>(&arr2); // { dg-error "16:invalid .static_cast." }
}
void f1()
{
int i = 0;
- f((long const)i); // { dg-warning "qualifiers ignored" }
- f((int* const)&i); // { dg-warning "qualifiers ignored" }
- f((int const* const)&i); // { dg-warning "qualifiers ignored" }
- f((long* const)&i); // { dg-warning "qualifiers ignored" }
+ f((long const)i); // { dg-warning "5:type qualifiers ignored" }
+ f((int* const)&i); // { dg-warning "5:type qualifiers ignored" }
+ f((int const* const)&i); // { dg-warning "5:type qualifiers ignored" }
+ f((long* const)&i); // { dg-warning "5:type qualifiers ignored" }
- f(static_cast<long const>(i)); // { dg-warning "qualifiers ignored" }
- f(reinterpret_cast<long const>(&i)); // { dg-warning "qualifiers ignored" }
+ f(static_cast<long const>(i)); // { dg-warning "5:type qualifiers ignored" }
+ f(reinterpret_cast<long const>(&i)); // { dg-warning "5:type qualifiers ignored" }
- f(static_cast<int* const>(&i)); // { dg-warning "qualifiers ignored" }
- f(const_cast<int* const>(&i)); // { dg-warning "qualifiers ignored" }
- f(reinterpret_cast<long* const>(&i)); // { dg-warning "qualifiers ignored" }
+ f(static_cast<int* const>(&i)); // { dg-warning "5:type qualifiers ignored" }
+ f(const_cast<int* const>(&i)); // { dg-warning "5:type qualifiers ignored" }
+ f(reinterpret_cast<long* const>(&i)); // { dg-warning "5:type qualifiers ignored" }
using ptrmem = int B::*;
- f(static_cast<ptrmem const>(&B::i)); // { dg-warning "qualifiers ignored" }
- f(const_cast<ptrmem const>(&B::i)); // { dg-warning "qualifiers ignored" }
- f(reinterpret_cast<ptrmem const>(&B::i)); // { dg-warning "qualifiers ignored" }
+ f(static_cast<ptrmem const>(&B::i)); // { dg-warning "5:type qualifiers ignored" }
+ f(const_cast<ptrmem const>(&B::i)); // { dg-warning "5:type qualifiers ignored" }
+ f(reinterpret_cast<ptrmem const>(&B::i)); // { dg-warning "5:type qualifiers ignored" }
// No warnings, not a cv-qualified type:
using ptrmem2 = const char B::*;
void pointers(C* c, A2* a2, B1* b1)
{
- (void) static_cast<A1*>(c); // { dg-error "invalid 'static_cast'" }
- (void) static_cast<C*>(a2); // { dg-error "invalid 'static_cast'" }
- (void) static_cast<B2*>(b1); // { dg-error "invalid 'static_cast'" }
+ (void) static_cast<A1*>(c); // { dg-error "10:invalid 'static_cast'" }
+ (void) static_cast<C*>(a2); // { dg-error "10:invalid 'static_cast'" }
+ (void) static_cast<B2*>(b1); // { dg-error "10:invalid 'static_cast'" }
}
struct D1; // { dg-message "note: class type 'D1' is incomplete" }
void references(C& c, D2& d2, E1& e1)
{
- (void) static_cast<D1&>(c); // { dg-error "invalid 'static_cast'" }
- (void) static_cast<C&>(d2); // { dg-error "invalid 'static_cast'" }
- (void) static_cast<E2&>(e1); // { dg-error "invalid 'static_cast'" }
+ (void) static_cast<D1&>(c); // { dg-error "10:invalid 'static_cast'" }
+ (void) static_cast<C&>(d2); // { dg-error "10:invalid 'static_cast'" }
+ (void) static_cast<E2&>(e1); // { dg-error "10:invalid 'static_cast'" }
}
void f(void)
{
__v_4F b;
- (reinterpret_cast<__v4F>(b).a)[1] = 1; // { dg-error "" }
+ (reinterpret_cast<__v4F>(b).a)[1] = 1; // { dg-error "8:invalid cast" }
}
{
long long m;
- (void (QObject::*)()) m; // { dg-error "invalid cast" }
+ (void (QObject::*)()) m; // { dg-error "3:invalid cast" }
}
C bar (void)
{
- (C ())(3); // { dg-error "invalid cast" }
+ (C ())(3); // { dg-error "3:invalid cast" }
return (C ());
}
{
C ()[2];
(C ())[2];
- (S ())(3); // { dg-error "invalid cast" }
- (C())*var; // { dg-error "invalid cast" }
- (C())+var; // { dg-error "invalid cast" }
+ (S ())(3); // { dg-error "3:invalid cast" }
+ (C())*var; // { dg-error "3:invalid cast" }
+ (C())+var; // { dg-error "3:invalid cast" }
S()(3);
(S()(3));
}
int main()
{
- B* b = dynamic_cast<B*>(f()); // { dg-error "" }
+ B* b = dynamic_cast<B*>(f()); // { dg-error "11:.dynamic_cast. not permitted" }
}
void foo(void)
{
(void)static_cast<const volatile A *>(v);
- (void)static_cast<A *>(v); // { dg-error "" "static_cast cannot remove cv qualifiers" }
+ (void)static_cast<A *>(v); // { dg-error "9:.static_cast. from type .const void\\*. to type .A\\*. casts away qualifiers" "static_cast cannot remove cv qualifiers" }
}
template <class T> void f()
{
- static_cast<int&>(42); // { dg-error "static_cast" }
+ static_cast<int&>(42); // { dg-error "3:invalid .static_cast." }
}
int main(int, char**) {
const int foo[2] = {1,1};
- ((int*)foo)[0] = 0; // { dg-warning "cast" }
+ ((int*)foo)[0] = 0; // { dg-warning "4:cast" }
}
// PR c++/50956
// { dg-options "-Wcast-qual" }
-void* p = (void*)"txt"; // { dg-warning "cast" }
+void* p = (void*)"txt"; // { dg-warning "11:cast" }
PV pv;
PO po;
- pf = reinterpret_cast <PF>(pv); // { dg-warning "conditionally-supported" }
- pv = reinterpret_cast <PV>(pf); // { dg-warning "conditionally-supported" }
+ pf = reinterpret_cast <PF>(pv); // { dg-warning "8:casting between pointer-to-function and pointer-to-object is conditionally-supported" }
+ pv = reinterpret_cast <PV>(pf); // { dg-warning "8:casting between pointer-to-function and pointer-to-object is conditionally-supported" }
- pf = reinterpret_cast <PF>(po); // { dg-warning "conditionally-supported" }
- po = reinterpret_cast <PO>(pf); // { dg-warning "conditionally-supported" }
+ pf = reinterpret_cast <PF>(po); // { dg-warning "8:casting between pointer-to-function and pointer-to-object is conditionally-supported" }
+ po = reinterpret_cast <PO>(pf); // { dg-warning "8:casting between pointer-to-function and pointer-to-object is conditionally-supported" }
}
{
int n;
- (int)(n); // { dg-warning "useless cast" }
- static_cast<int>(n); // { dg-warning "useless cast" }
- reinterpret_cast<int>(n); // { dg-warning "useless cast" }
+ (int)(n); // { dg-warning "3:useless cast" }
+ static_cast<int>(n); // { dg-warning "3:useless cast" }
+ reinterpret_cast<int>(n); // { dg-warning "3:useless cast" }
- (int*)(&n); // { dg-warning "useless cast" }
- const_cast<int*>(&n); // { dg-warning "useless cast" }
- static_cast<int*>(&n); // { dg-warning "useless cast" }
- reinterpret_cast<int*>(&n); // { dg-warning "useless cast" }
+ (int*)(&n); // { dg-warning "3:useless cast" }
+ const_cast<int*>(&n); // { dg-warning "3:useless cast" }
+ static_cast<int*>(&n); // { dg-warning "3:useless cast" }
+ reinterpret_cast<int*>(&n); // { dg-warning "3:useless cast" }
int& m = n;
- (int&)(m); // { dg-warning "useless cast" }
- const_cast<int&>(m); // { dg-warning "useless cast" }
- static_cast<int&>(m); // { dg-warning "useless cast" }
- reinterpret_cast<int&>(m); // { dg-warning "useless cast" }
+ (int&)(m); // { dg-warning "3:useless cast" }
+ const_cast<int&>(m); // { dg-warning "3:useless cast" }
+ static_cast<int&>(m); // { dg-warning "3:useless cast" }
+ reinterpret_cast<int&>(m); // { dg-warning "3:useless cast" }
tmpl_f1(m);
- (int&)(n); // { dg-warning "useless cast" }
- const_cast<int&>(n); // { dg-warning "useless cast" }
- static_cast<int&>(n); // { dg-warning "useless cast" }
- reinterpret_cast<int&>(n); // { dg-warning "useless cast" }
+ (int&)(n); // { dg-warning "3:useless cast" }
+ const_cast<int&>(n); // { dg-warning "3:useless cast" }
+ static_cast<int&>(n); // { dg-warning "3:useless cast" }
+ reinterpret_cast<int&>(n); // { dg-warning "3:useless cast" }
tmpl_f2(n);
A a;
- (A)(a); // { dg-warning "useless cast" }
- static_cast<A>(a); // { dg-warning "useless cast" }
+ (A)(a); // { dg-warning "3:useless cast" }
+ static_cast<A>(a); // { dg-warning "3:useless cast" }
- (A*)(&a); // { dg-warning "useless cast" }
- const_cast<A*>(&a); // { dg-warning "useless cast" }
- static_cast<A*>(&a); // { dg-warning "useless cast" }
- reinterpret_cast<A*>(&a); // { dg-warning "useless cast" }
- dynamic_cast<A*>(&a); // { dg-warning "useless cast" }
+ (A*)(&a); // { dg-warning "3:useless cast" }
+ const_cast<A*>(&a); // { dg-warning "3:useless cast" }
+ static_cast<A*>(&a); // { dg-warning "3:useless cast" }
+ reinterpret_cast<A*>(&a); // { dg-warning "3:useless cast" }
+ dynamic_cast<A*>(&a); // { dg-warning "3:useless cast" }
A& b = a;
- (A&)(b); // { dg-warning "useless cast" }
- const_cast<A&>(b); // { dg-warning "useless cast" }
- static_cast<A&>(b); // { dg-warning "useless cast" }
- static_cast<A&>(b); // { dg-warning "useless cast" }
- dynamic_cast<A&>(b); // { dg-warning "useless cast" }
+ (A&)(b); // { dg-warning "3:useless cast" }
+ const_cast<A&>(b); // { dg-warning "3:useless cast" }
+ static_cast<A&>(b); // { dg-warning "3:useless cast" }
+ static_cast<A&>(b); // { dg-warning "3:useless cast" }
+ dynamic_cast<A&>(b); // { dg-warning "3:useless cast" }
tmpl_f3(b);
- (A&)(a); // { dg-warning "useless cast" }
- const_cast<A&>(a); // { dg-warning "useless cast" }
- static_cast<A&>(a); // { dg-warning "useless cast" }
- reinterpret_cast<A&>(a); // { dg-warning "useless cast" }
- dynamic_cast<A&>(a); // { dg-warning "useless cast" }
+ (A&)(a); // { dg-warning "3:useless cast" }
+ const_cast<A&>(a); // { dg-warning "3:useless cast" }
+ static_cast<A&>(a); // { dg-warning "3:useless cast" }
+ reinterpret_cast<A&>(a); // { dg-warning "3:useless cast" }
+ dynamic_cast<A&>(a); // { dg-warning "3:useless cast" }
tmpl_f4(a);
}
int* foo (volatile int *p)
{
- return (int*)p; // { dg-warning "cast from type 'volatile int\\*' to type 'int\\*' casts away qualifiers" }
+ return (int*)p; // { dg-warning "10:cast from type 'volatile int\\*' to type 'int\\*' casts away qualifiers" }
}
int main ();
-short s = (short) &main; // { dg-error "loses precision" "lose" { xfail h8*-*-* xstormy16-*-* } }
-char c = (char) &main; // { dg-error "loses precision" "lose" }
+short s = (short) &main; // { dg-error "11:cast \[^\n\r]* loses precision" "lose" { xfail h8*-*-* xstormy16-*-* } }
+char c = (char) &main; // { dg-error "10:cast \[^\n\r]* loses precision" "lose" }
int main () { return 0; }
void foo ()
{
- int i = *((array_type) *ap); /* { dg-error "" } missed */
+ int i = *((array_type) *ap); /* { dg-error "13:ISO C\\+\\+ forbids casting to an array type" } missed */
}
struct B: public A { };
void bar (A& a) {
- B* bp = (B*)a; // { dg-error "" }
+ B* bp = (B*)a; // { dg-error "11:invalid cast" }
}
void
test_0 ()
{
- (FTYPE) f; /* { dg-error "" } casting to function type */
+ (FTYPE) f; /* { dg-error "5:invalid cast to function type" } casting to function type */
}
int main ()
{
int i;
- int &ir = (int&)(int)i; // { dg-error "" } casting rvalue to reference type
+ int &ir = (int&)(int)i; // { dg-error "14:invalid cast of an rvalue expression" } casting rvalue to reference type
}
int main()
{
B* bp;
- A& ar = (A&)bp; // { dg-warning "" }
+ A& ar = (A&)bp; // { dg-warning "11:casting .B\\*. to .A&. does not dereference pointer" }
}
// { dg-do assemble }
int main() {
int* d;
- dynamic_cast<void*>(d); // { dg-error "" }
+ dynamic_cast<void*>(d); // { dg-error "3:cannot .dynamic_cast." }
}
class B : public A { };
void x (A& a) {
- const B& b1 = dynamic_cast<B&>((const A&)a); // { dg-error "" } opps
+ const B& b1 = dynamic_cast<B&>((const A&)a); // { dg-error "17:cannot .dynamic_cast." } opps
}
enum E { bad, ok } e;
void foo() {
- e = (E)vp; // { dg-error "" }
+ e = (E)vp; // { dg-error "7:invalid cast" }
}
};
char *X::add() {
- char *f1 = (char *) &key; // { dg-error "" }
- char *f2 = (char *) &vkey; // { dg-error "" }
+ char *f1 = (char *) &key; // { dg-error "14:invalid cast" }
+ // { dg-error "24:ISO C\\+\\+ forbids taking the address" "" { target *-*-* } .-1 }
+ char *f2 = (char *) &vkey; // { dg-error "14:invalid cast" }
+ // { dg-error "24:ISO C\\+\\+ forbids taking the address" "" { target *-*-* } .-1 }
return f1;
}
int main()
{
Ctest obj;
- char* temp = (char *)obj; // { dg-error "invalid cast" }
+ char* temp = (char *)obj; // { dg-error "16:invalid cast" }
temp[0] = '\0';
}
void HeapTracked::isObjectAllocation(const HeapTracked *ptr)
{
const_cast<void*>(dynamic_cast<const void*>(ptr));
- dynamic_cast<void*>(ptr); // { dg-error "" }
+ dynamic_cast<void*>(ptr); // { dg-error "3:cannot .dynamic_cast." }
}
int main()
{
int (C::*mfp)() = &C::func;
- bar((int*)mfp); // { dg-error "" } no clear semantics
+ bar((int*)mfp); // { dg-error "7:invalid cast" } no clear semantics
}
typedef void (A::*F)();
F p;
- const_cast<const A>(a); // { dg-error "" } const_cast requires pointer/ref types
- const_cast<F>(p); // { dg-error "" } const_cast requires pointer/ref types
- const_cast<int (*)()>(&main); // { dg-error "" } function type in const_cast
- const_cast<int (&)()>(main); // { dg-error "" } function type in const_cast
+ const_cast<const A>(a); // { dg-error "3:invalid use of .const_cast." } const_cast requires pointer/ref types
+ const_cast<F>(p); // { dg-error "3:invalid use of .const_cast." } const_cast requires pointer/ref types
+ const_cast<int (*)()>(&main); // { dg-error "3:invalid use of .const_cast." } function type in const_cast
+ // { dg-error "26:ISO C\\+\\+ forbids taking address" "" { target *-*-* } .-1 }
+ const_cast<int (&)()>(main); // { dg-error "3:invalid use of .const_cast." } function type in const_cast
}
static_cast <int *const *> (p);
static_cast <int const *const *> (p);
- static_cast <X *> (cp); // { dg-error "" } lose const
+ static_cast <X *> (cp); // { dg-error "3:.static_cast. from type .const void\\*. to type .X\\*. casts away qualifiers" } lose const
static_cast <X const *> (cp);
- static_cast <int *> (cp); // { dg-error "" } lose const
+ static_cast <int *> (cp); // { dg-error "3:.static_cast. from type .const void\\*. to type .int\\*. casts away qualifiers" } lose const
static_cast <int const *> (cp);
- static_cast <int **> (cp); // { dg-error "" } lose const
- static_cast <int const **> (cp); // { dg-error "" } lose const
+ static_cast <int **> (cp); // { dg-error "3:.static_cast. from type .const void\\*. to type .int\\*\\*. casts away qualifiers" } lose const
+ static_cast <int const **> (cp); // { dg-error "3:.static_cast. from type .const void\\*. to type .const int\\*\\*. casts away qualifiers" } lose const
static_cast <int *const *> (cp);
static_cast <int const *const *> (cp);
static_cast <Z *> (yp);
static_cast <Z const *> (yp);
- static_cast <Z *> (ycp); // { dg-error "" } lose const
+ static_cast <Z *> (ycp); // { dg-error "3:.static_cast. from type .const Y\\*. to type .Z\\*. casts away qualifiers" } lose const
static_cast <Z const *> (ycp);
static_cast <Y *> (zp);
static_cast <Y const *> (zp);
- static_cast <Y *> (zcp); // { dg-error "" } lose const
+ static_cast <Y *> (zcp); // { dg-error "3:invalid .static_cast. from type .const Z\\*. to type .Y\\*." } lose const
static_cast <Y const *> (zcp);
}
void f ()
{
- dynamic_cast<void*>(cp); // { dg-error "" } cannot dynamic_cast
- dynamic_cast<C&>(cr); // { dg-error "" } cannot dynamic_cast
+ dynamic_cast<void*>(cp); // { dg-error "3:cannot .dynamic_cast." } cannot dynamic_cast
+ dynamic_cast<C&>(cr); // { dg-error "3:cannot .dynamic_cast." } cannot dynamic_cast
}
void foo() {
B x;
- dynamic_cast<D*>(&x); // { dg-warning "" } will never succeed
+ dynamic_cast<D*>(&x); // { dg-warning "3:.dynamic_cast" } will never succeed
B* p = &x;
dynamic_cast<D*>(p);
}
+2019-12-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * libcp1plugin.cc (plugin_build_cast_expr): Adjust build_cast
+ declaration.
+
2019-12-05 Paolo Carlini <paolo.carlini@oracle.com>
* libcp1plugin.cc (plugin_build_expression_list_expr): Adjust
gcc_expr operand2)
{
plugin_context *ctx = static_cast<plugin_context *> (self);
- tree (*build_cast)(tree type, tree expr, tsubst_flags_t complain) = NULL;
+ tree (*build_cast)(location_t loc, tree type, tree expr,
+ tsubst_flags_t complain) = NULL;
tree type = convert_in (operand1);
tree expr = convert_in (operand2);
if (!template_dependent_p)
processing_template_decl--;
- tree val = build_cast (type, expr, tf_error);
+ tree val = build_cast (input_location, type, expr, tf_error);
if (template_dependent_p)
processing_template_decl--;