aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-08-26 00:35:17 -0400
committerJason Merrill <jason@gcc.gnu.org>2009-08-26 00:35:17 -0400
commit7919d7b4422cefaa7768d576a73bcf96a6efd6cb (patch)
tree546ac29f25c2da9faf199e896449acc55bbcf658 /gcc
parent171fc18dd9e9fc5653711067b1c7061238348099 (diff)
downloadgcc-7919d7b4422cefaa7768d576a73bcf96a6efd6cb.zip
gcc-7919d7b4422cefaa7768d576a73bcf96a6efd6cb.tar.gz
gcc-7919d7b4422cefaa7768d576a73bcf96a6efd6cb.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/call.c38
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/overload/cond2.C15
4 files changed, 33 insertions, 29 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6c9d217..e7f4500 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+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.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f6a083b..8dc6d2a 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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),
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 54c86c8..d465ac2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+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.
diff --git a/gcc/testsuite/g++.dg/overload/cond2.C b/gcc/testsuite/g++.dg/overload/cond2.C
new file mode 100644
index 0000000..cbcdc6e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/cond2.C
@@ -0,0 +1,15 @@
+struct C
+{
+ operator int();
+};
+
+struct D
+{
+ operator int();
+};
+
+int main()
+{
+ C c; D d;
+ true ? c : d;
+}