aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2008-03-08 11:10:18 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2008-03-08 11:10:18 +0000
commit66abe22c0716119ac01164cebd147d86a0ed8c70 (patch)
tree6d06a7a60f89e389c96d2d726ee38dbeb507a474 /gcc/ada
parent563569be5ed93378df1e43fca7d7fd6ee0fc0c65 (diff)
downloadgcc-66abe22c0716119ac01164cebd147d86a0ed8c70.zip
gcc-66abe22c0716119ac01164cebd147d86a0ed8c70.tar.gz
gcc-66abe22c0716119ac01164cebd147d86a0ed8c70.tar.bz2
decl.c (gnat_to_gnu_entity): Add support for scalar types with small alignment.
* decl.c (gnat_to_gnu_entity) <E_Signed_Integer_Subtype>: Add support for scalar types with small alignment. From-SVN: r133027
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/decl.c39
2 files changed, 44 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 4d6f170..2a10f10 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2008-03-08 Eric Botcazou <ebotcazou@adacore.com>
+ * decl.c (gnat_to_gnu_entity) <E_Signed_Integer_Subtype>: Add support
+ for scalar types with small alignment.
+
+2008-03-08 Eric Botcazou <ebotcazou@adacore.com>
+
* trans.c (Loop_Statement_to_gnu): Set the SLOC of the loop label
from that of the front-end's end label.
(gnat_gimplify_stmt) <LOOP_STMT>: Set the SLOC of the backward goto
diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c
index c1d02ec..6278320 100644
--- a/gcc/ada/decl.c
+++ b/gcc/ada/decl.c
@@ -1520,6 +1520,45 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
copy_alias_set (gnu_type, gnu_field_type);
}
+ /* If the type we are dealing with has got a smaller alignment than the
+ natural one, we need to wrap it up in a record type and under-align
+ the latter. We reuse the padding machinery for this purpose. */
+ else if (Known_Alignment (gnat_entity)
+ && UI_Is_In_Int_Range (Alignment (gnat_entity))
+ && (align = UI_To_Int (Alignment (gnat_entity)) * BITS_PER_UNIT)
+ && align < TYPE_ALIGN (gnu_type))
+ {
+ tree gnu_field_type = gnu_type;
+ tree gnu_field;
+
+ gnu_type = make_node (RECORD_TYPE);
+ TYPE_NAME (gnu_type) = create_concat_name (gnat_entity, "PAD");
+
+ TYPE_ALIGN (gnu_type) = align;
+ TYPE_PACKED (gnu_type) = 1;
+
+ /* Create a stripped-down declaration of the original type, mainly
+ for debugging. */
+ create_type_decl (get_entity_name (gnat_entity), gnu_field_type,
+ NULL, true, debug_info_p, gnat_entity);
+
+ /* Don't notify the field as "addressable", since we won't be taking
+ it's address and it would prevent create_field_decl from making a
+ bitfield. */
+ gnu_field = create_field_decl (get_identifier ("OBJECT"),
+ gnu_field_type, gnu_type, 1, 0, 0, 0);
+
+ finish_record_type (gnu_type, gnu_field, 0, false);
+ TYPE_IS_PADDING_P (gnu_type) = 1;
+ SET_TYPE_ADA_SIZE (gnu_type, bitsize_int (esize));
+
+ copy_alias_set (gnu_type, gnu_field_type);
+ }
+
+ /* Otherwise reset the alignment lest we computed it above. */
+ else
+ align = 0;
+
break;
case E_Floating_Point_Type: