+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
* 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.
}
/* 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;
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);
+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>
--- /dev/null
+-- { dg-do run }\r
+\r
+procedure Alignment10 is\r
+\r
+ type Short_T is mod 2 ** 16;\r
+ for Short_T'Size use 16;\r
+ for Short_T'Alignment use 1;\r
+\r
+ subtype Short_Sub_T is Short_T range 1000 .. 1005;\r
+\r
+ A : aliased Short_T := 1000;\r
+ B : Short_Sub_T;\r
+ for B'Address use A'Address;\r
+ pragma Import (Ada, B);\r
+\r
+begin\r
+ if B /= 1000 then\r
+ raise Program_Error;\r
+ end if;\r
+end;\r