summaryrefslogtreecommitdiff
path: root/gcc/ada/decl.c
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-08 11:41:59 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-08 11:41:59 +0000
commitff62539a329f6aa42e291c0b3a1743cdfacdb206 (patch)
treee039d18b7e69f9b896b96ec52a36f7115dac70fc /gcc/ada/decl.c
parentb840e60da9ce337f527e2971c422db0ee6460408 (diff)
downloadgcc-ff62539a329f6aa42e291c0b3a1743cdfacdb206.tar.gz
* decl.c (gnat_to_gnu_entity) <object>: If -gnatd.a and not optimizing
alignment for space, promote the alignment of non-scalar variables with no size and alignment. * gigi.h (gnat_types_compatible_p): Declare. * misc.c (LANG_HOOKS_TYPES_COMPATIBLE_P): Set to above predicate. * trans.c (gnat_to_gnu): Revert revision 129339 change. Minor cleanup. * utils.c (gnat_types_compatible_p) : New predicate. (convert): Use it throughout to test for cases where a mere view conversion is sufficient. * utils2.c (build_binary_op): Minor tweaks. (build_unary_op): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134092 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/decl.c')
-rw-r--r--gcc/ada/decl.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c
index 2d4742dd06b..bc5d4283053 100644
--- a/gcc/ada/decl.c
+++ b/gcc/ada/decl.c
@@ -672,19 +672,42 @@ 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 atomic object with no specified size and alignment,
- but where the size of the type is a constant, set the alignment to
- the smallest not less than the size, or to the biggest meaningful
- alignment, whichever is smaller. */
- if (Is_Atomic (gnat_entity) && !gnu_size && align == 0
+ /* 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 (!gnu_size && align == 0
+ && (Is_Atomic (gnat_entity)
+ || (Debug_Flag_Dot_A
+ && !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))))
&& TREE_CODE (TYPE_SIZE (gnu_type)) == INTEGER_CST)
{
+ /* No point in jumping through all the hoops needed in order
+ to support BIGGEST_ALIGNMENT if we don't really have to. */
+ unsigned int align_cap = Is_Atomic (gnat_entity)
+ ? BIGGEST_ALIGNMENT
+ : MAX_FIXED_MODE_SIZE;
+
if (!host_integerp (TYPE_SIZE (gnu_type), 1)
- || 0 <= compare_tree_int (TYPE_SIZE (gnu_type),
- BIGGEST_ALIGNMENT))
- align = BIGGEST_ALIGNMENT;
+ || compare_tree_int (TYPE_SIZE (gnu_type), align_cap) >= 0)
+ align = align_cap;
else
align = ceil_alignment (tree_low_cst (TYPE_SIZE (gnu_type), 1));
+
+ /* But make sure not to under-align the object. */
+ if (align < TYPE_ALIGN (gnu_type))
+ align = TYPE_ALIGN (gnu_type);
+
+ /* And honor the minimum valid atomic alignment, if any. */
+#ifdef MINIMUM_ATOMIC_ALIGNMENT
+ if (align < MINIMUM_ATOMIC_ALIGNMENT)
+ align = MINIMUM_ATOMIC_ALIGNMENT;
+#endif
}
/* If the object is set to have atomic components, find the component