Commit 884523df by Bryce McKinlay Committed by Bryce McKinlay

parse.y (patch_assignment): Wrap the right-hand-side with a save_expr to prevent…

parse.y (patch_assignment): Wrap the right-hand-side with a save_expr to prevent it getting evaluated twice...

	* parse.y (patch_assignment): Wrap the right-hand-side with a save_expr
	to prevent it getting evaluated twice in the store checking case.
	* expr.c (build_java_arraystore_check): Unwrap SAVE_EXPR's when
	examining OBJECT.

From-SVN: r50570
parent 3fcaac1d
2002-03-11 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* parse.y (patch_assignment): Wrap the right-hand-side with a save_expr
to prevent it getting evaluated twice in the store checking case.
* expr.c (build_java_arraystore_check): Unwrap SAVE_EXPR's when
examining OBJECT.
2002-03-09 Bryce McKinlay <bryce@waitaki.otago.ac.nz> 2002-03-09 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* decl.c (java_init_decl_processing): Make sure class_type_node * decl.c (java_init_decl_processing): Make sure class_type_node
......
...@@ -811,7 +811,7 @@ build_java_arraystore_check (array, object) ...@@ -811,7 +811,7 @@ build_java_arraystore_check (array, object)
tree array; tree array;
tree object; tree object;
{ {
tree check, element_type; tree check, element_type, source;
tree array_type_p = TREE_TYPE (array); tree array_type_p = TREE_TYPE (array);
tree object_type = TYPE_NAME (TREE_TYPE (TREE_TYPE (object))); tree object_type = TYPE_NAME (TREE_TYPE (TREE_TYPE (object)));
...@@ -837,11 +837,17 @@ build_java_arraystore_check (array, object) ...@@ -837,11 +837,17 @@ build_java_arraystore_check (array, object)
|| CLASS_FINAL (element_type))) || CLASS_FINAL (element_type)))
return build1 (NOP_EXPR, array_type_p, array); return build1 (NOP_EXPR, array_type_p, array);
/* OBJECT might be wrapped by a SAVE_EXPR. */
if (TREE_CODE (object) == SAVE_EXPR)
source = TREE_OPERAND (object, 0);
else
source = object;
/* Avoid the check if OBJECT was just loaded from the same array. */ /* Avoid the check if OBJECT was just loaded from the same array. */
if (TREE_CODE (object) == ARRAY_REF) if (TREE_CODE (source) == ARRAY_REF)
{ {
tree target; tree target;
tree source = TREE_OPERAND (object, 0); /* COMPONENT_REF. */ source = TREE_OPERAND (source, 0); /* COMPONENT_REF. */
source = TREE_OPERAND (source, 0); /* INDIRECT_REF. */ source = TREE_OPERAND (source, 0); /* INDIRECT_REF. */
source = TREE_OPERAND (source, 0); /* Source array's DECL or SAVE_EXPR. */ source = TREE_OPERAND (source, 0); /* Source array's DECL or SAVE_EXPR. */
if (TREE_CODE (source) == SAVE_EXPR) if (TREE_CODE (source) == SAVE_EXPR)
......
...@@ -12715,6 +12715,9 @@ patch_assignment (node, wfl_op1) ...@@ -12715,6 +12715,9 @@ patch_assignment (node, wfl_op1)
&& JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type))) && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
{ {
tree array, store_check, base, index_expr; tree array, store_check, base, index_expr;
/* Save RHS so that it doesn't get re-evaluated by the store check. */
new_rhs = save_expr (new_rhs);
/* Get the INDIRECT_REF. */ /* Get the INDIRECT_REF. */
array = TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0); array = TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0);
......
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