Commit 4cbc4bd7 by Paolo Carlini Committed by Paolo Carlini

call.c (build_conditional_expr_1): Add location_t parameter.

/cp
2013-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

	* call.c (build_conditional_expr_1): Add location_t parameter.
	(build_conditional_expr): Likewise.
	* typeck.c (rationalize_conditional_expr, cp_build_array_ref,
	get_member_function_from_ptrfunc, build_x_conditional_expr,
	cp_build_modify_expr): Update.
	* init.c (build_new_1): Likewise.
	* cp-tree.h: Update declaration.

/testsuite
2013-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/explicit3.C: Add column in dg-error strings.
	* g++.dg/warn/Wdouble-promotion.C: Likewise.

From-SVN: r199166
parent 4f7a634e
2013-05-21 Paolo Carlini <paolo.carlini@oracle.com>
* call.c (build_conditional_expr_1): Add location_t parameter.
(build_conditional_expr): Likewise.
* typeck.c (rationalize_conditional_expr, cp_build_array_ref,
get_member_function_from_ptrfunc, build_x_conditional_expr,
cp_build_modify_expr): Update.
* init.c (build_new_1): Likewise.
* cp-tree.h: Update declaration.
2013-05-20 Jason Merrill <jason@redhat.com> 2013-05-20 Jason Merrill <jason@redhat.com>
PR c++/57016 PR c++/57016
......
...@@ -4353,7 +4353,7 @@ conditional_conversion (tree e1, tree e2, tsubst_flags_t complain) ...@@ -4353,7 +4353,7 @@ conditional_conversion (tree e1, tree e2, tsubst_flags_t complain)
arguments to the conditional expression. */ arguments to the conditional expression. */
static tree 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) tsubst_flags_t complain)
{ {
tree arg2_type; tree arg2_type;
...@@ -4373,7 +4373,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4373,7 +4373,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
if (!arg2) if (!arg2)
{ {
if (complain & tf_error) if (complain & tf_error)
pedwarn (input_location, OPT_Wpedantic, pedwarn (loc, OPT_Wpedantic,
"ISO C++ forbids omitting the middle term of a ?: expression"); "ISO C++ forbids omitting the middle term of a ?: expression");
/* Make sure that lvalues remain lvalues. See g++.oliva/ext1.C. */ /* Make sure that lvalues remain lvalues. See g++.oliva/ext1.C. */
...@@ -4407,8 +4407,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4407,8 +4407,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
&& TREE_CODE (arg3_type) != VECTOR_TYPE) && TREE_CODE (arg3_type) != VECTOR_TYPE)
{ {
if (complain & tf_error) if (complain & tf_error)
error ("at least one operand of a vector conditional operator " error_at (loc, "at least one operand of a vector conditional "
"must be a vector"); "operator must be a vector");
return error_mark_node; return error_mark_node;
} }
...@@ -4416,7 +4416,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4416,7 +4416,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
!= (TREE_CODE (arg3_type) == VECTOR_TYPE)) != (TREE_CODE (arg3_type) == VECTOR_TYPE))
{ {
enum stv_conv convert_flag = 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); complain & tf_error);
switch (convert_flag) switch (convert_flag)
...@@ -4448,14 +4448,15 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4448,14 +4448,15 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
|| TYPE_SIZE (arg1_type) != TYPE_SIZE (arg2_type)) || TYPE_SIZE (arg1_type) != TYPE_SIZE (arg2_type))
{ {
if (complain & tf_error) if (complain & tf_error)
error ("incompatible vector types in conditional expression: " error_at (loc,
"%qT, %qT and %qT", TREE_TYPE (arg1), TREE_TYPE (orig_arg2), "incompatible vector types in conditional expression: "
TREE_TYPE (orig_arg3)); "%qT, %qT and %qT", TREE_TYPE (arg1),
TREE_TYPE (orig_arg2), TREE_TYPE (orig_arg3));
return error_mark_node; return error_mark_node;
} }
if (!COMPARISON_CLASS_P (arg1)) 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); build_zero_cst (arg1_type), complain);
return fold_build3 (VEC_COND_EXPR, arg2_type, arg1, arg2, arg3); return fold_build3 (VEC_COND_EXPR, arg2_type, arg1, arg2, arg3);
} }
...@@ -4535,15 +4536,15 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4535,15 +4536,15 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
if (complain & tf_error) if (complain & tf_error)
{ {
if (VOID_TYPE_P (arg2_type)) if (VOID_TYPE_P (arg2_type))
error ("second operand to the conditional operator " error_at (EXPR_LOC_OR_LOC (arg3, loc),
"is of type %<void%>, " "second operand to the conditional operator "
"but the third operand is neither a throw-expression " "is of type %<void%>, but the third operand is "
"nor of type %<void%>"); "neither a throw-expression nor of type %<void%>");
else else
error ("third operand to the conditional operator " error_at (EXPR_LOC_OR_LOC (arg2, loc),
"is of type %<void%>, " "third operand to the conditional operator "
"but the second operand is neither a throw-expression " "is of type %<void%>, but the second operand is "
"nor of type %<void%>"); "neither a throw-expression nor of type %<void%>");
} }
return error_mark_node; return error_mark_node;
} }
...@@ -4583,8 +4584,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4583,8 +4584,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
|| (conv3 && conv3->kind == ck_ambig)) || (conv3 && conv3->kind == ck_ambig))
{ {
if (complain & tf_error) if (complain & tf_error)
error ("operands to ?: have different types %qT and %qT", error_at (loc, "operands to ?: have different types %qT and %qT",
arg2_type, arg3_type); arg2_type, arg3_type);
result = error_mark_node; result = error_mark_node;
} }
else if (conv2 && (!conv2->bad_p || !conv3)) else if (conv2 && (!conv2->bad_p || !conv3))
...@@ -4690,9 +4691,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4690,9 +4691,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
{ {
if (complain & tf_error) if (complain & tf_error)
{ {
op_error (input_location, COND_EXPR, NOP_EXPR, op_error (loc, COND_EXPR, NOP_EXPR, arg1, arg2, arg3, FALSE);
arg1, arg2, arg3, FALSE); print_z_candidates (loc, candidates);
print_z_candidates (location_of (arg1), candidates);
} }
return error_mark_node; return error_mark_node;
} }
...@@ -4701,9 +4701,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4701,9 +4701,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
{ {
if (complain & tf_error) if (complain & tf_error)
{ {
op_error (input_location, COND_EXPR, NOP_EXPR, op_error (loc, COND_EXPR, NOP_EXPR, arg1, arg2, arg3, FALSE);
arg1, arg2, arg3, FALSE); print_z_candidates (loc, candidates);
print_z_candidates (location_of (arg1), candidates);
} }
return error_mark_node; return error_mark_node;
} }
...@@ -4770,7 +4769,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4770,7 +4769,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
do_warn_double_promotion (result_type, arg2_type, arg3_type, do_warn_double_promotion (result_type, arg2_type, arg3_type,
"implicit conversion from %qT to %qT to " "implicit conversion from %qT to %qT to "
"match other result of conditional", "match other result of conditional",
input_location); loc);
if (TREE_CODE (arg2_type) == ENUMERAL_TYPE if (TREE_CODE (arg2_type) == ENUMERAL_TYPE
&& TREE_CODE (arg3_type) == ENUMERAL_TYPE) && TREE_CODE (arg3_type) == ENUMERAL_TYPE)
...@@ -4781,19 +4780,20 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4781,19 +4780,20 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
/* Two enumerators from the same enumeration can have different /* Two enumerators from the same enumeration can have different
types when the enumeration is still being defined. */; types when the enumeration is still being defined. */;
else if (complain & tf_warning) else if (complain & tf_warning)
warning (OPT_Wenum_compare, warning_at (loc, OPT_Wenum_compare, "enumeral mismatch in "
"enumeral mismatch in conditional expression: %qT vs %qT", "conditional expression: %qT vs %qT",
arg2_type, arg3_type); arg2_type, arg3_type);
} }
else if (extra_warnings else if (extra_warnings
&& ((TREE_CODE (arg2_type) == ENUMERAL_TYPE && ((TREE_CODE (arg2_type) == ENUMERAL_TYPE
&& !same_type_p (arg3_type, type_promotes_to (arg2_type))) && !same_type_p (arg3_type, type_promotes_to (arg2_type)))
|| (TREE_CODE (arg3_type) == ENUMERAL_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) if (complain & tf_warning)
warning (0, warning_at (loc, 0, "enumeral and non-enumeral type in "
"enumeral and non-enumeral type in conditional expression"); "conditional expression");
} }
arg2 = perform_implicit_conversion (result_type, arg2, complain); arg2 = perform_implicit_conversion (result_type, arg2, complain);
...@@ -4835,8 +4835,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4835,8 +4835,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
if (!result_type) if (!result_type)
{ {
if (complain & tf_error) if (complain & tf_error)
error ("operands to ?: have different types %qT and %qT", error_at (loc, "operands to ?: have different types %qT and %qT",
arg2_type, arg3_type); arg2_type, arg3_type);
return error_mark_node; return error_mark_node;
} }
...@@ -4873,12 +4873,12 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, ...@@ -4873,12 +4873,12 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
/* Wrapper for above. */ /* Wrapper for above. */
tree 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) tsubst_flags_t complain)
{ {
tree ret; tree ret;
bool subtime = timevar_cond_start (TV_OVERLOAD); 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); timevar_cond_stop (TV_OVERLOAD, subtime);
return ret; return ret;
} }
......
...@@ -4969,7 +4969,7 @@ extern bool pragma_java_exceptions; ...@@ -4969,7 +4969,7 @@ extern bool pragma_java_exceptions;
/* in call.c */ /* in call.c */
extern bool check_dtor_name (tree, tree); extern bool check_dtor_name (tree, tree);
extern tree build_conditional_expr (tree, tree, tree, extern tree build_conditional_expr (location_t, tree, tree, tree,
tsubst_flags_t); tsubst_flags_t);
extern tree build_addr_func (tree, tsubst_flags_t); extern tree build_addr_func (tree, tsubst_flags_t);
extern void set_flags_from_callee (tree); extern void set_flags_from_callee (tree);
......
...@@ -2900,8 +2900,8 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, ...@@ -2900,8 +2900,8 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
NE_EXPR, alloc_node, NE_EXPR, alloc_node,
nullptr_node, nullptr_node,
complain); complain);
rval = build_conditional_expr (ifexp, rval, alloc_node, rval = build_conditional_expr (input_location, ifexp, rval,
complain); alloc_node, complain);
} }
/* Perform the allocation before anything else, so that ALLOC_NODE /* Perform the allocation before anything else, so that ALLOC_NODE
......
...@@ -2141,7 +2141,8 @@ rationalize_conditional_expr (enum tree_code code, tree t, ...@@ -2141,7 +2141,8 @@ rationalize_conditional_expr (enum tree_code code, tree t,
gcc_assert (!TREE_SIDE_EFFECTS (op0) gcc_assert (!TREE_SIDE_EFFECTS (op0)
&& !TREE_SIDE_EFFECTS (op1)); && !TREE_SIDE_EFFECTS (op1));
return 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 (TREE_CODE (t) == MIN_EXPR
? LE_EXPR : GE_EXPR), ? LE_EXPR : GE_EXPR),
op0, TREE_CODE (op0), op0, TREE_CODE (op0),
...@@ -2154,7 +2155,7 @@ rationalize_conditional_expr (enum tree_code code, tree t, ...@@ -2154,7 +2155,7 @@ rationalize_conditional_expr (enum tree_code code, tree t,
} }
return 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, cp_build_unary_op (code, TREE_OPERAND (t, 1), 0,
complain), complain),
cp_build_unary_op (code, TREE_OPERAND (t, 2), 0, cp_build_unary_op (code, TREE_OPERAND (t, 2), 0,
...@@ -3024,7 +3025,7 @@ cp_build_array_ref (location_t loc, tree array, tree idx, ...@@ -3024,7 +3025,7 @@ cp_build_array_ref (location_t loc, tree array, tree idx,
case COND_EXPR: case COND_EXPR:
ret = build_conditional_expr ret = build_conditional_expr
(TREE_OPERAND (array, 0), (loc, TREE_OPERAND (array, 0),
cp_build_array_ref (loc, TREE_OPERAND (array, 1), idx, cp_build_array_ref (loc, TREE_OPERAND (array, 1), idx,
complain), complain),
cp_build_array_ref (loc, TREE_OPERAND (array, 2), idx, cp_build_array_ref (loc, TREE_OPERAND (array, 2), idx,
...@@ -3306,7 +3307,7 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function, ...@@ -3306,7 +3307,7 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function,
cp_build_addr_expr (e2, complain)); cp_build_addr_expr (e2, complain));
e2 = fold_convert (TREE_TYPE (e3), e2); 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) if (e1 == error_mark_node)
return error_mark_node; return error_mark_node;
...@@ -5902,7 +5903,7 @@ build_x_conditional_expr (location_t loc, tree ifexp, tree op1, tree op2, ...@@ -5902,7 +5903,7 @@ build_x_conditional_expr (location_t loc, tree ifexp, tree op1, tree op2,
op2 = build_non_dependent_expr (op2); 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 if (processing_template_decl && expr != error_mark_node
&& TREE_CODE (expr) != VEC_COND_EXPR) && TREE_CODE (expr) != VEC_COND_EXPR)
{ {
...@@ -7152,7 +7153,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, ...@@ -7152,7 +7153,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
return error_mark_node; return error_mark_node;
cond = build_conditional_expr cond = build_conditional_expr
(TREE_OPERAND (lhs, 0), (input_location, TREE_OPERAND (lhs, 0),
cp_build_modify_expr (TREE_OPERAND (lhs, 1), cp_build_modify_expr (TREE_OPERAND (lhs, 1),
modifycode, rhs, complain), modifycode, rhs, complain),
cp_build_modify_expr (TREE_OPERAND (lhs, 2), cp_build_modify_expr (TREE_OPERAND (lhs, 2),
......
2013-05-21 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/explicit3.C: Add column in dg-error strings.
* g++.dg/warn/Wdouble-promotion.C: Likewise.
2013-05-21 Easwaran Raman <eraman@google.com> 2013-05-21 Easwaran Raman <eraman@google.com>
PR tree-optimization/57322 PR tree-optimization/57322
......
...@@ -42,10 +42,9 @@ int main() ...@@ -42,10 +42,9 @@ int main()
// These do not. // These do not.
switch (a); // { dg-error "" } switch (a); // { dg-error "" }
bool b = a; // { dg-error "" } bool b = a; // { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 44 }
f(a); // { dg-error "" } f(a); // { dg-error "" }
B b2 = { a }; // { dg-error "" } B b2 = { a }; // { dg-error "" }
a + true; // { dg-message "" } a + true; // { dg-error "5:no match" }
b ? a : true; // { dg-message "" } b ? a : true; // { dg-error "5:no match" }
a ? a : true; // { dg-message "" } a ? a : true; // { dg-error "5:no match" }
} }
...@@ -29,19 +29,19 @@ usual_arithmetic_conversions(void) ...@@ -29,19 +29,19 @@ usual_arithmetic_conversions(void)
/* Values of type "float" are implicitly converted to "double" or /* Values of type "float" are implicitly converted to "double" or
"long double" due to use in arithmetic with "double" or "long "long double" due to use in arithmetic with "double" or "long
double" operands. */ double" operands. */
local_f = f + 1.0; /* { dg-warning "implicit" } */ local_f = f + 1.0; /* { dg-warning "15:implicit" } */
local_f = f - d; /* { dg-warning "implicit" } */ local_f = f - d; /* { dg-warning "15:implicit" } */
local_f = 1.0f * 1.0; /* { dg-warning "implicit" } */ local_f = 1.0f * 1.0; /* { dg-warning "18:implicit" } */
local_f = 1.0f / d; /* { dg-warning "implicit" } */ local_f = 1.0f / d; /* { dg-warning "18:implicit" } */
local_cf = cf + 1.0; /* { dg-warning "implicit" } */ local_cf = cf + 1.0; /* { dg-warning "17:implicit" } */
local_cf = cf - d; /* { dg-warning "implicit" } */ local_cf = cf - d; /* { dg-warning "17:implicit" } */
local_cf = cf + 1.0 * ID; /* { dg-warning "implicit" } */ local_cf = cf + 1.0 * ID; /* { dg-warning "17:implicit" } */
local_cf = cf - cd; /* { dg-warning "implicit" } */ local_cf = cf - cd; /* { dg-warning "17:implicit" } */
local_f = i ? f : d; /* { dg-warning "implicit" } */ local_f = i ? f : d; /* { dg-warning "15:implicit" } */
i = f == d; /* { dg-warning "implicit" } */ i = f == d; /* { dg-warning "9:implicit" } */
i = d != f; /* { dg-warning "implicit" } */ i = d != f; /* { dg-warning "9:implicit" } */
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment