------- Comment #19 from matz at gcc dot gnu dot org 2009-05-06 20:39 ------- Something like this implements option 1. It's probably hopelessly inefficient (always generating a new type for each packed field), and wrong, and generally just a bad idea, but it does fix the testcase, execute.exp still works and bootstrap is already in the target libs :) And it only deals with packed fields, not those having an aligned() attribute.
Index: c-common.c =================================================================== --- c-common.c (Revision 147187) +++ c-common.c (Arbeitskopie) @@ -5813,6 +5813,18 @@ c_init_attributes (void) #undef DEF_ATTR_TREE_LIST } +static tree +get_aligned_type (tree t, int align) +{ + tree ret; + if (TYPE_PACKED (t)) + return t; + ret = build_variant_type_copy (t); + TYPE_ALIGN (ret) = align * BITS_PER_UNIT; + TYPE_USER_ALIGN (ret) = 1; + return ret; +} + /* Attribute handlers common to C front ends. */ /* Handle a "packed" attribute; arguments as in @@ -5837,7 +5849,10 @@ handle_packed_attribute (tree *node, tre "%qE attribute ignored for field of type %qT", name, TREE_TYPE (*node)); else - DECL_PACKED (*node) = 1; + { + DECL_PACKED (*node) = 1; + TREE_TYPE (*node) = get_aligned_type (TREE_TYPE (*node), 1); + } } /* We can't set DECL_PACKED for a VAR_DECL, because the bit is used for DECL_REGISTER. It wouldn't mean anything anyway. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39954