From 8df0611867a09f498ddfaf28f68498a02789a8fc Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Wed, 16 Mar 1994 06:57:14 -0500 Subject: [PATCH] (layout_record): If the place where we were going to put a field changed, lay it out again. From-SVN: r6793 --- gcc/stor-layout.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 8b464a31b9e..3c2fc8fc912 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -309,6 +309,7 @@ layout_record (rec) for (field = TYPE_FIELDS (rec); field; field = TREE_CHAIN (field)) { + register int known_align = var_size ? var_align : const_size; register int desired_align; /* If FIELD is static, then treat it like a separate variable, @@ -328,14 +329,11 @@ layout_record (rec) continue; /* Lay out the field so we know what alignment it needs. - For KNOWN_ALIGN, pass the number of bits from start of record - or some divisor of it. */ - - /* For a packed field, use the alignment as specified, + For a packed field, use the alignment as specified, disregarding what the type would want. */ if (DECL_PACKED (field)) desired_align = DECL_ALIGN (field); - layout_decl (field, var_size ? var_align : const_size); + layout_decl (field, known_align); if (! DECL_PACKED (field)) desired_align = DECL_ALIGN (field); /* Some targets (i.e. VMS) limit struct field alignment @@ -463,7 +461,16 @@ layout_record (rec) else if (var_size) DECL_FIELD_BITPOS (field) = var_size; else - DECL_FIELD_BITPOS (field) = size_int (const_size); + { + DECL_FIELD_BITPOS (field) = size_int (const_size); + + /* If this field ended up more aligned than we thought it + would be (we approximate this by seeing if its position + changed), lay out the field again; perhaps we can use an + integral mode for it now. */ + if (known_align != const_size) + layout_decl (field, const_size); + } /* Now add size of this field to the size of the record. */ -- 2.30.2