From: Eric Botcazou Date: Thu, 14 Dec 2017 17:07:28 +0000 (+0000) Subject: decl.c (gnat_to_gnu_field): Do not set the alignment of the enclosing record type... X-Git-Tag: releases/gcc-6.5.0~638 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3c71fce7a5464b8122c9aa80f4e3cc229eefdba;p=thirdparty%2Fgcc.git 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: r255647 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 17b72d620ea6..aca3c23380fe 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2017-12-14 Eric Botcazou + + * 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-11-10 Eric Botcazou * gcc-interface/utils.c (convert) : Add comment and do diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 2e57beae2f52..a02dd24b27fb 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -6805,7 +6805,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) TYPE_ALIGN (gnu_record_type) = type_align; /* If the position is not a multiple of the alignment of the type, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0fae4dce0d1f..6a12b8ad78df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-12-14 Eric Botcazou + + * gnat.dg/alignment13.adb: New test. + 2017-12-11 Thomas Schwinge PR c++/83301 diff --git a/gcc/testsuite/gnat.dg/alignment13.adb b/gcc/testsuite/gnat.dg/alignment13.adb new file mode 100644 index 000000000000..dd0b25425f0c --- /dev/null +++ b/gcc/testsuite/gnat.dg/alignment13.adb @@ -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;