diff options
author | Mark Mitchell <mark@codesourcery.com> | 2002-12-23 16:39:36 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2002-12-23 16:39:36 +0000 |
commit | 8dc65b6e6d423750c05dbe4e241556febf84dcca (patch) | |
tree | 159cad292d86d5201b0631ba807629fb2759076d /gcc/stor-layout.c | |
parent | 7c02ae17fed20316d9790f679903b274f6abe77d (diff) | |
download | gcc-8dc65b6e6d423750c05dbe4e241556febf84dcca.zip gcc-8dc65b6e6d423750c05dbe4e241556febf84dcca.tar.gz gcc-8dc65b6e6d423750c05dbe4e241556febf84dcca.tar.bz2 |
stor-layout.c (update_alignment_for_field): Correct handling of unnamed bitfields on PCC_BITFIELD_TYPE_MATTERS machines.
* stor-layout.c (update_alignment_for_field): Correct handling of
unnamed bitfields on PCC_BITFIELD_TYPE_MATTERS machines.
* doc/tm.texi (PCC_BITFIELD_TYPE_MATTERS): Note that an unnamed
bitfield does not affect alignment.
* testsuite/gcc.dg/i386-bitfield3.c: New test.
From-SVN: r60439
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index c4fdaee..6c81924 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -715,13 +715,9 @@ update_alignment_for_field (rli, field, known_align) && DECL_BIT_FIELD_TYPE (field) && ! integer_zerop (TYPE_SIZE (type))) { - /* For these machines, a zero-length field does not - affect the alignment of the structure as a whole. - It does, however, affect the alignment of the next field - within the structure. */ - if (! integer_zerop (DECL_SIZE (field))) - rli->record_align = MAX (rli->record_align, desired_align); - else if (! DECL_PACKED (field)) + /* A zero-length bit-field affects the alignment of the next + field. */ + if (!DECL_PACKED (field) && integer_zerop (DECL_SIZE (field))) { desired_align = TYPE_ALIGN (type); #ifdef ADJUST_FIELD_ALIGN @@ -729,8 +725,8 @@ update_alignment_for_field (rli, field, known_align) #endif } - /* A named bit field of declared type `int' - forces the entire structure to have `int' alignment. */ + /* Named bit-fields cause the entire structure to have the + alignment implied by their type. */ if (DECL_NAME (field) != 0) { unsigned int type_align = TYPE_ALIGN (type); @@ -745,7 +741,14 @@ update_alignment_for_field (rli, field, known_align) else if (DECL_PACKED (field)) type_align = MIN (type_align, BITS_PER_UNIT); + /* The alignment of the record is increased to the maximum + of the current alignment, the alignment indicated on the + field (i.e., the alignment specified by an __aligned__ + attribute), and the alignment indicated by the type of + the field. */ + rli->record_align = MAX (rli->record_align, desired_align); rli->record_align = MAX (rli->record_align, type_align); + rli->unpadded_align = MAX (rli->unpadded_align, DECL_ALIGN (field)); if (warn_packed) rli->unpacked_align = MAX (rli->unpacked_align, TYPE_ALIGN (type)); |