summaryrefslogtreecommitdiff
path: root/gcc/java/expr.c
diff options
context:
space:
mode:
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-02 10:44:54 +0000
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-02 10:44:54 +0000
commit77e103b2d7ad086a7cb5425f8f599aee533d47d2 (patch)
tree28bf1e5a9de0c8886fdbcffd97a6273ddb87c033 /gcc/java/expr.c
parent36198b2324f290ecc06f8789f0ffe8bc1d2f0399 (diff)
downloadgcc-77e103b2d7ad086a7cb5425f8f599aee533d47d2.tar.gz
2001-12-02 Tang Ching-Hui <nicholas@cs.nthu.edu.tw>
Alexandre Petit-Bianco <apbianco@redhat.com> * expr.c: call save_expr on array for correct evaluation order, modified comment, fixed indentation. * parse.y: (patch_assignment): Correctly extract the array base from the tree generate by build_java_arrayaccess, added comments. (patch_array_ref): Remove SAVE_EXPR on ARRAY_REF. Fixes PR java/3096, PR java/3803, PR java/3965. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47525 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r--gcc/java/expr.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 182d247f890..0d3c61d169a 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -798,14 +798,21 @@ build_java_arrayaccess (array, type, index)
TREE_SIDE_EFFECTS( throw ) = 1;
}
}
-
+
+ /* The SAVE_EXPR is for correct evaluation order. It would be
+ cleaner to use force_evaluation_order (see comment there), but
+ that is difficult when we also have to deal with bounds
+ checking. The SAVE_EXPR is not necessary to do that when we're
+ not checking for array bounds. */
+ if (TREE_SIDE_EFFECTS (index) && throw)
+ throw = build (COMPOUND_EXPR, int_type_node, save_expr (array), throw);
+
node = build1 (INDIRECT_REF, type,
fold (build (PLUS_EXPR, ptr_type_node,
- java_check_reference (array, flag_check_references),
+ java_check_reference (array,
+ flag_check_references),
(throw ? build (COMPOUND_EXPR, int_type_node,
- throw, arith )
- : arith))));
-
+ throw, arith ) : arith))));
return node;
}