OSDN Git Service

Fix for PRs gcj/312 and gcj/253:
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Dec 2000 21:15:52 +0000 (21:15 +0000)
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Dec 2000 21:15:52 +0000 (21:15 +0000)
* parse.y (valid_ref_assignconv_cast_p): Load classes for source and
dest if they arn't already.
* class.c (layout_class): Call maybe_layout_super_class on
superinterfaces also, but only if compiling from bytecode.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38363 138bc75d-0d04-0410-961f-82ee72b054a4

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

index af55e5b..0f71e7f 100644 (file)
@@ -1,3 +1,11 @@
+2000-12-17  Bryce McKinlay  <bryce@albatross.co.nz>
+
+       Fix for PRs gcj/312 and gcj/253:
+       * parse.y (valid_ref_assignconv_cast_p): Load classes for source and
+       dest if they arn't already.
+       * class.c (layout_class): Call maybe_layout_super_class on 
+       superinterfaces also, but only if compiling from bytecode.
+
 2000-12-15  Tom Tromey  <tromey@redhat.com>
 
        * jcf-parse.c (jcf_parse_source): Set wfl_operator if not already
index 00cf42e..92dd0b9 100644 (file)
@@ -1841,6 +1841,35 @@ layout_class (this_class)
 
   layout_type (this_class);
 
+  /* Also recursively load/layout any superinterfaces, but only if class was
+  loaded from bytecode. The source parser will take care of this itself. */
+  if (!CLASS_FROM_SOURCE_P (this_class))
+    {
+      tree basetype_vec = TYPE_BINFO_BASETYPES (this_class);
+
+      if (basetype_vec)
+       {
+         int n = TREE_VEC_LENGTH (basetype_vec) - 1;
+         int i;
+         for (i = n; i > 0; i--)
+           {
+             tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
+             tree super_interface = BINFO_TYPE (vec_elt);
+
+             tree maybe_super_interface 
+               = maybe_layout_super_class (super_interface, NULL_TREE);
+             if (maybe_super_interface == NULL
+                 || TREE_CODE (TYPE_SIZE (maybe_super_interface)) == ERROR_MARK)
+               {
+                 TYPE_SIZE (this_class) = error_mark_node;
+                 CLASS_BEING_LAIDOUT (this_class) = 0;
+                 list = TREE_CHAIN (list);
+                 return;
+               }
+           }
+       }
+    }
+
   /* Convert the size back to an SI integer value */
   TYPE_SIZE_UNIT (this_class) = 
     fold (convert (int_type_node, TYPE_SIZE_UNIT (this_class)));
index 7a23e72..ec09a49 100644 (file)
@@ -12778,6 +12778,20 @@ valid_ref_assignconv_cast_p (source, dest, cast)
     source = TREE_TYPE (source);
   if (TREE_CODE (dest) == POINTER_TYPE)
     dest = TREE_TYPE (dest);
+
+  /* If source and dest are being compiled from bytecode, they may need to
+     be loaded. */
+  if (CLASS_P (source) && !CLASS_LOADED_P (source))
+    {
+      load_class (source, 1);
+      safe_layout_class (source);
+    }
+  if (CLASS_P (dest) && !CLASS_LOADED_P (dest))
+    {
+      load_class (dest, 1);
+      safe_layout_class (dest);
+    }
+
   /* Case where SOURCE is a class type */
   if (TYPE_CLASS_P (source))
     {