This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix 21166
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 29 Jun 2005 10:27:35 +0100
- Subject: Re: Fix 21166
- References: <4270A58A.3010704@codesourcery.com> <20050428224019.GC6294@redhat.com> <42721B5C.3000502@codesourcery.com> <20050429191025.GB9936@redhat.com> <4273AF72.6060500@codesourcery.com> <20050501035432.GB27933@redhat.com> <4280C4ED.4090307@codesourcery.com> <20050510175011.GA20349@redhat.com>
Richard Henderson wrote:
On Tue, May 10, 2005 at 03:27:57PM +0100, Nathan Sidwell wrote:
+ /* We might be able to clear DECL_PACKED on any members that happen
+ to be suitably aligned (not forgetting the alignment of the type
+ itself). */
+ for (field = TYPE_FIELDS (rli->t); field; field = TREE_CHAIN (field))
+ if (TREE_CODE (field) == FIELD_DECL && DECL_PACKED (field)
+ && DECL_OFFSET_ALIGN (field) >= TYPE_ALIGN (TREE_TYPE (field))
+ && TYPE_ALIGN (rli->t) >= TYPE_ALIGN (TREE_TYPE (field)))
+ DECL_PACKED (field) = 0;
Any reason not to do this in layout_decl where we handle the other
aspects of overalignment? Seems to me that the known_align argument
can be used just like you want.
when we're laying out the field_decl of one field we won't know if a later field
forces the struct to have a larger alignment.
struct X {
int __attribute__((packed)) a;
int b;
};
we'd want to set X::a as unpacked here.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk