diff options
author | rms <rms@138bc75d-0d04-0410-961f-82ee72b054a4> | 1992-08-01 18:08:36 +0000 |
---|---|---|
committer | rms <rms@138bc75d-0d04-0410-961f-82ee72b054a4> | 1992-08-01 18:08:36 +0000 |
commit | 87994a83abb356c1ce23a3b12861f6efc1a9b8df (patch) | |
tree | 40e73f0a23fc59f5585a281fd729089ba68d8b9c /gcc | |
parent | dc119b74668f30e2efbc3943a3a569507fcaf077 (diff) | |
download | gcc-87994a83abb356c1ce23a3b12861f6efc1a9b8df.tar.gz |
(layout_record): Take account of
maximum_field_alignment when using the field's alignment.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@1739 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/stor-layout.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index e2202844ced..b2e330324ea 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -327,7 +327,13 @@ layout_record (rec) /* A named bit field of declared type `int' forces the entire structure to have `int' alignment. */ if (DECL_NAME (field) != 0) - record_align = MAX (record_align, TYPE_ALIGN (TREE_TYPE (field))); + { + int type_align = TYPE_ALIGN (TREE_TYPE (field)); + if (maximum_field_alignment != 0) + type_align = MIN (type_align, maximum_field_alignment); + + record_align = MAX (record_align, type_align); + } } else record_align = MAX (record_align, desired_align); @@ -371,8 +377,15 @@ layout_record (rec) register tree dsize = DECL_SIZE (field); int field_size = TREE_INT_CST_LOW (dsize); + if (maximum_field_alignment != 0) + type_align = MIN (type_align, maximum_field_alignment); + /* A bit field may not span the unit of alignment of its type. Advance to next boundary if necessary. */ + /* ??? There is some uncertainty here as to what + should be done if type_align is less than the width of the type. + That can happen because the width exceeds BIGGEST_ALIGNMENT + or because it exceeds maximum_field_alignment. */ if (const_size / type_align != (const_size + field_size - 1) / type_align) const_size = CEIL (const_size, type_align) * type_align; @@ -393,6 +406,9 @@ layout_record (rec) register tree dsize = DECL_SIZE (field); int field_size = TREE_INT_CST_LOW (dsize); + if (maximum_field_alignment != 0) + type_align = MIN (type_align, maximum_field_alignment); + /* A bit field may not span the unit of alignment of its type. Advance to next boundary if necessary. */ if (const_size / type_align |