aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/utils2.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/utils2.c')
-rw-r--r--gcc/ada/utils2.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/ada/utils2.c b/gcc/ada/utils2.c
index 5888bc5..877959d 100644
--- a/gcc/ada/utils2.c
+++ b/gcc/ada/utils2.c
@@ -695,16 +695,19 @@ build_binary_op (enum tree_code op_code, tree result_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. */
+ 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. */
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_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) == 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))
operation_type = left_type;
/* Find the best type to use for copying between aggregate types. */