aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@act-europe.fr>2004-01-23 17:52:07 +0100
committerEric Botcazou <ebotcazou@gcc.gnu.org>2004-01-23 16:52:07 +0000
commit0a944ef648a5d7cab40f741d7a4491904f200936 (patch)
treeb67a2d42933b08f285794356a649b4d0a065dc1d /gcc/fold-const.c
parent22352844c944c3d4fb2e70854484d346fffa9733 (diff)
downloadgcc-0a944ef648a5d7cab40f741d7a4491904f200936.zip
gcc-0a944ef648a5d7cab40f741d7a4491904f200936.tar.gz
gcc-0a944ef648a5d7cab40f741d7a4491904f200936.tar.bz2
fold-const.c (fold_binary_op_with_conditional_arg): Only build a COMPOUND_EXPR if 'arg' is really a SAVE_EXPR.
* fold-const.c (fold_binary_op_with_conditional_arg): Only build a COMPOUND_EXPR if 'arg' is really a SAVE_EXPR. Co-Authored-By: Olivier Hainque <hainque@act-europe.fr> From-SVN: r76434
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index d29b86e..de72a76 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -4749,7 +4749,7 @@ fold_binary_op_with_conditional_arg (enum tree_code code, tree type,
{
arg = save_expr (arg);
lhs = rhs = 0;
- save = 1;
+ save = saved_expr_p (arg);
}
}
@@ -4760,6 +4760,12 @@ fold_binary_op_with_conditional_arg (enum tree_code code, tree type,
test = fold (build (COND_EXPR, type, test, lhs, rhs));
+ /* If ARG involves a SAVE_EXPR, we need to ensure it is evaluated
+ ahead of the COND_EXPR we made. Otherwise we would have it only
+ evaluated in one branch, with the other branch using the result
+ but missing the evaluation code. Beware that the save_expr call
+ above might not return a SAVE_EXPR, so testing the TREE_CODE
+ of ARG is not enough to decide here.  */
if (save)
return build (COMPOUND_EXPR, type,
convert (void_type_node, arg),