diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2008-05-03 19:35:01 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2008-05-03 19:35:01 +0000 |
commit | 88f36b7eb6a153a914e9b4d678c1ddaddb842747 (patch) | |
tree | 8c9f10498aa285c5cda1ea869b4f8d07d9999b77 /gcc/ada/utils2.c | |
parent | 093daf0fc7ddbde9214ae6cca049bb80fa7d65ab (diff) | |
download | gcc-88f36b7eb6a153a914e9b4d678c1ddaddb842747.zip gcc-88f36b7eb6a153a914e9b4d678c1ddaddb842747.tar.gz gcc-88f36b7eb6a153a914e9b4d678c1ddaddb842747.tar.bz2 |
decl.c (maybe_pad_type): Try to get a form of the type with integral mode even if...
* decl.c (maybe_pad_type): Try to get a form of the type with integral
mode even if the alignment is not a factor of the original size. But
make sure to create the inner field with the original size. Reorder.
* trans.c (addressable_p) <COMPONENT_REF>: Treat the field of a padding
record as always addressable.
* utils.c (convert): Deal specially with conversions between original
and packable versions of a record type.
* utils2.c (build_binary_op) <MODIFY_EXPR>: Be more restrictive when
recognizing an assignment between padded objects.
From-SVN: r134916
Diffstat (limited to 'gcc/ada/utils2.c')
-rw-r--r-- | gcc/ada/utils2.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gcc/ada/utils2.c b/gcc/ada/utils2.c index f2eaf5e..b45c7ac 100644 --- a/gcc/ada/utils2.c +++ b/gcc/ada/utils2.c @@ -693,21 +693,24 @@ build_binary_op (enum tree_code op_code, tree result_type, && TYPE_ALIGN_OK (right_type)) operation_type = right_type; - /* If we are copying between padded objects of the same underlying - type with a non-zero size, use the padded view of the type, this - is very likely more efficient; but gnat_to_gnu will have removed - the padding on the RHS so we have to make sure that we can safely - put it back. */ + /* If we are copying between padded objects with compatible types, use + the padded view of the objects, this is very likely more efficient. + Likewise for a padded that is assigned a constructor, in order to + avoid putting a VIEW_CONVERT_EXPR on the LHS. But don't do this if + we wouldn't have actually copied anything. */ else if (TREE_CODE (left_type) == RECORD_TYPE && TYPE_IS_PADDING_P (left_type) - && TREE_TYPE (TYPE_FIELDS (left_type)) == right_type - && !integer_zerop (TYPE_SIZE (right_type)) + && TREE_CONSTANT (TYPE_SIZE (left_type)) && ((TREE_CODE (right_operand) == COMPONENT_REF && TREE_CODE (TREE_TYPE (TREE_OPERAND (right_operand, 0))) == RECORD_TYPE && TYPE_IS_PADDING_P - (TREE_TYPE (TREE_OPERAND (right_operand, 0)))) - || TREE_CODE (right_operand) == CONSTRUCTOR)) + (TREE_TYPE (TREE_OPERAND (right_operand, 0))) + && gnat_types_compatible_p + (left_type, + TREE_TYPE (TREE_OPERAND (right_operand, 0)))) + || TREE_CODE (right_operand) == CONSTRUCTOR) + && !integer_zerop (TYPE_SIZE (right_type))) operation_type = left_type; /* Find the best type to use for copying between aggregate types. */ |