]> gcc.gnu.org Git - gcc.git/commitdiff
re GNATS gcj/129 (Static array length access bug in gcj)
authorAlexandre Petit-Bianco <apbianco@cygnus.com>
Thu, 1 Jun 2000 16:04:14 +0000 (16:04 +0000)
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>
Thu, 1 Jun 2000 16:04:14 +0000 (09:04 -0700)
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

gcc/java/ChangeLog
gcc/java/parse.c
gcc/java/parse.y

index 7bd5521fa85c9871961792653f94781dd267e8ad..fdfc79cf62c8d89f2efe45c1681fe5dc68ea3298 100644 (file)
        `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
index 2f77d7497dbacfe05fe3e1a414d42f56457f2eb2..c7871837132fef209948272fd51f23b472a2f7a2 100644 (file)
@@ -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 */
index 83cd49edfd6ef616a14f40843ca0edccb9a37866..385f913968853881a90ace8103cd81b38f5cd892 100644 (file)
@@ -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 */
This page took 0.108968 seconds and 5 git commands to generate.