aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-11-12 13:25:42 -0500
committerJason Merrill <jason@gcc.gnu.org>2009-11-12 13:25:42 -0500
commitf33e4dd77aa34fab8c329da1572289304802c2a1 (patch)
tree11455813d31d0bd5a499463d3f1bf40fc9518d77 /gcc/cp
parent9d324ddebd9179cac8a7dcc1bba76b8579902e9f (diff)
downloadgcc-f33e4dd77aa34fab8c329da1572289304802c2a1.zip
gcc-f33e4dd77aa34fab8c329da1572289304802c2a1.tar.gz
gcc-f33e4dd77aa34fab8c329da1572289304802c2a1.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): Don't fold a TREE_SIDE_EFFECTS COND_EXPR in unevaluated context. From-SVN: r154124
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c9
2 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9a28a49..e6d696b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-12 Jason Merrill <jason@redhat.com>
+
+ PR c++/42013
+ * call.c (build_conditional_expr): Don't fold a TREE_SIDE_EFFECTS
+ COND_EXPR in unevaluated context.
+
2009-11-12 Jan Hubicka <jh@suse.cz>
* decl2.c (constrain_visibility): Clear WEAK and COMMON flags.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index db609f8..e77a738 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3991,8 +3991,13 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3,
}
valid_operands:
- result = fold_if_not_in_template (build3 (COND_EXPR, result_type, arg1,
- arg2, arg3));
+ result = build3 (COND_EXPR, result_type, arg1, arg2, arg3);
+
+ 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);
+
/* We can't use result_type below, as fold might have returned a
throw_expr. */