aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/expr.c4
-rw-r--r--gcc/flags.h3
-rw-r--r--gcc/java/ChangeLog8
-rw-r--r--gcc/java/expr.c15
-rw-r--r--gcc/java/lang.c3
-rw-r--r--gcc/java/parse.y2
-rw-r--r--gcc/toplev.c3
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.
diff --git a/gcc/expr.c b/gcc/expr.c
index 6ad93c5..26eaab0 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -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;