aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils2.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2012-05-06 10:41:03 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2012-05-06 10:41:03 +0000
commit842d4ee2add5d9bc624857c3545d27f70e2fd37b (patch)
tree2b6e941a54364ab5cb9615c2ee43302a788c946f /gcc/ada/gcc-interface/utils2.c
parent6295740973a67863a7a941c8d3f83d92b117abbc (diff)
downloadgcc-842d4ee2add5d9bc624857c3545d27f70e2fd37b.zip
gcc-842d4ee2add5d9bc624857c3545d27f70e2fd37b.tar.gz
gcc-842d4ee2add5d9bc624857c3545d27f70e2fd37b.tar.bz2
gigi.h (make_packable_type): Declare.
* gcc-interface/gigi.h (make_packable_type): Declare. (make_type_from_size): Likewise. (relate_alias_sets): Likewise. (maybe_pad_type): Adjust. (init_gnat_to_gnu): Delete. (destroy_gnat_to_gnu): Likewise. (init_dummy_type): Likewise. (destroy_dummy_type): Likewise. (init_gnat_utils): Declare. (destroy_gnat_utils): Likewise. (ceil_pow2): New inline function. * gcc-interface/decl.c (gnat_to_gnu_entity): Use ceil_pow2. <object>: Pass True for the final processing of alignment and size. <E_Subprogram_Type>: Only create the TYPE_DECL for a padded return type if necessary. (round_up_to_align): Delete. (ceil_alignment): Likewise. (relate_alias_sets): Move to... (make_aligning_type): Likewise. (make_packable_type): Likewise. (maybe_pad_type): Likewise. (make_type_from_size): Likewise. * gcc-interface/utils.c (MAX_BITS_PER_WORD): Delete. (struct pad_type_hash): New type. (pad_type_hash_table): New static variable. (init_gnat_to_gnu): Merge into... (init_dummy_type): Likewise. (init_gnat_utils): ...this. New function. (destroy_gnat_to_gnu): Merge into... (destroy_dummy_type): Likewise. (destroy_gnat_utils): ...this. New function. (pad_type_hash_marked_p): New function. (pad_type_hash_hash): Likewise. (pad_type_hash_eq): Likewise. (relate_alias_sets): ...here. (make_aligning_type): Likewise. (make_packable_type): Likewise. (maybe_pad_type): Likewise. Change same_rm_size parameter into set_rm_size; do not set TYPE_ADA_SIZE if it is false. Do not set null as Ada size. Do not set TYPE_VOLATILE on the padded type. If it is complete and has constant size, canonicalize it. Bail out earlier if a warning need not be issued. (make_type_from_size): Likewise. <INTEGER_TYPE>: Bail out if size is too large (gnat_types_compatible_p): Do not deal with padded types. (convert): Compare main variants for padded types. * gcc-interface/trans.c (gigi): Call {init|destroy}_gnat_utils. (gnat_to_gnu): Do not convert at the end for a call to a function that returns an unconstrained type with default discriminant. (Attribute_to_gnu) <Attr_Size>: Simplify handling of padded objects. * gcc-interface/utils2.c (build_binary_op) <MODIFY_EXPR>: Likewise. Do not use the padded type if it is BLKmode and the inner type is non-BLKmode. From-SVN: r187206
Diffstat (limited to 'gcc/ada/gcc-interface/utils2.c')
-rw-r--r--gcc/ada/gcc-interface/utils2.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index d0769f7..e104b4f 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -789,16 +789,28 @@ build_binary_op (enum tree_code op_code, tree result_type,
else if (TYPE_IS_PADDING_P (left_type)
&& TREE_CONSTANT (TYPE_SIZE (left_type))
&& ((TREE_CODE (right_operand) == COMPONENT_REF
- && TYPE_IS_PADDING_P
- (TREE_TYPE (TREE_OPERAND (right_operand, 0)))
- && gnat_types_compatible_p
- (left_type,
- TREE_TYPE (TREE_OPERAND (right_operand, 0))))
+ && TYPE_MAIN_VARIANT (left_type)
+ == TYPE_MAIN_VARIANT
+ (TREE_TYPE (TREE_OPERAND (right_operand, 0))))
|| (TREE_CODE (right_operand) == CONSTRUCTOR
&& !CONTAINS_PLACEHOLDER_P
(DECL_SIZE (TYPE_FIELDS (left_type)))))
&& !integer_zerop (TYPE_SIZE (right_type)))
- operation_type = left_type;
+ {
+ /* We make an exception for a BLKmode type padding a non-BLKmode
+ inner type and do the conversion of the LHS right away, since
+ unchecked_convert wouldn't do it properly. */
+ if (TYPE_MODE (left_type) == BLKmode
+ && TYPE_MODE (right_type) != BLKmode
+ && TREE_CODE (right_operand) != CONSTRUCTOR)
+ {
+ operation_type = right_type;
+ left_operand = convert (operation_type, left_operand);
+ left_type = operation_type;
+ }
+ else
+ operation_type = left_type;
+ }
/* If we have a call to a function that returns an unconstrained type
with default discriminant on the RHS, use the RHS type (which is