]> gcc.gnu.org Git - gcc.git/commitdiff
c-decl.c (start_struct): Ensure that structs with forward declarations are in fact...
authorMike Stump <mrs@wrs.com>
Thu, 16 Oct 1997 21:45:24 +0000 (21:45 +0000)
committerJeff Law <law@gcc.gnu.org>
Thu, 16 Oct 1997 21:45:24 +0000 (15:45 -0600)
        * c-decl.c (start_struct): Ensure that structs with forward
        declarations are in fact packed when -fpack-struct is given.

        * stor-layout.c (layout_record): Ignore STRUCTURE_SIZE_BOUNDARY if
        we are packing a structure.  This allows a structure with only
        bytes to be aligned on a byte boundary and have no padding on a
        m68k.

From-SVN: r15939

gcc/ChangeLog
gcc/c-decl.c
gcc/stor-layout.c

index 065b3ddef3381f220b860d51c49539455e5e308a..32a32398db6552c23a20870f91acbbfcacc69e14 100644 (file)
@@ -1,3 +1,13 @@
+Thu Oct 16 15:43:26 1997  Mike Stump  (mrs@wrs.com)
+
+       * c-decl.c (start_struct): Ensure that structs with forward
+       declarations are in fact packed when -fpack-struct is given.
+
+       * stor-layout.c (layout_record): Ignore STRUCTURE_SIZE_BOUNDARY if
+       we are packing a structure.  This allows a structure with only
+       bytes to be aligned on a byte boundary and have no padding on a
+       m68k.
+
 Thu Oct 16 15:17:54 1997  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
        * rs6000.h (ROUND_TYPE_ALIGN): Don't blow up if no fields in record.
index 5774f755b032c5ed56b625d19d2876bc8413183e..e38cdb15a89a3caa3d596a7ec57bf797b493bff8 100644 (file)
@@ -5529,6 +5529,7 @@ start_struct (code, name)
   if (ref && TREE_CODE (ref) == code)
     {
       C_TYPE_BEING_DEFINED (ref) = 1;
+      TYPE_PACKED (ref) = flag_pack_struct;
       if (TYPE_FIELDS (ref))
        error ((code == UNION_TYPE ? "redefinition of `union %s'"
                : "redefinition of `struct %s'"),
index 7c4b4f69c7ce93cbd57f474248e54db67c014442..2ccf45ee1f4cf21a12804b000f39a2369f96fba3 100644 (file)
@@ -306,11 +306,7 @@ layout_record (rec)
      tree rec;
 {
   register tree field;
-#ifdef STRUCTURE_SIZE_BOUNDARY
-  unsigned record_align = MAX (STRUCTURE_SIZE_BOUNDARY, TYPE_ALIGN (rec));
-#else
   unsigned record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (rec));
-#endif
   /* These must be laid out *after* the record is.  */
   tree pending_statics = NULL_TREE;
   /* Record size so far is CONST_SIZE + VAR_SIZE bits,
@@ -324,6 +320,11 @@ layout_record (rec)
      that we know VAR_SIZE has.  */
   register int var_align = BITS_PER_UNIT;
 
+#ifdef STRUCTURE_SIZE_BOUNDARY
+  /* Packed structures don't need to have minimum size.  */
+  if (! TYPE_PACKED (rec))
+    record_align = MAX (record_align, STRUCTURE_SIZE_BOUNDARY);
+#endif
 
   for (field = TYPE_FIELDS (rec); field; field = TREE_CHAIN (field))
     {
@@ -563,11 +564,7 @@ layout_union (rec)
      tree rec;
 {
   register tree field;
-#ifdef STRUCTURE_SIZE_BOUNDARY
-  unsigned union_align = STRUCTURE_SIZE_BOUNDARY;
-#else
   unsigned union_align = BITS_PER_UNIT;
-#endif
 
   /* The size of the union, based on the fields scanned so far,
      is max (CONST_SIZE, VAR_SIZE).
@@ -575,6 +572,12 @@ layout_union (rec)
   register int const_size = 0;
   register tree var_size = 0;
 
+#ifdef STRUCTURE_SIZE_BOUNDARY
+  /* Packed structures don't need to have minimum size.  */
+  if (! TYPE_PACKED (rec))
+    union_align = STRUCTURE_SIZE_BOUNDARY;
+#endif
+
   /* If this is a QUAL_UNION_TYPE, we want to process the fields in
      the reverse order in building the COND_EXPR that denotes its
      size.  We reverse them again later.  */
This page took 0.076411 seconds and 5 git commands to generate.