Commit c67e6e14 by Roger Sayle Committed by Roger Sayle

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
parent edaf3e03
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);
}
......
......@@ -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;
......
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>
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment