aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorMike Stump <mrs@wrs.com>1997-10-16 21:45:24 +0000
committerJeff Law <law@gcc.gnu.org>1997-10-16 15:45:24 -0600
commit5c19a35643bd0c7d5a2766a5b91f6b6b4cb7242d (patch)
tree074af1c4450358fa3fca1e255fb9492918cce5f8 /gcc/stor-layout.c
parentbdd7e652f4b7b615e07eef4f83d80fb9ab7425e8 (diff)
downloadgcc-5c19a35643bd0c7d5a2766a5b91f6b6b4cb7242d.zip
gcc-5c19a35643bd0c7d5a2766a5b91f6b6b4cb7242d.tar.gz
gcc-5c19a35643bd0c7d5a2766a5b91f6b6b4cb7242d.tar.bz2
c-decl.c (start_struct): Ensure that structs with forward declarations are in fact packed when...
* 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
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 7c4b4f6..2ccf45e 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -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. */