OSDN Git Service

* stor-layout.c (do_type_align): New fn, split out from...
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Apr 2003 18:23:04 +0000 (18:23 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Apr 2003 18:23:04 +0000 (18:23 +0000)
        (layout_decl): ...here.  Do all alignment calculations for
        FIELD_DECLs here.
        (update_alignment_for_field): Not here.
        (start_record_layout, debug_rli): Remove unpadded_align.
        * tree.h (struct record_layout_info_s): Remove unpadded_align.
        * c-decl.c (finish_enum): Don't set DECL_SIZE, DECL_ALIGN
        or DECL_MODE on the CONST_DECLs.
        (finish_struct): Don't mess with DECL_ALIGN.
        * cp/class.c (build_vtable): Set DECL_ALIGN here.
        (get_vtable_decl): Not here.
        (layout_vtable_decl): Or here.
        (create_vtable_ptr): Or here.
        (layout_class_type): Or here.
        (check_bitfield_decl): Don't mess with field alignment.
        * ada/misc.c (gnat_adjust_rli): #if 0.

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

gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/misc.c
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/doc/tm.texi
gcc/stor-layout.c
gcc/tree.h

index c62741a..6e155ed 100644 (file)
@@ -1,3 +1,15 @@
+2003-04-03  Jason Merrill  <jason@redhat.com>
+
+       * stor-layout.c (do_type_align): New fn, split out from...
+       (layout_decl): ...here.  Do all alignment calculations for 
+       FIELD_DECLs here.
+       (update_alignment_for_field): Not here.
+       (start_record_layout, debug_rli): Remove unpadded_align.
+       * tree.h (struct record_layout_info_s): Remove unpadded_align.
+       * c-decl.c (finish_enum): Don't set DECL_SIZE, DECL_ALIGN
+       or DECL_MODE on the CONST_DECLs.
+       (finish_struct): Don't mess with DECL_ALIGN.
+
 Thu Apr  3 18:57:19 CEST 2003  Jan Hubicka  <jh@suse.cz>
 
        * i386.c (print_operand): Do not bypass output_addr_const at flag_pic.
index 5e98f50..2b8bf05 100644 (file)
@@ -1,3 +1,7 @@
+2003-04-03  Jason Merrill  <jason@redhat.com>
+
+       * misc.c (gnat_adjust_rli): #if 0.
+
 2003-03-31   Geert Bosch <bosch@gnat.com>
 
        PR ada/10020
@@ -19,8 +23,8 @@
 2003-03-05  Olivier Hainque  <hainque@gnat.com>
 
        ada/9961
-        * raise.c (__gnat_Unwind_RaiseException): Add prototype to avoid
-        warning, and fix return type for the IN_RTS && !SJLJ case.
+       * raise.c (__gnat_Unwind_RaiseException): Add prototype to avoid
+       warning, and fix return type for the IN_RTS && !SJLJ case.
 
 2003-03-04  Tom Tromey  <tromey@redhat.com>
 
index 1da50c3..1a5c9db 100644 (file)
@@ -563,8 +563,11 @@ gnat_expand_expr (exp, target, tmode, modifier)
 
 static void
 gnat_adjust_rli (rli)
-     record_layout_info rli;
+     record_layout_info rli ATTRIBUTE_UNUSED;
 {
+#if 0
+  /* This code seems to have no actual effect; record_align should already
+     reflect the largest alignment desired by a field.  jason 2003-04-01  */
   unsigned int record_align = rli->unpadded_align;
   tree field;
 
@@ -576,6 +579,7 @@ gnat_adjust_rli (rli)
 
   if (TYPE_PACKED (rli->t))
     rli->record_align = record_align;
+#endif
 }
 
 /* Make a TRANSFORM_EXPR to later expand GNAT_NODE into code.  */
index e0354f0..2007308 100644 (file)
@@ -5250,23 +5250,6 @@ finish_struct (t, fieldlist, attributes)
              DECL_SIZE (x) = bitsize_int (width);
              DECL_BIT_FIELD (x) = 1;
              SET_DECL_C_BIT_FIELD (x);
-
-             if (width == 0
-                 && ! (* targetm.ms_bitfield_layout_p) (t))
-               {
-                 /* field size 0 => force desired amount of alignment.  */
-#ifdef EMPTY_FIELD_BOUNDARY
-                 DECL_ALIGN (x) = MAX (DECL_ALIGN (x), EMPTY_FIELD_BOUNDARY);
-#endif
-#ifdef PCC_BITFIELD_TYPE_MATTERS
-                 if (PCC_BITFIELD_TYPE_MATTERS)
-                   {
-                     DECL_ALIGN (x) = MAX (DECL_ALIGN (x),
-                                           TYPE_ALIGN (TREE_TYPE (x)));
-                     DECL_USER_ALIGN (x) |= TYPE_USER_ALIGN (TREE_TYPE (x));
-                   }
-#endif
-               }
            }
        }
 
@@ -5564,11 +5547,6 @@ finish_enum (enumtype, values, attributes)
          tree enu = TREE_PURPOSE (pair);
 
          TREE_TYPE (enu) = enumtype;
-         DECL_SIZE (enu) = TYPE_SIZE (enumtype);
-         DECL_SIZE_UNIT (enu) = TYPE_SIZE_UNIT (enumtype);
-         DECL_ALIGN (enu) = TYPE_ALIGN (enumtype);
-         DECL_USER_ALIGN (enu) = TYPE_USER_ALIGN (enumtype);
-         DECL_MODE (enu) = TYPE_MODE (enumtype);
 
          /* The ISO C Standard mandates enumerators to have type int,
             even though the underlying type of an enum type is
index 8667f01..06109bf 100644 (file)
@@ -1,3 +1,12 @@
+2003-04-03  Jason Merrill  <jason@redhat.com>
+
+       * class.c (build_vtable): Set DECL_ALIGN here.
+       (get_vtable_decl): Not here.
+       (layout_vtable_decl): Or here.
+       (create_vtable_ptr): Or here.
+       (layout_class_type): Or here.
+       (check_bitfield_decl): Don't mess with field alignment.
+
 2003-04-03  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * operators.def (DEF_SIMPLE_OPERATOR, DEF_ASSN_OPERATOR,
index 01d4dd2..e6fad0a 100644 (file)
@@ -531,6 +531,11 @@ build_vtable (tree class_type, tree name, tree vtable_type)
   DECL_VIRTUAL_P (decl) = 1;
   DECL_ALIGN (decl) = TARGET_VTABLE_ENTRY_ALIGN;
 
+  /* At one time the vtable info was grabbed 2 words at a time.  This
+     fails on sparc unless you have 8-byte alignment.  (tiemann) */
+  DECL_ALIGN (decl) = MAX (TYPE_ALIGN (double_type_node),
+                          DECL_ALIGN (decl));
+
   import_export_vtable (decl, class_type, 0);
 
   return decl;
@@ -553,11 +558,6 @@ get_vtable_decl (tree type, int complete)
   decl = build_vtable (type, get_vtable_name (type), vtbl_type_node);
   CLASSTYPE_VTABLES (type) = decl;
 
-  /* At one time the vtable info was grabbed 2 words at a time.  This
-     fails on sparc unless you have 8-byte alignment.  (tiemann) */
-  DECL_ALIGN (decl) = MAX (TYPE_ALIGN (double_type_node),
-                          DECL_ALIGN (decl));
-
   if (complete)
     {
       DECL_EXTERNAL (decl) = 1;
@@ -2017,11 +2017,6 @@ layout_vtable_decl (tree binfo, int n)
       TREE_TYPE (vtable) = atype;
       DECL_SIZE (vtable) = DECL_SIZE_UNIT (vtable) = NULL_TREE;
       layout_decl (vtable, 0);
-
-      /* At one time the vtable info was grabbed 2 words at a time.  This
-        fails on SPARC unless you have 8-byte alignment.  */
-      DECL_ALIGN (vtable) = MAX (TYPE_ALIGN (double_type_node),
-                                DECL_ALIGN (vtable));
     }
 }
 
@@ -2952,31 +2947,12 @@ check_bitfield_decl (tree field)
     {
       DECL_SIZE (field) = convert (bitsizetype, w);
       DECL_BIT_FIELD (field) = 1;
-
-      if (integer_zerop (w)
-         && ! (* targetm.ms_bitfield_layout_p) (DECL_FIELD_CONTEXT (field)))
-       {
-#ifdef EMPTY_FIELD_BOUNDARY
-         DECL_ALIGN (field) = MAX (DECL_ALIGN (field), 
-                                   EMPTY_FIELD_BOUNDARY);
-#endif
-#ifdef PCC_BITFIELD_TYPE_MATTERS
-         if (PCC_BITFIELD_TYPE_MATTERS)
-           {
-             DECL_ALIGN (field) = MAX (DECL_ALIGN (field), 
-                                       TYPE_ALIGN (type));
-             DECL_USER_ALIGN (field) |= TYPE_USER_ALIGN (type);
-           }
-#endif
-       }
     }
   else
     {
       /* Non-bit-fields are aligned for their type.  */
       DECL_BIT_FIELD (field) = 0;
       CLEAR_DECL_C_BIT_FIELD (field);
-      DECL_ALIGN (field) = MAX (DECL_ALIGN (field), TYPE_ALIGN (type));
-      DECL_USER_ALIGN (field) |= TYPE_USER_ALIGN (type);
     }
 }
 
@@ -4428,8 +4404,6 @@ create_vtable_ptr (tree t, tree* virtuals_p)
       DECL_ARTIFICIAL (field) = 1;
       DECL_FIELD_CONTEXT (field) = t;
       DECL_FCONTEXT (field) = t;
-      DECL_ALIGN (field) = TYPE_ALIGN (vtbl_ptr_type_node);
-      DECL_USER_ALIGN (field) = TYPE_USER_ALIGN (vtbl_ptr_type_node);
       
       TYPE_VFIELD (t) = field;
       
@@ -4950,8 +4924,6 @@ layout_class_type (tree t, tree *virtuals_p)
                                      char_type_node); 
          DECL_BIT_FIELD (padding_field) = 1;
          DECL_SIZE (padding_field) = padding;
-         DECL_ALIGN (padding_field) = 1;
-         DECL_USER_ALIGN (padding_field) = 0;
          layout_nonempty_base_or_field (rli, padding_field,
                                         NULL_TREE, 
                                         empty_base_offsets);
index 1723455..9ff8040 100644 (file)
@@ -1160,8 +1160,7 @@ make it all fit in fewer cache lines.
 Alignment in bits to be given to a structure bit-field that follows an
 empty field such as @code{int : 0;}.
 
-Note that @code{PCC_BITFIELD_TYPE_MATTERS} also affects the alignment
-that results from an empty field.
+If @code{PCC_BITFIELD_TYPE_MATTERS} is true, it overrides this macro.
 
 @findex STRUCTURE_SIZE_BOUNDARY
 @item STRUCTURE_SIZE_BOUNDARY
index af02cad..c840481 100644 (file)
@@ -357,6 +357,19 @@ round_down (value, divisor)
   return size_binop (MULT_EXPR, size_binop (FLOOR_DIV_EXPR, value, arg), arg);
 }
 \f
+/* Subroutine of layout_decl: Force alignment required for the data type.
+   But if the decl itself wants greater alignment, don't override that.  */
+
+static inline void
+do_type_align (tree type, tree decl)
+{
+  if (TYPE_ALIGN (type) > DECL_ALIGN (decl))
+    {
+      DECL_ALIGN (decl) = TYPE_ALIGN (type);
+      DECL_USER_ALIGN (decl) = TYPE_USER_ALIGN (type);
+    }
+}
+
 /* Set the size, mode and alignment of a ..._DECL node.
    TYPE_DECL does need this for C++.
    Note that LABEL_DECL and CONST_DECL nodes do not need this,
@@ -411,67 +424,96 @@ layout_decl (decl, known_align)
       = convert (sizetype, size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl),
                                       bitsize_unit_node));
 
-  /* Force alignment required for the data type.
-     But if the decl itself wants greater alignment, don't override that.
-     Likewise, if the decl is packed, don't override it.  */
-  if (! (code == FIELD_DECL && DECL_BIT_FIELD (decl))
-      && (DECL_ALIGN (decl) == 0
-         || (! (code == FIELD_DECL && DECL_PACKED (decl))
-             && TYPE_ALIGN (type) > DECL_ALIGN (decl))))
+  if (code != FIELD_DECL)
+    /* For non-fields, update the alignment from the type.  */
+    do_type_align (type, decl);
+  else
+    /* For fields, it's a bit more complicated...  */
     {
-      DECL_ALIGN (decl) = TYPE_ALIGN (type);
-      DECL_USER_ALIGN (decl) = 0;
-    }
+      if (DECL_BIT_FIELD (decl))
+       {
+         DECL_BIT_FIELD_TYPE (decl) = type;
 
-  /* For fields, set the bit field type and update the alignment.  */
-  if (code == FIELD_DECL)
-    {
-      DECL_BIT_FIELD_TYPE (decl) = DECL_BIT_FIELD (decl) ? type : 0;
-      if (maximum_field_alignment != 0)
-       DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), maximum_field_alignment);
+         /* A zero-length bit-field affects the alignment of the next
+            field.  */
+         if (integer_zerop (DECL_SIZE (decl))
+             && ! DECL_PACKED (decl)
+             && ! (*targetm.ms_bitfield_layout_p) (DECL_FIELD_CONTEXT (decl)))
+           {
+#ifdef PCC_BITFIELD_TYPE_MATTERS
+             if (PCC_BITFIELD_TYPE_MATTERS)
+               do_type_align (type, decl);
+             else
+#endif
+#ifdef EMPTY_FIELD_BOUNDARY
+               if (EMPTY_FIELD_BOUNDARY > DECL_ALIGN (decl))
+                 {
+                   DECL_ALIGN (decl) = EMPTY_FIELD_BOUNDARY;
+                   DECL_USER_ALIGN (decl) = 0;
+                 }
+#endif
+           }
+
+         /* See if we can use an ordinary integer mode for a bit-field.
+            Conditions are: a fixed size that is correct for another mode
+            and occupying a complete byte or bytes on proper boundary.  */
+         if (TYPE_SIZE (type) != 0
+             && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
+             && GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT)
+           {
+             enum machine_mode xmode
+               = mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1);
+
+             if (xmode != BLKmode && known_align >= GET_MODE_ALIGNMENT (xmode))
+               {
+                 DECL_ALIGN (decl) = MAX (GET_MODE_ALIGNMENT (xmode),
+                                          DECL_ALIGN (decl));
+                 DECL_MODE (decl) = xmode;
+                 DECL_BIT_FIELD (decl) = 0;
+               }
+           }
+
+         /* Turn off DECL_BIT_FIELD if we won't need it set.  */
+         if (TYPE_MODE (type) == BLKmode && DECL_MODE (decl) == BLKmode
+             && known_align >= TYPE_ALIGN (type)
+             && DECL_ALIGN (decl) >= TYPE_ALIGN (type))
+           DECL_BIT_FIELD (decl) = 0;
+       }
+      else if (DECL_PACKED (decl) && DECL_USER_ALIGN (decl))
+       /* Don't touch DECL_ALIGN.  For other packed fields, go ahead and
+          round up; we'll reduce it again below.  */;
+      else
+       do_type_align (type, decl);
 
       /* If the field is of variable size, we can't misalign it since we
         have no way to make a temporary to align the result.  But this
         isn't an issue if the decl is not addressable.  Likewise if it
         is of unknown size.  */
-      else if (DECL_PACKED (decl)
-              && (DECL_NONADDRESSABLE_P (decl)
-                  || DECL_SIZE_UNIT (decl) == 0
-                  || TREE_CODE (DECL_SIZE_UNIT (decl)) == INTEGER_CST))
-       {
-         DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), BITS_PER_UNIT);
-         DECL_USER_ALIGN (decl) = 0;
-       }
-    }
-
-  /* See if we can use an ordinary integer mode for a bit-field.
-     Conditions are: a fixed size that is correct for another mode
-     and occupying a complete byte or bytes on proper boundary.  */
-  if (code == FIELD_DECL && DECL_BIT_FIELD (decl)
-      && TYPE_SIZE (type) != 0
-      && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
-      && GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT)
-    {
-      enum machine_mode xmode
-       = mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1);
-
-      if (xmode != BLKmode && known_align >= GET_MODE_ALIGNMENT (xmode))
+      if (DECL_PACKED (decl)
+         && !DECL_USER_ALIGN (decl)
+         && (DECL_NONADDRESSABLE_P (decl)
+             || DECL_SIZE_UNIT (decl) == 0
+             || TREE_CODE (DECL_SIZE_UNIT (decl)) == INTEGER_CST))
+       DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), BITS_PER_UNIT);
+
+      /* Should this be controlled by DECL_USER_ALIGN, too?  */
+      if (maximum_field_alignment != 0)
+       DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), maximum_field_alignment);
+      if (! DECL_USER_ALIGN (decl))
        {
-         DECL_ALIGN (decl) = MAX (GET_MODE_ALIGNMENT (xmode),
-                                  DECL_ALIGN (decl));
-         DECL_MODE (decl) = xmode;
-         DECL_BIT_FIELD (decl) = 0;
+         /* Some targets (i.e. i386, VMS) limit struct field alignment
+            to a lower boundary than alignment of variables unless
+            it was overridden by attribute aligned.  */
+#ifdef BIGGEST_FIELD_ALIGNMENT
+         DECL_ALIGN (decl)
+           = MIN (DECL_ALIGN (decl), (unsigned) BIGGEST_FIELD_ALIGNMENT);
+#endif
+#ifdef ADJUST_FIELD_ALIGN
+         DECL_ALIGN (decl) = ADJUST_FIELD_ALIGN (decl, DECL_ALIGN (decl));
+#endif
        }
     }
 
-  /* Turn off DECL_BIT_FIELD if we won't need it set.  */
-  if (code == FIELD_DECL && DECL_BIT_FIELD (decl)
-      && TYPE_MODE (type) == BLKmode && DECL_MODE (decl) == BLKmode
-      && known_align >= TYPE_ALIGN (type)
-      && DECL_ALIGN (decl) >= TYPE_ALIGN (type)
-      && DECL_SIZE_UNIT (decl) != 0)
-    DECL_BIT_FIELD (decl) = 0;
-
   /* Evaluate nonconstant size only once, either now or as soon as safe.  */
   if (DECL_SIZE (decl) != 0 && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
     DECL_SIZE (decl) = variable_size (DECL_SIZE (decl));
@@ -532,7 +574,7 @@ start_record_layout (t)
      declaration, for example) use it -- otherwise, start with a
      one-byte alignment.  */
   rli->record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (t));
-  rli->unpacked_align = rli->unpadded_align = rli->record_align;
+  rli->unpacked_align = rli->record_align;
   rli->offset_align = MAX (rli->record_align, BIGGEST_ALIGNMENT);
 
 #ifdef STRUCTURE_SIZE_BOUNDARY
@@ -621,8 +663,8 @@ debug_rli (rli)
   print_node_brief (stderr, "\noffset", rli->offset, 0);
   print_node_brief (stderr, " bitpos", rli->bitpos, 0);
 
-  fprintf (stderr, "\naligns: rec = %u, unpack = %u, unpad = %u, off = %u\n",
-          rli->record_align, rli->unpacked_align, rli->unpadded_align,
+  fprintf (stderr, "\naligns: rec = %u, unpack = %u, off = %u\n",
+          rli->record_align, rli->unpacked_align,
           rli->offset_align);
   if (rli->packed_maybe_necessary)
     fprintf (stderr, "packed may be necessary\n");
@@ -679,40 +721,21 @@ update_alignment_for_field (rli, field, known_align)
   tree type = TREE_TYPE (field);
   /* True if the field was explicitly aligned by the user.  */
   bool user_align;
+  bool is_bitfield;
 
-  /* Lay out the field so we know what alignment it needs.  For a
-     packed field, use the alignment as specified, disregarding what
-     the type would want.  */
+  /* Lay out the field so we know what alignment it needs.  */
+  layout_decl (field, known_align);
   desired_align = DECL_ALIGN (field);
   user_align = DECL_USER_ALIGN (field);
-  layout_decl (field, known_align);
-  if (! DECL_PACKED (field))
-    {
-      desired_align = DECL_ALIGN (field);
-      user_align = DECL_USER_ALIGN (field);
-    }
-
-  /* Some targets (i.e. i386, VMS) limit struct field alignment
-     to a lower boundary than alignment of variables unless
-     it was overridden by attribute aligned.  */
-#ifdef BIGGEST_FIELD_ALIGNMENT
-  if (!user_align)
-    desired_align
-      = MIN (desired_align, (unsigned) BIGGEST_FIELD_ALIGNMENT);
-#endif
 
-#ifdef ADJUST_FIELD_ALIGN
-  if (!user_align)
-    desired_align = ADJUST_FIELD_ALIGN (field, desired_align);
-#endif
+  is_bitfield = (type != error_mark_node
+                && DECL_BIT_FIELD_TYPE (field)
+                && ! integer_zerop (TYPE_SIZE (type)));
 
   /* Record must have at least as much alignment as any field.
      Otherwise, the alignment of the field within the record is
      meaningless.  */
-  if ((* targetm.ms_bitfield_layout_p) (rli->t)
-      && type != error_mark_node
-      && DECL_BIT_FIELD_TYPE (field)
-      && ! integer_zerop (TYPE_SIZE (type)))
+  if (is_bitfield && (* targetm.ms_bitfield_layout_p) (rli->t))
     {
       /* Here, the alignment of the underlying type of a bitfield can
         affect the alignment of a record; even a zero-sized field
@@ -732,29 +755,11 @@ update_alignment_for_field (rli, field, known_align)
            type_align = MIN (type_align, maximum_field_alignment);
          rli->record_align = MAX (rli->record_align, type_align);
          rli->unpacked_align = MAX (rli->unpacked_align, TYPE_ALIGN (type));
-         rli->unpadded_align = MAX (rli->unpadded_align, DECL_ALIGN (field));
        }
-      else
-       desired_align = 1;
     }
-  else
 #ifdef PCC_BITFIELD_TYPE_MATTERS
-  if (PCC_BITFIELD_TYPE_MATTERS && type != error_mark_node
-      && ! (* targetm.ms_bitfield_layout_p) (rli->t)
-      && DECL_BIT_FIELD_TYPE (field)
-      && ! integer_zerop (TYPE_SIZE (type)))
+  else if (is_bitfield && PCC_BITFIELD_TYPE_MATTERS)
     {
-      /* A zero-length bit-field affects the alignment of the next
-        field.  */
-      if (!DECL_PACKED (field) && !user_align
-         && integer_zerop (DECL_SIZE (field)))
-       {
-         desired_align = TYPE_ALIGN (type);
-#ifdef ADJUST_FIELD_ALIGN
-         desired_align = ADJUST_FIELD_ALIGN (field, desired_align);
-#endif
-       }
-
       /* Named bit-fields cause the entire structure to have the
         alignment implied by their type.  */
       if (DECL_NAME (field) != 0)
@@ -779,18 +784,16 @@ update_alignment_for_field (rli, field, known_align)
          rli->record_align = MAX (rli->record_align, desired_align);
          rli->record_align = MAX (rli->record_align, type_align);
 
-         rli->unpadded_align = MAX (rli->unpadded_align, DECL_ALIGN (field));
          if (warn_packed)
            rli->unpacked_align = MAX (rli->unpacked_align, TYPE_ALIGN (type));
          user_align |= TYPE_USER_ALIGN (type);
        }
     }
-  else
 #endif
+  else
     {
       rli->record_align = MAX (rli->record_align, desired_align);
       rli->unpacked_align = MAX (rli->unpacked_align, TYPE_ALIGN (type));
-      rli->unpadded_align = MAX (rli->unpadded_align, DECL_ALIGN (field));
     }
 
   TYPE_USER_ALIGN (rli->t) |= user_align;
@@ -905,7 +908,7 @@ place_field (rli, field)
 
   if (warn_packed && DECL_PACKED (field))
     {
-      if (known_align > TYPE_ALIGN (type))
+      if (known_align >= TYPE_ALIGN (type))
        {
          if (TYPE_ALIGN (type) > desired_align)
            {
index d15cce8..12352d8 100644 (file)
@@ -2452,11 +2452,9 @@ typedef struct record_layout_info_s
   tree bitpos;
   /* The alignment of the record so far, in bits.  */
   unsigned int record_align;
-  /* The alignment of the record so far, not including padding, in bits.  */
+  /* The alignment of the record so far, ignoring #pragma pack and
+     __attribute__ ((packed)), in bits.  */
   unsigned int unpacked_align;
-  /* The alignment of the record so far, allowing for the record to be
-     padded only at the end, in bits.  */
-  unsigned int unpadded_align;
   /* The previous field layed out.  */
   tree prev_field;
   /* The static variables (i.e., class variables, as opposed to
@@ -2464,6 +2462,8 @@ typedef struct record_layout_info_s
   tree pending_statics;
   /* Bits remaining in the current alignment group */
   int remaining_in_alignment;
+  /* True if we've seen a packed field that didn't have normal
+     alignment anyway.  */
   int packed_maybe_necessary;
 } *record_layout_info;