diff options
author | Alexandre Petit-Bianco <apbianco@cygnus.com> | 2000-06-01 16:04:14 +0000 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2000-06-01 09:04:14 -0700 |
commit | 611a4b873e1fbd6fc2b4a28c05924660a0b5c2af (patch) | |
tree | d6324832e0824ac9082b28a39a44e90b8c742472 /gcc | |
parent | 079b71f5ab1535ac920e4bd4182480f2a89f933d (diff) | |
download | gcc-611a4b873e1fbd6fc2b4a28c05924660a0b5c2af.zip gcc-611a4b873e1fbd6fc2b4a28c05924660a0b5c2af.tar.gz gcc-611a4b873e1fbd6fc2b4a28c05924660a0b5c2af.tar.bz2 |
re GNATS gcj/129 (Static array length access bug in gcj)
2000-05-02 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (resolve_field_access): Call the appropriate <clinit>
before accessing the length of a static array. Craft a decl for
the field while its time.
(Fixes the PR #129:
http://sourceware.cygnus.com/ml/java-prs/2000-q1/msg00013.html)
From-SVN: r34340
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/java/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/java/parse.c | 12 | ||||
-rw-r--r-- | gcc/java/parse.y | 12 |
3 files changed, 30 insertions, 0 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 7bd5521..fdfc79c 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -34,6 +34,12 @@ `wfl_operator', to maybe_build_primttype_type_ref. Fixes PR gcj/235. +2000-05-02 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (resolve_field_access): Call the appropriate <clinit> + before accessing the length of a static array. Craft a decl for + the field while its time. Fixes PR gcj/129. + 2000-05-01 Alexandre Petit-Bianco <apbianco@cygnus.com> * parse.y (resolve_package): Correctly set `*next' (was off by diff --git a/gcc/java/parse.c b/gcc/java/parse.c index 2f77d74..c787183 100644 --- a/gcc/java/parse.c +++ b/gcc/java/parse.c @@ -11348,6 +11348,18 @@ resolve_field_access (qual_wfl, field_decl, field_type) tree length = build_java_array_length_access (where_found); field_ref = build_java_arraynull_check (type_found, length, int_type_node); + + /* In case we're dealing with a static array, we need to + initialize its class before the array length can be fetched. + It's also a good time to create a DECL_RTL for the field if + none already exists, otherwise if the field was declared in a + class found in an external file and hasn't been (and won't + be) accessed for its value, none will be created. */ + if (TREE_CODE (where_found) == VAR_DECL && FIELD_STATIC (where_found)) + { + build_static_field_ref (where_found); + field_ref = build_class_init (DECL_CONTEXT (where_found), field_ref); + } } /* We might have been trying to resolve field.method(). In which case, the resolution is over and decl is the answer */ diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 83cd49e..385f913 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -8650,6 +8650,18 @@ resolve_field_access (qual_wfl, field_decl, field_type) tree length = build_java_array_length_access (where_found); field_ref = build_java_arraynull_check (type_found, length, int_type_node); + + /* In case we're dealing with a static array, we need to + initialize its class before the array length can be fetched. + It's also a good time to create a DECL_RTL for the field if + none already exists, otherwise if the field was declared in a + class found in an external file and hasn't been (and won't + be) accessed for its value, none will be created. */ + if (TREE_CODE (where_found) == VAR_DECL && FIELD_STATIC (where_found)) + { + build_static_field_ref (where_found); + field_ref = build_class_init (DECL_CONTEXT (where_found), field_ref); + } } /* We might have been trying to resolve field.method(). In which case, the resolution is over and decl is the answer */ |