arguments to the conditional expression. */
static tree
-build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
+build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
tsubst_flags_t complain)
{
tree arg2_type;
if (!arg2)
{
if (complain & tf_error)
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (loc, OPT_Wpedantic,
"ISO C++ forbids omitting the middle term of a ?: expression");
/* Make sure that lvalues remain lvalues. See g++.oliva/ext1.C. */
&& TREE_CODE (arg3_type) != VECTOR_TYPE)
{
if (complain & tf_error)
- error ("at least one operand of a vector conditional operator "
- "must be a vector");
+ error_at (loc, "at least one operand of a vector conditional "
+ "operator must be a vector");
return error_mark_node;
}
!= (TREE_CODE (arg3_type) == VECTOR_TYPE))
{
enum stv_conv convert_flag =
- scalar_to_vector (input_location, VEC_COND_EXPR, arg2, arg3,
+ scalar_to_vector (loc, VEC_COND_EXPR, arg2, arg3,
complain & tf_error);
switch (convert_flag)
|| TYPE_SIZE (arg1_type) != TYPE_SIZE (arg2_type))
{
if (complain & tf_error)
- error ("incompatible vector types in conditional expression: "
- "%qT, %qT and %qT", TREE_TYPE (arg1), TREE_TYPE (orig_arg2),
- TREE_TYPE (orig_arg3));
+ error_at (loc,
+ "incompatible vector types in conditional expression: "
+ "%qT, %qT and %qT", TREE_TYPE (arg1),
+ TREE_TYPE (orig_arg2), TREE_TYPE (orig_arg3));
return error_mark_node;
}
if (!COMPARISON_CLASS_P (arg1))
- arg1 = cp_build_binary_op (input_location, NE_EXPR, arg1,
+ arg1 = cp_build_binary_op (loc, NE_EXPR, arg1,
build_zero_cst (arg1_type), complain);
return fold_build3 (VEC_COND_EXPR, arg2_type, arg1, arg2, arg3);
}
if (complain & tf_error)
{
if (VOID_TYPE_P (arg2_type))
- error ("second operand to the conditional operator "
- "is of type %<void%>, "
- "but the third operand is neither a throw-expression "
- "nor of type %<void%>");
+ error_at (EXPR_LOC_OR_LOC (arg3, loc),
+ "second operand to the conditional operator "
+ "is of type %<void%>, but the third operand is "
+ "neither a throw-expression nor of type %<void%>");
else
- error ("third operand to the conditional operator "
- "is of type %<void%>, "
- "but the second operand is neither a throw-expression "
- "nor of type %<void%>");
+ error_at (EXPR_LOC_OR_LOC (arg2, loc),
+ "third operand to the conditional operator "
+ "is of type %<void%>, but the second operand is "
+ "neither a throw-expression nor of type %<void%>");
}
return error_mark_node;
}
|| (conv3 && conv3->kind == ck_ambig))
{
if (complain & tf_error)
- error ("operands to ?: have different types %qT and %qT",
- arg2_type, arg3_type);
+ error_at (loc, "operands to ?: have different types %qT and %qT",
+ arg2_type, arg3_type);
result = error_mark_node;
}
else if (conv2 && (!conv2->bad_p || !conv3))
{
if (complain & tf_error)
{
- op_error (input_location, COND_EXPR, NOP_EXPR,
- arg1, arg2, arg3, FALSE);
- print_z_candidates (location_of (arg1), candidates);
+ op_error (loc, COND_EXPR, NOP_EXPR, arg1, arg2, arg3, FALSE);
+ print_z_candidates (loc, candidates);
}
return error_mark_node;
}
{
if (complain & tf_error)
{
- op_error (input_location, COND_EXPR, NOP_EXPR,
- arg1, arg2, arg3, FALSE);
- print_z_candidates (location_of (arg1), candidates);
+ op_error (loc, COND_EXPR, NOP_EXPR, arg1, arg2, arg3, FALSE);
+ print_z_candidates (loc, candidates);
}
return error_mark_node;
}
do_warn_double_promotion (result_type, arg2_type, arg3_type,
"implicit conversion from %qT to %qT to "
"match other result of conditional",
- input_location);
+ loc);
if (TREE_CODE (arg2_type) == ENUMERAL_TYPE
&& TREE_CODE (arg3_type) == ENUMERAL_TYPE)
/* Two enumerators from the same enumeration can have different
types when the enumeration is still being defined. */;
else if (complain & tf_warning)
- warning (OPT_Wenum_compare,
- "enumeral mismatch in conditional expression: %qT vs %qT",
- arg2_type, arg3_type);
+ warning_at (loc, OPT_Wenum_compare, "enumeral mismatch in "
+ "conditional expression: %qT vs %qT",
+ arg2_type, arg3_type);
}
else if (extra_warnings
&& ((TREE_CODE (arg2_type) == ENUMERAL_TYPE
&& !same_type_p (arg3_type, type_promotes_to (arg2_type)))
|| (TREE_CODE (arg3_type) == ENUMERAL_TYPE
- && !same_type_p (arg2_type, type_promotes_to (arg3_type)))))
+ && !same_type_p (arg2_type,
+ type_promotes_to (arg3_type)))))
{
if (complain & tf_warning)
- warning (0,
- "enumeral and non-enumeral type in conditional expression");
+ warning_at (loc, 0, "enumeral and non-enumeral type in "
+ "conditional expression");
}
arg2 = perform_implicit_conversion (result_type, arg2, complain);
if (!result_type)
{
if (complain & tf_error)
- error ("operands to ?: have different types %qT and %qT",
- arg2_type, arg3_type);
+ error_at (loc, "operands to ?: have different types %qT and %qT",
+ arg2_type, arg3_type);
return error_mark_node;
}
/* Wrapper for above. */
tree
-build_conditional_expr (tree arg1, tree arg2, tree arg3,
+build_conditional_expr (location_t loc, tree arg1, tree arg2, tree arg3,
tsubst_flags_t complain)
{
tree ret;
bool subtime = timevar_cond_start (TV_OVERLOAD);
- ret = build_conditional_expr_1 (arg1, arg2, arg3, complain);
+ ret = build_conditional_expr_1 (loc, arg1, arg2, arg3, complain);
timevar_cond_stop (TV_OVERLOAD, subtime);
return ret;
}
gcc_assert (!TREE_SIDE_EFFECTS (op0)
&& !TREE_SIDE_EFFECTS (op1));
return
- build_conditional_expr (build_x_binary_op (input_location,
+ build_conditional_expr (EXPR_LOC_OR_HERE (t),
+ build_x_binary_op (EXPR_LOC_OR_HERE (t),
(TREE_CODE (t) == MIN_EXPR
? LE_EXPR : GE_EXPR),
op0, TREE_CODE (op0),
}
return
- build_conditional_expr (TREE_OPERAND (t, 0),
+ build_conditional_expr (EXPR_LOC_OR_HERE (t), TREE_OPERAND (t, 0),
cp_build_unary_op (code, TREE_OPERAND (t, 1), 0,
complain),
cp_build_unary_op (code, TREE_OPERAND (t, 2), 0,
case COND_EXPR:
ret = build_conditional_expr
- (TREE_OPERAND (array, 0),
+ (loc, TREE_OPERAND (array, 0),
cp_build_array_ref (loc, TREE_OPERAND (array, 1), idx,
complain),
cp_build_array_ref (loc, TREE_OPERAND (array, 2), idx,
cp_build_addr_expr (e2, complain));
e2 = fold_convert (TREE_TYPE (e3), e2);
- e1 = build_conditional_expr (e1, e2, e3, complain);
+ e1 = build_conditional_expr (input_location, e1, e2, e3, complain);
if (e1 == error_mark_node)
return error_mark_node;
op2 = build_non_dependent_expr (op2);
}
- expr = build_conditional_expr (ifexp, op1, op2, complain);
+ expr = build_conditional_expr (loc, ifexp, op1, op2, complain);
if (processing_template_decl && expr != error_mark_node
&& TREE_CODE (expr) != VEC_COND_EXPR)
{
return error_mark_node;
cond = build_conditional_expr
- (TREE_OPERAND (lhs, 0),
+ (input_location, TREE_OPERAND (lhs, 0),
cp_build_modify_expr (TREE_OPERAND (lhs, 1),
modifycode, rhs, complain),
cp_build_modify_expr (TREE_OPERAND (lhs, 2),