From: Eric Botcazou Date: Fri, 23 Jan 2004 16:52:07 +0000 (+0100) Subject: fold-const.c (fold_binary_op_with_conditional_arg): Only build a COMPOUND_EXPR if... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a944ef648a5d7cab40f741d7a4491904f200936;p=gcc.git 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 From-SVN: r76434 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5679eb4a534..20e4249986d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-01-23 Eric Botcazou + Olivier Hainque + + * fold-const.c (fold_binary_op_with_conditional_arg): Only + build a COMPOUND_EXPR if 'arg' is really a SAVE_EXPR. + 2004-01-23 Daniel Jacobowitz * config/arm/arm.c (arm_legitimate_address_p): Don't check the mode diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d29b86e067e..de72a76f1ff 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),