Commit 8665c7ca by Eric Botcazou Committed by Eric Botcazou

decl.c (make_packable_type): Resize the last component to its RM size only if it…

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
parent 2de4b319
2008-05-01 Eric Botcazou <ebotcazou@adacore.com>
* 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.
2008-04-30 Samuel Tardieu <sam@rfc1149.net> 2008-04-30 Samuel Tardieu <sam@rfc1149.net>
* Makefile.in: Adapt sh4-linux target. * Makefile.in: Adapt sh4-linux target.
...@@ -5487,9 +5487,8 @@ make_packable_type (tree type, bool in_record) ...@@ -5487,9 +5487,8 @@ make_packable_type (tree type, bool in_record)
TYPE_USER_ALIGN (new_type) = 1; TYPE_USER_ALIGN (new_type) = 1;
/* Now copy the fields, keeping the position and size as we don't /* Now copy the fields, keeping the position and size as we don't want
want to propagate packedness downward. But make an exception to change the layout by propagating the packedness downwards. */
for the last field in order to ditch the padding bits. */
for (old_field = TYPE_FIELDS (type); old_field; for (old_field = TYPE_FIELDS (type); old_field;
old_field = TREE_CHAIN (old_field)) old_field = TREE_CHAIN (old_field))
{ {
...@@ -5503,8 +5502,18 @@ make_packable_type (tree type, bool in_record) ...@@ -5503,8 +5502,18 @@ make_packable_type (tree type, bool in_record)
&& host_integerp (TYPE_SIZE (new_field_type), 1)) && host_integerp (TYPE_SIZE (new_field_type), 1))
new_field_type = make_packable_type (new_field_type, true); new_field_type = make_packable_type (new_field_type, true);
if (!TREE_CHAIN (old_field) && !TYPE_PACKED (type)) /* However, for the last field in a not already packed record type
new_size = rm_size (new_field_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 else
new_size = DECL_SIZE (old_field); new_size = DECL_SIZE (old_field);
......
...@@ -2204,7 +2204,7 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target) ...@@ -2204,7 +2204,7 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target)
of the object if they are distinct, because the expectations of the object if they are distinct, because the expectations
of the callee would otherwise not be met: of the callee would otherwise not be met:
- if it's a justified modular type, - if it's a justified modular type,
- if the actual type is a packed version of it. */ - if the actual type is a packable version of it. */
else if (TREE_CODE (gnu_name_type) == RECORD_TYPE else if (TREE_CODE (gnu_name_type) == RECORD_TYPE
&& (TYPE_JUSTIFIED_MODULAR_P (gnu_name_type) && (TYPE_JUSTIFIED_MODULAR_P (gnu_name_type)
|| larger_record_type_p (gnu_name_type, || larger_record_type_p (gnu_name_type,
...@@ -4902,7 +4902,7 @@ gnat_to_gnu (Node_Id gnat_node) ...@@ -4902,7 +4902,7 @@ gnat_to_gnu (Node_Id gnat_node)
type wrong due to "instantiating" the unconstrained record with type wrong due to "instantiating" the unconstrained record with
discriminant values. Similarly, if the two types are record types discriminant values. Similarly, if the two types are record types
with the same name don't convert. This will be the case when we are with the same name don't convert. This will be the case when we are
converting from a packed version of a type to its original type and converting from a packable version of a type to its original type and
we need those conversions to be NOPs in order for assignments into we need those conversions to be NOPs in order for assignments into
these types to work properly. these types to work properly.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment