aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2009-04-24 07:01:41 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2009-04-24 07:01:41 +0000
commit0d858698b6741132801b03c09901c56cd78e5083 (patch)
tree8a3bba04fcb19049af005796d22718b58a268485 /gcc/ada/gcc-interface/decl.c
parent6216f94e37db8de5a846c5945f4aa5f4e32aaedf (diff)
downloadgcc-0d858698b6741132801b03c09901c56cd78e5083.zip
gcc-0d858698b6741132801b03c09901c56cd78e5083.tar.gz
gcc-0d858698b6741132801b03c09901c56cd78e5083.tar.bz2
decl.c (gnat_to_gnu_entity): If an alignment is specified, do not promote that of the component type beyond it.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: If an alignment is specified, do not promote that of the component type beyond it. <E_Array_Subtype>: Likewise. From-SVN: r146670
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r--gcc/ada/gcc-interface/decl.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 746e1e8..bc44fa0 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -1957,11 +1957,28 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
if (gnu_comp_size && !Is_Bit_Packed_Array (gnat_entity))
{
- tree orig_tem;
+ tree orig_tem = tem;
+ unsigned int max_align;
+
+ /* If an alignment is specified, use it as a cap on the component
+ type so that it can be honored for the whole type. But ignore
+ it for the original type of packed array types. */
+ if (No (Packed_Array_Type (gnat_entity))
+ && Known_Alignment (gnat_entity))
+ max_align = validate_alignment (Alignment (gnat_entity),
+ gnat_entity, 0);
+ else
+ max_align = 0;
+
tem = make_type_from_size (tem, gnu_comp_size, false);
- orig_tem = tem;
+ if (max_align > 0 && TYPE_ALIGN (tem) > max_align)
+ tem = orig_tem;
+ else
+ orig_tem = tem;
+
tem = maybe_pad_type (tem, gnu_comp_size, 0, gnat_entity,
"C_PAD", false, definition, true);
+
/* If a padding record was made, declare it now since it will
never be declared otherwise. This is necessary to ensure
that its subtrees are properly marked. */
@@ -2343,13 +2360,31 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
if (gnu_comp_size && !Is_Bit_Packed_Array (gnat_entity))
{
- tree orig_gnu_type;
+ tree orig_gnu_type = gnu_type;
+ unsigned int max_align;
+
+ /* If an alignment is specified, use it as a cap on the
+ component type so that it can be honored for the whole
+ type. But ignore it for the original type of packed
+ array types. */
+ if (No (Packed_Array_Type (gnat_entity))
+ && Known_Alignment (gnat_entity))
+ max_align = validate_alignment (Alignment (gnat_entity),
+ gnat_entity, 0);
+ else
+ max_align = 0;
+
gnu_type
= make_type_from_size (gnu_type, gnu_comp_size, false);
- orig_gnu_type = gnu_type;
+ if (max_align > 0 && TYPE_ALIGN (gnu_type) > max_align)
+ gnu_type = orig_gnu_type;
+ else
+ orig_gnu_type = gnu_type;
+
gnu_type = maybe_pad_type (gnu_type, gnu_comp_size, 0,
gnat_entity, "C_PAD", false,
definition, true);
+
/* If a padding record was made, declare it now since it
will never be declared otherwise. This is necessary
to ensure that its subtrees are properly marked. */