Commit 940ff20c by Eric Botcazou

decl.c (gnat_to_gnu_entity): Do not pack the field of the record type made for a misaligned type.

	* gcc-interface/decl.c (gnat_to_gnu_entity) <discrete_type>: Do not
	pack the field of the record type made for a misaligned type.

From-SVN: r194942
parent adf8bb4f
2013-01-06 Eric Botcazou <ebotcazou@adacore.com> 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 * gcc-interface/decl.c (annotate_value) <COMPONENT_REF>: Be prepared
for discriminants inherited from parent record types. for discriminants inherited from parent record types.
...@@ -12,7 +17,7 @@ ...@@ -12,7 +17,7 @@
* einfo.adb, atree.adb: Enlarge entities to make 63 more flags, 6 more * einfo.adb, atree.adb: Enlarge entities to make 63 more flags, 6 more
fields. fields.
2013-01-04 Joel Brobecker <brobecker@adacore.com brobecker> 2013-01-04 Joel Brobecker <brobecker@adacore.com>
* gnat_ugn.texi: Fix typo. * gnat_ugn.texi: Fix typo.
......
...@@ -1887,8 +1887,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -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 /* 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 natural one, we need to wrap it up in a record type and misalign the
the latter. We reuse the padding machinery for this purpose. */ 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) else if (align > 0)
{ {
tree gnu_field_type, gnu_field; tree gnu_field_type, gnu_field;
...@@ -1918,7 +1920,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -1918,7 +1920,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
a bitfield. */ a bitfield. */
gnu_field gnu_field
= create_field_decl (get_identifier ("F"), gnu_field_type, = 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); finish_record_type (gnu_type, gnu_field, 2, debug_info_p);
compute_record_mode (gnu_type); 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> 2013-01-05 Steven G. Kargl <kargl@gcc.gnu.org>
Mikael Morin <mikael@gcc.gnu.org> Mikael Morin <mikael@gcc.gnu.org>
......
-- { 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment