aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2007-09-11 11:07:59 -0400
committerJason Merrill <jason@gcc.gnu.org>2007-09-11 11:07:59 -0400
commit7e4aeb3297fc305dc887732c5d03360a7677fba5 (patch)
tree48637fd65b23c6ae1ebddac14a1328f463c9565c /gcc/stor-layout.c
parent257fafe0c91f84ad5dca36dcdf28980d512f1fec (diff)
downloadgcc-7e4aeb3297fc305dc887732c5d03360a7677fba5.zip
gcc-7e4aeb3297fc305dc887732c5d03360a7677fba5.tar.gz
gcc-7e4aeb3297fc305dc887732c5d03360a7677fba5.tar.bz2
re PR middle-end/27945 (Packed struct of variable length has wrong size)
PR middle-end/27945 * stor-layout.c (layout_decl): Do pack variable size fields. From-SVN: r128380
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index ea658a8..f149e68 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -414,18 +414,11 @@ layout_decl (tree decl, unsigned int known_align)
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 need to
- check old_user_align instead. */
+ /* If the field is packed and not explicitly aligned, give it the
+ minimum alignment. Note that do_type_align may set
+ DECL_USER_ALIGN, so we need to check old_user_align instead. */
if (packed_p
- && !old_user_align
- && (DECL_NONADDRESSABLE_P (decl)
- || DECL_SIZE_UNIT (decl) == 0
- || TREE_CODE (DECL_SIZE_UNIT (decl)) == INTEGER_CST))
+ && !old_user_align)
DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), BITS_PER_UNIT);
if (! packed_p && ! DECL_USER_ALIGN (decl))