]> gcc.gnu.org Git - gcc.git/commitdiff
typeck.c (build_java_array_type): Rewrite code to do array alignment.
authorAndrew Haley <aph@cygnus.com>
Tue, 29 Aug 2000 22:15:21 +0000 (22:15 +0000)
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>
Tue, 29 Aug 2000 22:15:21 +0000 (15:15 -0700)
2000-08-16  Andrew Haley  <aph@cygnus.com>

* typeck.c (build_java_array_type): Rewrite code to do array
alignment.  Take into account back-end macros when aligning array
data.  Remove setting of TYPE_USER_ALIGN; Java doesn't allow the
user to set alignment. Fixes gcj/252 and 160.

(This fixes gcj/252 and 160:
 http://sources.redhat.com/ml/java-prs/2000-q2/msg00254.html
 <couldn't find an archive entry for gcj/160>
 http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00907.html)

From-SVN: r36057

gcc/java/ChangeLog
gcc/java/typeck.c

index 4dfa874e472ca38a2da1830a3a6fb9e49f799cbe..754112a606b448376e3f9605f472dec68a6df3ef 100644 (file)
        * lang-specs.h: Do not process -o or run the assembler if
        -fsyntax-only.
 
+2000-08-16  Andrew Haley  <aph@cygnus.com>
+
+       * typeck.c (build_java_array_type): Rewrite code to do array
+       alignment.  Take into account back-end macros when aligning array
+       data.  Remove setting of TYPE_USER_ALIGN; Java doesn't allow the
+       user to set alignment. Fixes gcj/252 and 160.
+
 2000-08-09  Tom Tromey  <tromey@cygnus.com>
 
        * parse.y (check_abstract_method_definitions): Now return `int'.
index 1a7256d64820cc443498a5ae1b0760f8ab27d232..990ff066db7dc5fe315321093314911624dfb15a 100644 (file)
@@ -417,13 +417,34 @@ build_java_array_type (element_type, length)
     {
       tree atype = build_prim_array_type (element_type, length);
       tree arfld = build_decl (FIELD_DECL, get_identifier ("data"), atype);
+      
       DECL_CONTEXT (arfld) = t;
       TREE_CHAIN (fld) = arfld;
+
+      /* We need to force the data field to begin at an alignment at
+       least equal to the biggest alignment in an object type node
+       in order to be compatible with the way that JArray is defined
+       in CNI.  However, we can't exceed BIGGEST_FIELD_ALIGNMENT. */
+      {
+      unsigned desired_align = TYPE_ALIGN (object_type_node);
+      desired_align = MAX (desired_align, TYPE_ALIGN (element_type));
+#ifdef BIGGEST_FIELD_ALIGNMENT
+      desired_align = MIN (desired_align, 
+                           (unsigned) BIGGEST_FIELD_ALIGNMENT);
+#endif
+#ifdef ADJUST_FIELD_ALIGN
+      desired_align = ADJUST_FIELD_ALIGN (field, desired_align);
+#endif
+      DECL_ALIGN (arfld) = desired_align;
+      }
     }
   else
     {
-      TYPE_ALIGN (t) = TYPE_ALIGN (element_type);
-      TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (element_type);
+      unsigned desired_align = TYPE_ALIGN (element_type);
+#ifdef BIGGEST_FIELD_ALIGNMENT
+      desired_align = MIN (desired_align, (unsigned) BIGGEST_FIELD_ALIGNMENT);
+#endif
+      TYPE_ALIGN (t) = desired_align;
     }
   pop_obstacks ();
 
This page took 0.080225 seconds and 5 git commands to generate.