diff options
author | Tom Tromey <tromey@redhat.com> | 2001-06-10 18:45:06 +0000 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2001-06-10 11:45:06 -0700 |
commit | 7abecd65aecbc749b0e7f0c5603e5efdab325329 (patch) | |
tree | ce1093577a4b6abfd4fdfb26bd79660d9374a086 /gcc/java | |
parent | 21a6bb3c452ae6e24c3cc5e346ccbb866f5f6d04 (diff) | |
download | gcc-7abecd65aecbc749b0e7f0c5603e5efdab325329.zip gcc-7abecd65aecbc749b0e7f0c5603e5efdab325329.tar.gz gcc-7abecd65aecbc749b0e7f0c5603e5efdab325329.tar.bz2 |
re PR java/2299 (Use of += for String arrays produces Segfault during compilation)
2001-03-20 Tom Tromey <tromey@redhat.com>
Alexandre Petit-Bianco <apbianco@redhat.com>
* parse.y (patch_assignment): Handle the case of a SAVE_EXPR
inside an array reference. Insertion of the array store check
rewritten. Fixes PR java/2299.
(http://gcc.gnu.org/ml/gcc-patches/2001-06/msg00611.html )
Co-Authored-By: Alexandre Petit-Bianco <apbianco@redhat.com>
From-SVN: r43146
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/java/parse.y | 46 |
2 files changed, 39 insertions, 14 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 8093e65..f55ad6c 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -475,6 +475,13 @@ too early to lay innerclasses out. 2001-03-20 Tom Tromey <tromey@redhat.com> + Alexandre Petit-Bianco <apbianco@redhat.com> + + * parse.y (patch_assignment): Handle the case of a SAVE_EXPR + inside an array reference. Insertion of the array store check + rewritten. Fixes PR java/2299. + +2001-03-20 Tom Tromey <tromey@redhat.com> * lex.c (java_read_unicode): Only accept leading `u's. diff --git a/gcc/java/parse.y b/gcc/java/parse.y index e766479..2ea7af0 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -12568,12 +12568,15 @@ patch_assignment (node, wfl_op1, wfl_op2) base = TREE_OPERAND (lvalue, 0); else { - base = TREE_OPERAND (base, 0); - if (flag_bounds_check) - base = TREE_OPERAND (base, 1); - if (flag_check_references) - base = TREE_OPERAND (base, 1); - base = TREE_OPERAND (base, 0); + tree op = TREE_OPERAND (base, 0); + + /* We can have a SAVE_EXPR here when doing String +=. */ + if (TREE_CODE (op) == SAVE_EXPR) + op = TREE_OPERAND (op, 0); + if (flag_bounds_check) + base = TREE_OPERAND (TREE_OPERAND (op, 1), 0); + else + base = TREE_OPERAND (op, 0); } /* Build the invocation of _Jv_CheckArrayStore */ @@ -12599,16 +12602,31 @@ patch_assignment (node, wfl_op1, wfl_op2) TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type, check, TREE_OPERAND (lvalue, 1)); } - else + else if (flag_bounds_check) { + tree hook = lvalue; + tree compound = TREE_OPERAND (lvalue, 0); + tree bound_check, new_compound; + + if (TREE_CODE (compound) == SAVE_EXPR) + { + compound = TREE_OPERAND (compound, 0); + hook = TREE_OPERAND (hook, 0); + } + + /* Find the array bound check, hook the original array access. */ + bound_check = TREE_OPERAND (compound, 0); + TREE_OPERAND (hook, 0) = TREE_OPERAND (compound, 1); + /* Make sure the bound check will happen before the store check */ - if (flag_bounds_check) - TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) = - build (COMPOUND_EXPR, void_type_node, - TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check); - else - lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue); - } + new_compound = + build (COMPOUND_EXPR, void_type_node, bound_check, check); + + /* Re-assemble the augmented array access. */ + lvalue = build (COMPOUND_EXPR, lhs_type, new_compound, lvalue); + } + else + lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue); } /* Final locals can be used as case values in switch |