summaryrefslogtreecommitdiffstats
path: root/gcc/convert.c
diff options
context:
space:
mode:
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1993-04-28 10:16:57 +0000
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1993-04-28 10:16:57 +0000
commit29e338325829e6031e4945b48651f59d24d1d987 (patch)
tree8cd22dd5e09259b9190a5755aeae38042ba9a184 /gcc/convert.c
parentb7d4d520f9896bcfe9fa584d3976a19f82bface3 (diff)
downloadppe42-gcc-29e338325829e6031e4945b48651f59d24d1d987.tar.gz
ppe42-gcc-29e338325829e6031e4945b48651f59d24d1d987.zip
(convert_to_integer): When we want to return zero, be sure we honor
any side-effects in our operand. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@4255 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/convert.c')
-rw-r--r--gcc/convert.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/convert.c b/gcc/convert.c
index 7261e1baa8e..d073ac3ee62 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -199,11 +199,22 @@ convert_to_integer (type, expr)
/* In this case, shifting is like multiplication. */
goto trunc1;
else
- /* If it is >= that width, result is zero.
- Handling this with trunc1 would give the wrong result:
- (int) ((long long) a << 32) is well defined (as 0)
- but (int) a << 32 is undefined and would get a warning. */
- return convert_to_integer (type, integer_zero_node);
+ {
+ /* If it is >= that width, result is zero.
+ Handling this with trunc1 would give the wrong result:
+ (int) ((long long) a << 32) is well defined (as 0)
+ but (int) a << 32 is undefined and would get a
+ warning. */
+
+ tree t = convert_to_integer (type, integer_zero_node);
+
+ /* If the original expression had side-effects, we must
+ preserve it. */
+ if (TREE_SIDE_EFFECTS (expr))
+ return build (COMPOUND_EXPR, type, expr, t);
+ else
+ return t;
+ }
}
break;
OpenPOWER on IntegriCloud