aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/expr.c
diff options
context:
space:
mode:
authorAlexandre Petit-Bianco <apbianco@cygnus.com>1999-07-07 13:11:03 +0000
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>1999-07-07 06:11:03 -0700
commit1a6d4fb73c25078994d945918a1451a94f79e56c (patch)
tree5b9696999f573cbe70d7dd465a7618959da1fc81 /gcc/java/expr.c
parent44a6ce434cdb606a3a8d9e542351aefbf1eb8965 (diff)
downloadgcc-1a6d4fb73c25078994d945918a1451a94f79e56c.zip
gcc-1a6d4fb73c25078994d945918a1451a94f79e56c.tar.gz
gcc-1a6d4fb73c25078994d945918a1451a94f79e56c.tar.bz2
[multiple changes]
Sat Jul 3 22:26:32 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> * expr.c (force_evaluation_order): Save the COMPOUND_EXPR'ed CALL_EXPR, to avoid order of evaluation changes. Fri Jul 2 17:44:08 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> * parse.y (qualify_ambiguous_name): Do not use IDENTIFIER_LOCAL_VALUE when name is a STRING_CST. Thu Jul 1 23:31:16 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> * check-init.c (check_init): Handle MAX_EXPR. * expr.c (force_evaluation_order): Force method call arguments to be evaluated in left-to-right order. * parse.y (qualify_ambiguous_name): Loop again to qualify NEW_ARRAY_EXPR properly. Wed Jun 30 17:27:58 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> * parse.y (patch_invoke): Resolve unresolved invoked method returned type. (qualify_ambiguous_name): STRING_CST to qualify expression for type name resolution. From-SVN: r27998
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r--gcc/java/expr.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 9beb724..8998bdb 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -2578,6 +2578,10 @@ process_jvm_instruction (PC, byte_ops, length)
We fix this by using save_expr. This forces the sub-operand to be
copied into a fresh virtual register,
+
+ For method invocation, we modify the arguments so that a
+ left-to-right order evaluation is performed. Saved expressions
+ will, in CALL_EXPR order, be reused when the call will be expanded.
*/
tree
@@ -2593,19 +2597,30 @@ force_evaluation_order (node)
}
else if (TREE_CODE (node) == CALL_EXPR || TREE_CODE (node) == NEW_CLASS_EXPR)
{
- tree last_side_effecting_arg = NULL_TREE;
- tree arg = TREE_OPERAND (node, 1);
- for (; arg != NULL_TREE; arg = TREE_CHAIN (arg))
+ tree arg, cmp;
+
+ if (!TREE_OPERAND (node, 1))
+ return node;
+
+ /* This reverses the evaluation order. This is a desired effect. */
+ for (cmp = NULL_TREE, arg = TREE_OPERAND (node, 1);
+ arg; arg = TREE_CHAIN (arg))
{
- if (TREE_SIDE_EFFECTS (TREE_VALUE (arg)))
- last_side_effecting_arg = arg;
+ tree saved = save_expr (TREE_VALUE (arg));
+ cmp = (cmp == NULL_TREE ? saved :
+ build (COMPOUND_EXPR, void_type_node, cmp, saved));
+ TREE_VALUE (arg) = saved;
}
- arg = TREE_OPERAND (node, 1);
- for (; arg != NULL_TREE; arg = TREE_CHAIN (arg))
+
+ if (cmp && TREE_CODE (cmp) == COMPOUND_EXPR)
+ TREE_SIDE_EFFECTS (cmp) = 1;
+
+ if (cmp)
{
- if (arg == last_side_effecting_arg)
- break;
- TREE_VALUE (arg) = save_expr (TREE_VALUE (arg));
+ cmp = save_expr (build (COMPOUND_EXPR, TREE_TYPE (node), cmp, node));
+ CAN_COMPLETE_NORMALLY (cmp) = CAN_COMPLETE_NORMALLY (node);
+ TREE_SIDE_EFFECTS (cmp) = 1;
+ node = cmp;
}
}
return node;