aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/decl.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2008-05-01 10:50:01 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2008-05-01 10:50:01 +0000
commit8665c7ca50061afae221149f0542d9a4f5329e1c (patch)
tree197d79b77d4a42946b3ee4b0f5c1ebc31ac12343 /gcc/ada/decl.c
parent2de4b3193d2282cce587ff1a6e041cd7cc649657 (diff)
downloadgcc-8665c7ca50061afae221149f0542d9a4f5329e1c.zip
gcc-8665c7ca50061afae221149f0542d9a4f5329e1c.tar.gz
gcc-8665c7ca50061afae221149f0542d9a4f5329e1c.tar.bz2
decl.c (make_packable_type): Resize the last component to its RM size only if it is of an aggregate type.
* decl.c (make_packable_type): Resize the last component to its RM size only if it is of an aggregate type. * trans.c (call_to_gnu): Fix nit in comment. (gnat_to_gnu): Likewise. From-SVN: r134848
Diffstat (limited to 'gcc/ada/decl.c')
-rw-r--r--gcc/ada/decl.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c
index 991faae..8dec1be 100644
--- a/gcc/ada/decl.c
+++ b/gcc/ada/decl.c
@@ -5487,9 +5487,8 @@ make_packable_type (tree type, bool in_record)
TYPE_USER_ALIGN (new_type) = 1;
- /* Now copy the fields, keeping the position and size as we don't
- want to propagate packedness downward. But make an exception
- for the last field in order to ditch the padding bits. */
+ /* Now copy the fields, keeping the position and size as we don't want
+ to change the layout by propagating the packedness downwards. */
for (old_field = TYPE_FIELDS (type); old_field;
old_field = TREE_CHAIN (old_field))
{
@@ -5503,8 +5502,18 @@ make_packable_type (tree type, bool in_record)
&& host_integerp (TYPE_SIZE (new_field_type), 1))
new_field_type = make_packable_type (new_field_type, true);
- if (!TREE_CHAIN (old_field) && !TYPE_PACKED (type))
- new_size = rm_size (new_field_type);
+ /* However, for the last field in a not already packed record type
+ that is of an aggregate type, we need to use the RM_Size in the
+ packable version of the record type, see finish_record_type. */
+ if (!TREE_CHAIN (old_field)
+ && !TYPE_PACKED (type)
+ && (TREE_CODE (new_field_type) == RECORD_TYPE
+ || TREE_CODE (new_field_type) == UNION_TYPE
+ || TREE_CODE (new_field_type) == QUAL_UNION_TYPE)
+ && !TYPE_IS_FAT_POINTER_P (new_field_type)
+ && !TYPE_CONTAINS_TEMPLATE_P (new_field_type)
+ && TYPE_ADA_SIZE (new_field_type))
+ new_size = TYPE_ADA_SIZE (new_field_type);
else
new_size = DECL_SIZE (old_field);