From 2cd36c22d3d16e24f342829a989ac35f2f442656 Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Fri, 23 Jan 2009 06:29:54 +0000 Subject: c-decl.c (finish_struct): Move code to set DECL_PACKED after DECL_BIT_FIELD is alreay known. * 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. From-SVN: r143584 --- gcc/c-decl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gcc/c-decl.c') diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 7f7f2b0..6ebee1a 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5564,9 +5564,6 @@ finish_struct (tree t, tree fieldlist, tree attributes) DECL_CONTEXT (x) = t; - if (TYPE_PACKED (t) && TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT) - DECL_PACKED (x) = 1; - /* If any field is const, the structure type is pseudo-const. */ if (TREE_READONLY (x)) C_TYPE_FIELDS_READONLY (t) = 1; @@ -5598,6 +5595,11 @@ finish_struct (tree t, tree fieldlist, tree attributes) SET_DECL_C_BIT_FIELD (x); } + if (TYPE_PACKED (t) + && (DECL_BIT_FIELD (x) + || TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT)) + DECL_PACKED (x) = 1; + /* Detect flexible array member in an invalid context. */ if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE && TYPE_SIZE (TREE_TYPE (x)) == NULL_TREE -- cgit v1.1