diff options
author | Tang Ching-Hui <nicholas@cs.nthu.edu.tw> | 2001-12-02 18:44:54 +0800 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2001-12-02 10:44:54 +0000 |
commit | b736dee60789f2353beeda8aed5b980659712c65 (patch) | |
tree | 28bf1e5a9de0c8886fdbcffd97a6273ddb87c033 /gcc/java/expr.c | |
parent | 41543739cd3813a7e593fc4f61b558ecf6cffaf3 (diff) | |
download | gcc-b736dee60789f2353beeda8aed5b980659712c65.zip gcc-b736dee60789f2353beeda8aed5b980659712c65.tar.gz gcc-b736dee60789f2353beeda8aed5b980659712c65.tar.bz2 |
re PR java/3096 (GCJ does not increment)
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.
Co-Authored-By: Alexandre Petit-Bianco <apbianco@redhat.com>
From-SVN: r47525
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r-- | gcc/java/expr.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 182d247..0d3c61d 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; } |