aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>2001-12-29 21:00:51 +0000
committerRichard Kenner <kenner@gcc.gnu.org>2001-12-29 16:00:51 -0500
commit6790d1bd90d6d41631034507a42a42d04f1d4003 (patch)
tree9eff696e051cd33a2392999d77a89728d2cec952 /gcc/stor-layout.c
parentf11c3043051e421744ea3d5d3b32c9149fbacf4e (diff)
downloadgcc-6790d1bd90d6d41631034507a42a42d04f1d4003.zip
gcc-6790d1bd90d6d41631034507a42a42d04f1d4003.tar.gz
gcc-6790d1bd90d6d41631034507a42a42d04f1d4003.tar.bz2
stor-layout.c (layout_decl): Don't misalign field of variable size for packed record.
* stor-layout.c (layout_decl): Don't misalign field of variable size for packed record. From-SVN: r48384
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index f657463..fe9ed2c 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -389,7 +389,15 @@ layout_decl (decl, known_align)
DECL_BIT_FIELD_TYPE (decl) = DECL_BIT_FIELD (decl) ? type : 0;
if (maximum_field_alignment != 0)
DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), maximum_field_alignment);
- else if (DECL_PACKED (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. */
+ else 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);
DECL_USER_ALIGN (decl) = 0;