c-common.c (truthvalue_conversion): Protect side effects in the expression when split...
authorAndreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Fri, 19 Jun 1998 01:46:50 +0000 (01:46 +0000)
committerAndreas Schwab <schwab@gcc.gnu.org>
Fri, 19 Jun 1998 01:46:50 +0000 (01:46 +0000)
* c-common.c (truthvalue_conversion): Protect side effects in the
expression when splitting a complex value.
* fold-const.c (fold): Likewise.

From-SVN: r20580

gcc/ChangeLog
gcc/c-common.c
gcc/fold-const.c

index 5afe85f9894906543cd67227b69757ce3840224c..af13373f7aefe68dbef5b7582438bbe1d0e406d7 100644 (file)
@@ -1,3 +1,9 @@
+Fri Jun 19 10:43:52 1998  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+       * c-common.c (truthvalue_conversion): Protect side effects in the
+       expression when splitting a complex value.
+       * fold-const.c (fold): Likewise. 
+
 Fri Jun 19 02:31:16 1998  Klaus Kaempf (kkaempf@progis.de)
 
        * cccp.c (hack_vms_include_specification): rewrite to handle
index 9983cdbc5efad5cf163d8d0f5028021afc1ce6fb..3a22c17418067e283e749c9b857cd01d6a095e45 100644 (file)
@@ -2670,12 +2670,15 @@ truthvalue_conversion (expr)
     }
 
   if (TREE_CODE (TREE_TYPE (expr)) == COMPLEX_TYPE)
-    return (build_binary_op
-           ((TREE_SIDE_EFFECTS (expr)
-             ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
-            truthvalue_conversion (build_unary_op (REALPART_EXPR, expr, 0)),
-            truthvalue_conversion (build_unary_op (IMAGPART_EXPR, expr, 0)),
-            0));
+    {
+      tree tem = save_expr (expr);
+      return (build_binary_op
+             ((TREE_SIDE_EFFECTS (expr)
+               ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
+              truthvalue_conversion (build_unary_op (REALPART_EXPR, tem, 0)),
+              truthvalue_conversion (build_unary_op (IMAGPART_EXPR, tem, 0)),
+              0));
+    }
 
   return build_binary_op (NE_EXPR, expr, integer_zero_node, 1);
 }
index 73b018924650e6b53c5e5733571ee530fd3ed479..30499a178dec3ca8b9fe862390e6cf338ce4bce9 100644 (file)
@@ -5656,10 +5656,14 @@ fold (expr)
              || TREE_CODE (arg1) == COMPLEX_EXPR))
        {
          tree subtype = TREE_TYPE (TREE_TYPE (arg0));
-         tree real0 = fold (build1 (REALPART_EXPR, subtype, arg0));
-         tree imag0 = fold (build1 (IMAGPART_EXPR, subtype, arg0));
-         tree real1 = fold (build1 (REALPART_EXPR, subtype, arg1));
-         tree imag1 = fold (build1 (IMAGPART_EXPR, subtype, arg1));
+         tree real0, imag0, real1, imag1;
+
+         arg0 = save_expr (arg0);
+         arg1 = save_expr (arg1);
+         real0 = fold (build1 (REALPART_EXPR, subtype, arg0));
+         imag0 = fold (build1 (IMAGPART_EXPR, subtype, arg0));
+         real1 = fold (build1 (REALPART_EXPR, subtype, arg1));
+         imag1 = fold (build1 (IMAGPART_EXPR, subtype, arg1));
 
          return fold (build ((code == EQ_EXPR ? TRUTH_ANDIF_EXPR
                               : TRUTH_ORIF_EXPR),