(expand_increment): Call save_expr on inner expression if
authorJim Wilson <wilson@gcc.gnu.org>
Sun, 8 Aug 1993 22:48:15 +0000 (15:48 -0700)
committerJim Wilson <wilson@gcc.gnu.org>
Sun, 8 Aug 1993 22:48:15 +0000 (15:48 -0700)
it is itself an increment expression.

From-SVN: r5115

gcc/expr.c

index bb31906f8c11380c7b1fd92816ea7012a87f414c..713f7d4eb77b8a756e78bb1f4bd59abf8e4e8746 100644 (file)
@@ -6940,6 +6940,12 @@ expand_increment (exp, post)
          && (TREE_CODE (TREE_OPERAND (incremented, 0)) != INDIRECT_REF
              || DECL_BIT_FIELD (TREE_OPERAND (incremented, 1)))))
     incremented = stabilize_reference (incremented);
+  /* Nested *INCREMENT_EXPRs can happen in C++.  We must force innermost
+     ones into save exprs so that they don't accidentally get evaluated
+     more than once by the code below.  */
+  if (TREE_CODE (incremented) == PREINCREMENT_EXPR
+      || TREE_CODE (incremented) == PREDECREMENT_EXPR)
+    incremented = save_expr (incremented);
 
   /* Compute the operands as RTX.
      Note whether OP0 is the actual lvalue or a copy of it: