diff options
author | Roger Sayle <roger@eyesopen.com> | 2003-09-28 04:56:35 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2003-09-28 04:56:35 +0000 |
commit | c67e6e1492b2e8cedf8a95731ee788dc919984be (patch) | |
tree | 59d5e4829907404d9cd123482f4ad1565deac1eb | |
parent | edaf3e0357bbc16c01ff9f341016a1e6969a617d (diff) | |
download | gcc-c67e6e1492b2e8cedf8a95731ee788dc919984be.zip gcc-c67e6e1492b2e8cedf8a95731ee788dc919984be.tar.gz gcc-c67e6e1492b2e8cedf8a95731ee788dc919984be.tar.bz2 |
toplev.c (flag_evaluation_order): New global variable.
* toplev.c (flag_evaluation_order): New global variable.
* flags.h (flag_evaluation_order): Prototype here.
* expr.c (expand_operands): If we need to preserve observable
evaluation order, protect exp1 from clobbering exp0's result.
* java/lang.c (java_init_options): Set flag_evaluation_order.
* java/expr.c (force_evaluation_order): Don't attempt to force
evaluation order of binary operations using save_expr.
* java/parse.y (java_complete_lhs): No longer need to call
force_evaluation_order when constructing binary operators.
From-SVN: r71873
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/expr.c | 4 | ||||
-rw-r--r-- | gcc/flags.h | 3 | ||||
-rw-r--r-- | gcc/java/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/java/expr.c | 15 | ||||
-rw-r--r-- | gcc/java/lang.c | 3 | ||||
-rw-r--r-- | gcc/java/parse.y | 2 | ||||
-rw-r--r-- | gcc/toplev.c | 3 |
8 files changed, 34 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4b1a9bf..dccdbdab 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2003-09-27 Roger Sayle <roger@eyesopen.com> + + * toplev.c (flag_evaluation_order): New global variable. + * flags.h (flag_evaluation_order): Prototype here. + * expr.c (expand_operands): If we need to preserve observable + evaluation order, protect exp1 from clobbering exp0's result. + 2003-09-28 Andreas Jaeger <aj@suse.de> * c-decl.c (finish_function): Convert definition to ISO C90. @@ -6553,6 +6553,10 @@ expand_operands (tree exp0, tree exp1, rtx target, rtx *op0, rtx *op1, } else { + /* If we need to preserve evaluation order, copy exp0 into its own + temporary variable so that it can't be clobbered by exp1. */ + if (flag_evaluation_order && TREE_SIDE_EFFECTS (exp1)) + exp0 = save_expr (exp0); *op0 = expand_expr (exp0, target, VOIDmode, modifier); *op1 = expand_expr (exp1, NULL_RTX, VOIDmode, modifier); } diff --git a/gcc/flags.h b/gcc/flags.h index 823aaef..4d6ea07 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -604,6 +604,9 @@ extern int flag_trapv; /* Nonzero if the signed arithmetic overflow should wrap around. */ extern int flag_wrapv; +/* Nonzero if subexpressions must be evaluated from left-to-right. */ +extern int flag_evaluation_order; + /* Value of the -G xx switch, and whether it was passed or not. */ extern unsigned HOST_WIDE_INT g_switch_value; extern bool g_switch_set; diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index a79d73a..514c097 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,11 @@ +2003-09-27 Roger Sayle <roger@eyesopen.com> + + * lang.c (java_init_options): Set flag_evaluation_order. + * expr.c (force_evaluation_order): Don't attempt to force + evaluation order of binary operations using save_expr. + * parse.y (java_complete_lhs): No longer need to call + force_evaluation_order when constructing binary operators. + 2003-09-27 Alexandre Petit-Bianco <apbianco@redhat.com> Bryce McKinlay <bryce@mckinlay.net.nz> diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 803c2de..272cb35 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -3324,16 +3324,11 @@ force_evaluation_order (tree node) { if (flag_syntax_only) return node; - if (TREE_CODE_CLASS (TREE_CODE (node)) == '2') - { - if (TREE_SIDE_EFFECTS (TREE_OPERAND (node, 1))) - TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0)); - } - else if (TREE_CODE (node) == CALL_EXPR - || TREE_CODE (node) == NEW_CLASS_EXPR - || (TREE_CODE (node) == COMPOUND_EXPR - && TREE_CODE (TREE_OPERAND (node, 0)) == CALL_EXPR - && TREE_CODE (TREE_OPERAND (node, 1)) == SAVE_EXPR)) + if (TREE_CODE (node) == CALL_EXPR + || TREE_CODE (node) == NEW_CLASS_EXPR + || (TREE_CODE (node) == COMPOUND_EXPR + && TREE_CODE (TREE_OPERAND (node, 0)) == CALL_EXPR + && TREE_CODE (TREE_OPERAND (node, 1)) == SAVE_EXPR)) { tree arg, cmp; diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 5ade4c0..a3ed327 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -685,6 +685,9 @@ java_init_options (unsigned int argc ATTRIBUTE_UNUSED, /* In Java arithmetic overflow always wraps around. */ flag_wrapv = 1; + /* Java requires left-to-right evaluation of subexpressions. */ + flag_evaluation_order = 1; + jcf_path_init (); return CL_Java; diff --git a/gcc/java/parse.y b/gcc/java/parse.y index e409719..ebcf680 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -12265,7 +12265,7 @@ java_complete_lhs (tree node) TREE_OPERAND (node, 1) = nn; } - return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2)); + return patch_binop (node, wfl_op1, wfl_op2); case INSTANCEOF_EXPR: wfl_op1 = TREE_OPERAND (node, 0); diff --git a/gcc/toplev.c b/gcc/toplev.c index 03485bc..425a0259 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -988,6 +988,9 @@ int flag_trapv = 0; /* Nonzero if signed arithmetic overflow should wrap around. */ int flag_wrapv = 0; +/* Nonzero if subexpressions must be evaluated from left-to-right. */ +int flag_evaluation_order = 0; + /* Add or remove a leading underscore from user symbols. */ int flag_leading_underscore = -1; |