aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/gcc-interface/decl.c9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/alignment10.adb20
4 files changed, 36 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 1ade2a0..1d3dcd3 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2013-01-06 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/decl.c (gnat_to_gnu_entity) <discrete_type>: Do not
+ pack the field of the record type made for a misaligned type.
+
+2013-01-06 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/decl.c (annotate_value) <COMPONENT_REF>: Be prepared
for discriminants inherited from parent record types.
@@ -12,7 +17,7 @@
* einfo.adb, atree.adb: Enlarge entities to make 63 more flags, 6 more
fields.
-2013-01-04 Joel Brobecker <brobecker@adacore.com brobecker>
+2013-01-04 Joel Brobecker <brobecker@adacore.com>
* gnat_ugn.texi: Fix typo.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index f7db364..f312c7d 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -1887,8 +1887,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
}
/* 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. */
+ natural one, we need to wrap it up in a record type and misalign the
+ latter; we reuse the padding machinery for this purpose. Note that,
+ even if the record type is marked as packed because of misalignment,
+ we don't pack the field so as to give it the size of the type. */
else if (align > 0)
{
tree gnu_field_type, gnu_field;
@@ -1918,7 +1920,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
a bitfield. */
gnu_field
= create_field_decl (get_identifier ("F"), gnu_field_type,
- gnu_type, NULL_TREE, bitsize_zero_node, 1, 0);
+ gnu_type, TYPE_SIZE (gnu_field_type),
+ bitsize_zero_node, 0, 0);
finish_record_type (gnu_type, gnu_field, 2, debug_info_p);
compute_record_mode (gnu_type);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f16dc19..1c91f46 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2013-01-06 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/alignment10.adb: New test.
+
2013-01-05 Steven G. Kargl <kargl@gcc.gnu.org>
Mikael Morin <mikael@gcc.gnu.org>
diff --git a/gcc/testsuite/gnat.dg/alignment10.adb b/gcc/testsuite/gnat.dg/alignment10.adb
new file mode 100644
index 0000000..61779f1
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/alignment10.adb
@@ -0,0 +1,20 @@
+-- { dg-do run }
+
+procedure Alignment10 is
+
+ type Short_T is mod 2 ** 16;
+ for Short_T'Size use 16;
+ for Short_T'Alignment use 1;
+
+ subtype Short_Sub_T is Short_T range 1000 .. 1005;
+
+ A : aliased Short_T := 1000;
+ B : Short_Sub_T;
+ for B'Address use A'Address;
+ pragma Import (Ada, B);
+
+begin
+ if B /= 1000 then
+ raise Program_Error;
+ end if;
+end;