diff options
author | Jason Merrill <jason@redhat.com> | 2003-10-21 22:14:36 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2003-10-21 22:14:36 -0400 |
commit | 40aae1784298218b225bfe9a237496a0e77acbed (patch) | |
tree | 9731cdb1e2059fbfa58ca96694e42d88548b9735 | |
parent | 18fd68a8b39900352967c54496fc1b394e7c48f2 (diff) | |
download | gcc-40aae1784298218b225bfe9a237496a0e77acbed.zip gcc-40aae1784298218b225bfe9a237496a0e77acbed.tar.gz gcc-40aae1784298218b225bfe9a237496a0e77acbed.tar.bz2 |
stor-layout.c (layout_decl): Do packed field alignment for bit-fields, too.
* stor-layout.c (layout_decl): Do packed field alignment for
bit-fields, too.
From-SVN: r72786
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/stor-layout.c | 33 |
2 files changed, 22 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f123dba..afcd8bc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-10-21 Jason Merrill <jason@redhat.com> + + * stor-layout.c (layout_decl): Do packed field alignment for + bit-fields, too. + 2003-10-21 Eric Christopher <echristo@redhat.com> * expr.c (convert_move): Use FLOAT_EXTEND for extensions. diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index c29c22d..6e128e3 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -397,6 +397,8 @@ layout_decl (tree decl, unsigned int known_align) else /* For fields, it's a bit more complicated... */ { + bool old_user_align = DECL_USER_ALIGN (decl); + if (DECL_BIT_FIELD (decl)) { DECL_BIT_FIELD_TYPE (decl) = type; @@ -454,22 +456,21 @@ layout_decl (tree decl, unsigned int known_align) supercede USER_ALIGN inherited from the type, but defer to alignment explicitly specified on the field decl. */; else - { - do_type_align (type, decl); - - /* If the field is of variable size, we can't misalign it since we - have no way to make a temporary to align the result. But this - isn't an issue if the decl is not addressable. Likewise if it - is of unknown size. - - Note that do_type_align may set DECL_USER_ALIGN, so we don't - want to check it again here. */ - if (DECL_PACKED (decl) - && (DECL_NONADDRESSABLE_P (decl) - || DECL_SIZE_UNIT (decl) == 0 - || TREE_CODE (DECL_SIZE_UNIT (decl)) == INTEGER_CST)) - DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), BITS_PER_UNIT); - } + do_type_align (type, decl); + + /* If the field is of variable size, we can't misalign it since we + have no way to make a temporary to align the result. But this + isn't an issue if the decl is not addressable. Likewise if it + is of unknown size. + + Note that do_type_align may set DECL_USER_ALIGN, so we need to + check old_user_align instead. */ + if (DECL_PACKED (decl) + && !old_user_align + && (DECL_NONADDRESSABLE_P (decl) + || DECL_SIZE_UNIT (decl) == 0 + || TREE_CODE (DECL_SIZE_UNIT (decl)) == INTEGER_CST)) + DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), BITS_PER_UNIT); /* Should this be controlled by DECL_USER_ALIGN, too? */ if (maximum_field_alignment != 0) |