decl.c (gnat_to_gnu_field): Do not set the alignment of the enclosing record type if it is not already set.

* gcc-interface/decl.c (gnat_to_gnu_field): Do not set the alignment
	of the enclosing record type if it is not already set.

From-SVN: r255646
This commit is contained in:
Eric Botcazou 2017-12-14 17:05:43 +00:00 committed by Eric Botcazou
parent 3824ac481e
commit a9834d8de0
4 changed files with 32 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2017-12-14 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_field): Do not set the alignment
of the enclosing record type if it is not already set.
2017-12-13 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Subprogram_Body_to_gnu): Initialize locus.

View File

@ -7127,7 +7127,8 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
{
const unsigned int type_align = TYPE_ALIGN (gnu_field_type);
if (TYPE_ALIGN (gnu_record_type) < type_align)
if (TYPE_ALIGN (gnu_record_type)
&& TYPE_ALIGN (gnu_record_type) < type_align)
SET_TYPE_ALIGN (gnu_record_type, type_align);
/* If the position is not a multiple of the alignment of the type,

View File

@ -1,3 +1,7 @@
2017-12-14 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/alignment13.adb: New test.
2017-12-13 Peter Bergner <bergner@vnet.ibm.com>
Backport from mainline

View File

@ -0,0 +1,21 @@
-- { dg-do run }
-- { dg-options "-gnatws" }
procedure Alignment13 is
type Rec is record
I1 : aliased Short_Integer;
I2 : Integer;
end record;
for Rec use record
I1 at 0 range 0 .. 15;
end record;
R : Rec;
begin
if R.I2'Bit_Position /= 32 then
raise Program_Error;
end if;
end;