aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-11-12 15:26:36 -0500
committerJason Merrill <jason@gcc.gnu.org>2009-11-12 15:26:36 -0500
commitd6c057abd6a83513d4b6356314b8c5752a7025af (patch)
tree4a28c4e0186639b2002f691c51080755c952cdb5 /gcc/cp
parentc8f59bc81c76a89edab59ac23a1ba687db68c0be (diff)
downloadgcc-d6c057abd6a83513d4b6356314b8c5752a7025af.zip
gcc-d6c057abd6a83513d4b6356314b8c5752a7025af.tar.gz
gcc-d6c057abd6a83513d4b6356314b8c5752a7025af.tar.bz2
re PR c++/42013 (cv-qualification of conditional expression type depending on the value of its first expression?!?)
PR c++/42013 * call.c (build_conditional_expr): Check specifically for folding to CALL_EXPR rather than TREE_SIDE_EFFECTS. From-SVN: r154129
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c11
2 files changed, 12 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 861835b..e0b5f27 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2009-11-12 Jason Merrill <jason@redhat.com>
+ PR c++/42013
+ * call.c (build_conditional_expr): Check specifically for folding
+ to CALL_EXPR rather than TREE_SIDE_EFFECTS.
+
+2009-11-12 Jason Merrill <jason@redhat.com>
+
* typeck.c (cv_qualified_p): New fn.
(decay_conversion): Use it.
* cp-tree.h: Declare it.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index e77a738..e4a6bca3 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3605,6 +3605,7 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3,
tree arg2_type;
tree arg3_type;
tree result = NULL_TREE;
+ tree result_save;
tree result_type = NULL_TREE;
bool lvalue_p = true;
struct z_candidate *candidates = 0;
@@ -3991,12 +3992,12 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3,
}
valid_operands:
- result = build3 (COND_EXPR, result_type, arg1, arg2, arg3);
+ result_save = build3 (COND_EXPR, result_type, arg1, arg2, arg3);
+ result = fold_if_not_in_template (result_save);
- if (cp_unevaluated_operand && TREE_SIDE_EFFECTS (result))
- /* Avoid folding a ?: of two calls within decltype (c++/42013). */;
- else
- result = fold_if_not_in_template (result);
+ if (cp_unevaluated_operand && TREE_CODE (result) == CALL_EXPR)
+ /* Avoid folding to a CALL_EXPR within decltype (c++/42013). */
+ result = result_save;
/* We can't use result_type below, as fold might have returned a
throw_expr. */