(convert_to_integer): When we want to return zero, be sure we honor
authorRichard Kenner <kenner@gcc.gnu.org>
Wed, 28 Apr 1993 10:16:57 +0000 (06:16 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Wed, 28 Apr 1993 10:16:57 +0000 (06:16 -0400)
any side-effects in our operand.

From-SVN: r4255

gcc/convert.c

index 7261e1baa8ed2db88c94bfb345e28dfb49ef5817..d073ac3ee625fa707334b60cdc9db2803ec4a85e 100644 (file)
@@ -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;