diff options
author | nemet <nemet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-01-23 06:29:54 +0000 |
---|---|---|
committer | nemet <nemet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-01-23 06:29:54 +0000 |
commit | 9fd767c5fd2774e0fc922e1497326dc6ce3fe4a5 (patch) | |
tree | f2ccff5eab03e65287a19a85ac3f6e9c2d8e320d /gcc/stor-layout.c | |
parent | 5a88eb87265ab500347a22f3969195246d5f5358 (diff) | |
download | gcc-9fd767c5fd2774e0fc922e1497326dc6ce3fe4a5.tar.gz |
* c-decl.c (finish_struct): Move code to set DECL_PACKED after
DECL_BIT_FIELD is alreay known. Also inherit packed for bitfields
regardless of their type.
* c-common.c (handle_packed_attribute): Don't ignore packed on
bitfields.
* c.opt (Wpacked-bitfield-compat): New warning option.
* stor-layout.c (place_field): Warn if offset of a field changed.
* doc/extend.texi (packed): Mention the ABI change.
* doc/invoke.texi (-Wpacked-bitfield-compat): Document.
(Warning Options): Add it to the list.
cp/
* class.c (check_field_decls): Also inherit packed for bitfields
regardless of their type.
testsuite/
* gcc.dg/bitfld-15.c, gcc.dg/bitfld-16.c,
gcc.dg/bitfld-17.c,gcc.dg/bitfld-18.c: New tests.
* g++.dg/ext/bitfield2.C, g++.dg/ext/bitfield3.C,
g++.dg/ext/bitfield4.C, g++.dg/ext/bitfield5.C: New tests.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143584 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 0e7caa5450b..bf896dbed37 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -937,7 +937,9 @@ place_field (record_layout_info rli, tree field) && TREE_CODE (field) == FIELD_DECL && type != error_mark_node && DECL_BIT_FIELD (field) - && ! DECL_PACKED (field) + && (! DECL_PACKED (field) + /* Enter for these packed fields only to issue a warning. */ + || TYPE_ALIGN (type) <= BITS_PER_UNIT) && maximum_field_alignment == 0 && ! integer_zerop (DECL_SIZE (field)) && host_integerp (DECL_SIZE (field), 1) @@ -958,9 +960,21 @@ place_field (record_layout_info rli, tree field) /* A bit field may not span more units of alignment of its type than its type itself. Advance to next boundary if necessary. */ if (excess_unit_span (offset, bit_offset, field_size, type_align, type)) - rli->bitpos = round_up (rli->bitpos, type_align); + { + if (DECL_PACKED (field)) + { + if (warn_packed_bitfield_compat) + inform + (input_location, + "Offset of packed bit-field %qD has changed in GCC 4.4", + field); + } + else + rli->bitpos = round_up (rli->bitpos, type_align); + } - TYPE_USER_ALIGN (rli->t) |= TYPE_USER_ALIGN (type); + if (! DECL_PACKED (field)) + TYPE_USER_ALIGN (rli->t) |= TYPE_USER_ALIGN (type); } #endif |