stor-layout.c (finalize_type_size): Restore behaviour for non-aggregate types to...
authorJ"orn Rennecke <joern.rennecke@st.com>
Fri, 26 Aug 2005 17:17:05 +0000 (17:17 +0000)
committerJoern Rennecke <amylaar@gcc.gnu.org>
Fri, 26 Aug 2005 17:17:05 +0000 (18:17 +0100)
* stor-layout.c (finalize_type_size): Restore behaviour for
non-aggregate types to the status quo ante of the patch for
pr 23467.  Document why it matters.

From-SVN: r103527

gcc/ChangeLog
gcc/stor-layout.c

index 5c55b1d99db5ae15933a433c28362e7011feae3f..8d90f9c0a59b5cd5970e880c342e4afa23620883 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-26  J"orn Rennecke <joern.rennecke@st.com>
+
+       * stor-layout.c (finalize_type_size): Restore behaviour for
+       non-aggregate types to the status quo ante of the patch for
+       pr 23467.  Document why it matters.
+
 2005-08-26  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/23506
index 0ec818d7fbd26f5d23d1d8c98d450bd0710bbdbb..810585585678655359a6014e3ec4cf01df06c3a3 100644 (file)
@@ -1399,23 +1399,23 @@ finalize_type_size (tree type)
   /* Normally, use the alignment corresponding to the mode chosen.
      However, where strict alignment is not required, avoid
      over-aligning structures, since most compilers do not do this
-     alignment.  */
+     alignment.  Also, we must avoid overriding a larger alignment
+     requirement coming from a user alignment of one of the fields.  */
+  /* ??? The non-aggregate code is also needed to reduce the alignment
+     of java types with alignment less than 16 bits.  The problem stems
+     from java/decl.c using char_type_node for the 16 bit character type,
+     while tree.c:make_node uses it as the type of the smallest addressable
+     unit to initialize the alignment of all types.  */
+  unsigned mode_align = GET_MODE_ALIGNMENT (TYPE_MODE (type));
 
   if (TYPE_MODE (type) != BLKmode && TYPE_MODE (type) != VOIDmode
-      && (STRICT_ALIGNMENT
+      && ((STRICT_ALIGNMENT && mode_align >= TYPE_ALIGN (type))
          || (TREE_CODE (type) != RECORD_TYPE && TREE_CODE (type) != UNION_TYPE
              && TREE_CODE (type) != QUAL_UNION_TYPE
              && TREE_CODE (type) != ARRAY_TYPE)))
     {
-      unsigned mode_align = GET_MODE_ALIGNMENT (TYPE_MODE (type));
-
-      /* Don't override a larger alignment requirement coming from a user
-        alignment of one of the fields.  */
-      if (mode_align >= TYPE_ALIGN (type))
-       {
-         TYPE_ALIGN (type) = mode_align;
-         TYPE_USER_ALIGN (type) = 0;
-       }
+      TYPE_ALIGN (type) = mode_align;
+      TYPE_USER_ALIGN (type) = 0;
     }
 
   /* Do machine-dependent extra alignment.  */