From e871a8730ae8bd2a50a47a6c87691078e2e7fff6 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sun, 20 Apr 2008 10:32:55 +0000 Subject: decl.c (gnat_to_gnu_entity): Also promote the alignment of constant objects, but not exceptions. * decl.c (gnat_to_gnu_entity) : Also promote the alignment of constant objects, but not exceptions. * trans.c (add_decl_expr): Use gnat_types_compatible_p for type compatibility test. * utils.c (create_var_decl_1): Likewise. * utils2.c (build_binary_op) : Also use the padded view of the type when copying to padded object and the source is a constructor. From-SVN: r134483 --- gcc/ada/decl.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'gcc/ada/decl.c') diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c index 9d4412d..e60b443 100644 --- a/gcc/ada/decl.c +++ b/gcc/ada/decl.c @@ -673,18 +673,21 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) && !Present (Address_Clause (gnat_entity))) gnu_size = bitsize_unit_node; - /* If this is an object with no specified size and alignment, and if - either it is atomic or we are not optimizing alignment for space - and it is a non-scalar variable, and the size of its type is a - constant, set the alignment to the smallest not less than the - size, or to the biggest meaningful one, whichever is smaller. */ + /* If this is an object with no specified size and alignment, and + if either it is atomic or we are not optimizing alignment for + space and it is composite and not an exception, an Out parameter + or a reference to another object, and the size of its type is a + constant, set the alignment to the smallest one which is not + smaller than the size, with an appropriate cap. */ if (!gnu_size && align == 0 && (Is_Atomic (gnat_entity) || (!Optimize_Alignment_Space (gnat_entity) - && kind == E_Variable - && AGGREGATE_TYPE_P (gnu_type) - && !const_flag && No (Renamed_Object (gnat_entity)) - && !imported_p && No (Address_Clause (gnat_entity)))) + && kind != E_Exception + && kind != E_Out_Parameter + && Is_Composite_Type (Etype (gnat_entity)) + && !imported_p + && No (Renamed_Object (gnat_entity)) + && No (Address_Clause (gnat_entity)))) && TREE_CODE (TYPE_SIZE (gnu_type)) == INTEGER_CST) { /* No point in jumping through all the hoops needed in order -- cgit v1.1