]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (gnat_to_gnu_field): Do not set the alignment of the enclosing record type...
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 14 Dec 2017 17:07:28 +0000 (17:07 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 14 Dec 2017 17:07:28 +0000 (17:07 +0000)
* 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

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/alignment13.adb [new file with mode: 0644]

index 17b72d620ea6d7f2e863d01cbd6ccfdaaeee6656..aca3c23380fe20d4d63337152aebda4a3371320f 100644 (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-11-10  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/utils.c (convert) <RECORD_TYPE>: Add comment and do
index 2e57beae2f5271b76eb379117f2b4928fbd53274..a02dd24b27fbe07061764a30adfbe55c9e85a05f 100644 (file)
@@ -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,
index 0fae4dce0d1f106a5c67f20d1bf94bc3c3f033d3..6a12b8ad78df293804d2b9d6311ff76e5b845129 100644 (file)
@@ -1,3 +1,7 @@
+2017-12-14  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/alignment13.adb: New test.
+
 2017-12-11  Thomas Schwinge  <thomas@codesourcery.com>
 
        PR c++/83301
diff --git a/gcc/testsuite/gnat.dg/alignment13.adb b/gcc/testsuite/gnat.dg/alignment13.adb
new file mode 100644 (file)
index 0000000..dd0b254
--- /dev/null
@@ -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;