Commit 7919d7b4 by Jason Merrill Committed by Jason Merrill

call.c (build_conditional_expr): Fix logic errors.

	* call.c (build_conditional_expr): Fix logic errors.
	(build_new_op): Remove dead COND_EXPR handling.

From-SVN: r151113
parent 171fc18d
2009-08-26 Jason Merrill <jason@redhat.com>
* call.c (build_conditional_expr): Fix logic errors.
(build_new_op): Remove dead COND_EXPR handling.
2009-08-24 Jason Merrill <jason@redhat.com>
* cp-tree.h (DECL_DEFERRED_FN): Remove.
......
......@@ -3791,7 +3791,7 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3,
bool any_viable_p;
/* Rearrange the arguments so that add_builtin_candidate only has
to know about two args. In build_builtin_candidates, the
to know about two args. In build_builtin_candidate, the
arguments are unscrambled. */
args[0] = arg2;
args[1] = arg3;
......@@ -3837,8 +3837,10 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3,
arg1 = convert_like (conv, arg1, complain);
conv = cand->convs[1];
arg2 = convert_like (conv, arg2, complain);
arg2_type = TREE_TYPE (arg2);
conv = cand->convs[2];
arg3 = convert_like (conv, arg3, complain);
arg3_type = TREE_TYPE (arg3);
}
/* [expr.cond]
......@@ -3857,7 +3859,7 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3,
arg2_type = TREE_TYPE (arg2);
arg3 = force_rvalue (arg3);
if (!CLASS_TYPE_P (arg2_type))
if (!CLASS_TYPE_P (arg3_type))
arg3_type = TREE_TYPE (arg3);
if (arg2 == error_mark_node || arg3 == error_mark_node)
......@@ -4157,14 +4159,8 @@ build_new_op (enum tree_code code, int flags, tree arg1, tree arg2, tree arg3,
arg3 = prep_operand (arg3);
if (code == COND_EXPR)
{
if (arg2 == NULL_TREE
|| TREE_CODE (TREE_TYPE (arg2)) == VOID_TYPE
|| TREE_CODE (TREE_TYPE (arg3)) == VOID_TYPE
|| (! IS_OVERLOAD_TYPE (TREE_TYPE (arg2))
&& ! IS_OVERLOAD_TYPE (TREE_TYPE (arg3))))
goto builtin;
}
/* Use build_conditional_expr instead. */
gcc_unreachable ();
else if (! IS_OVERLOAD_TYPE (TREE_TYPE (arg1))
&& (! arg2 || ! IS_OVERLOAD_TYPE (TREE_TYPE (arg2))))
goto builtin;
......@@ -4206,22 +4202,9 @@ build_new_op (enum tree_code code, int flags, tree arg1, tree arg2, tree arg3,
flags, &candidates);
}
/* Rearrange the arguments for ?: so that add_builtin_candidate only has
to know about two args; a builtin candidate will always have a first
parameter of type bool. We'll handle that in
build_builtin_candidate. */
if (code == COND_EXPR)
{
args[0] = arg2;
args[1] = arg3;
args[2] = arg1;
}
else
{
args[0] = arg1;
args[1] = arg2;
args[2] = NULL_TREE;
}
args[0] = arg1;
args[1] = arg2;
args[2] = NULL_TREE;
add_builtin_candidates (&candidates, code, code2, fnname, args, flags);
......@@ -4463,9 +4446,6 @@ build_new_op (enum tree_code code, int flags, tree arg1, tree arg2, tree arg3,
case ARRAY_REF:
return build_array_ref (input_location, arg1, arg2);
case COND_EXPR:
return build_conditional_expr (arg1, arg2, arg3, complain);
case MEMBER_REF:
return build_m_component_ref (cp_build_indirect_ref (arg1, NULL,
complain),
......
2009-08-26 Jason Merrill <jason@redhat.com>
* g++.dg/overload/cond2.C: New.
2009-08-25 Kaz Kojima <kkojima@gcc.gnu.org>
* gcc.dg/torture/builtin-math-7.c: Add -mieee for sh*-*-* targets.
......
struct C
{
operator int();
};
struct D
{
operator int();
};
int main()
{
C c; D d;
true ? c : d;
}
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