diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1994-03-16 06:57:14 -0500 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1994-03-16 06:57:14 -0500 |
commit | 8df0611867a09f498ddfaf28f68498a02789a8fc (patch) | |
tree | 2a969ea751b39ac9dd008ad1e8385052017eb8ce /gcc | |
parent | 6e5bea54683e79892a7ee623583a71612eda6341 (diff) | |
download | gcc-8df0611867a09f498ddfaf28f68498a02789a8fc.zip gcc-8df0611867a09f498ddfaf28f68498a02789a8fc.tar.gz gcc-8df0611867a09f498ddfaf28f68498a02789a8fc.tar.bz2 |
(layout_record): If the place where we were going to put a field
changed, lay it out again.
From-SVN: r6793
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/stor-layout.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 8b464a3..3c2fc8f 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. */ |