]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
trans.c (Call_to_gnu): Use the unpadded type when putting back an intermediate conver...
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 27 May 2019 10:25:17 +0000 (10:25 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 27 May 2019 10:25:17 +0000 (10:25 +0000)
* gcc-interface/trans.c (Call_to_gnu): Use the unpadded type when
putting back an intermediate conversion the type of the actuals.

From-SVN: r271648

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

index 05d3a4b0dbd6bb5497b42558b538a3aec51b7031..700795288a0e95c6fc5570dceea85a98ba2622c2 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (Call_to_gnu): Use the unpadded type when
+       putting back an intermediate conversion the type of the actuals.
+
 2019-05-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * gcc-interface/Makefile.in (install-gcc-specs): Use foreach.
index 155cb4b27abc3ac6063c4f630b400714c244b258..1afe847682aaf51ef5fa786514807f78ef49e17b 100644 (file)
@@ -5354,7 +5354,7 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target,
         since the parent is a procedure call, so put it back here.  Note that
         we might have a dummy type here if the actual is the dereference of a
         pointer to it, but that's OK if the formal is passed by reference.  */
-      tree gnu_actual_type = gnat_to_gnu_type (Etype (gnat_actual));
+      tree gnu_actual_type = get_unpadded_type (Etype (gnat_actual));
       if (TYPE_IS_DUMMY_P (gnu_actual_type))
        gcc_assert (is_true_formal_parm && DECL_BY_REF_P (gnu_formal));
       else if (suppress_type_conversion
index 99c9ab5541aa7f6efd11719b878658cc872bcb10..ef38f8f625297a2abf4f1cdf82bfdadae6578547 100644 (file)
@@ -1,3 +1,7 @@
+2019-05-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/unchecked_convert13.adb: New test.
+
 2019-05-24  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/gnat.dg/unchecked_convert13.adb b/gcc/testsuite/gnat.dg/unchecked_convert13.adb
new file mode 100644 (file)
index 0000000..6297e27
--- /dev/null
@@ -0,0 +1,30 @@
+-- { dg-do compile }
+
+with Ada.Unchecked_Conversion;
+
+procedure Unchecked_Convert13 is
+
+  type B16_T is mod 2 ** 16;
+  for B16_T'Size use 16;
+  for B16_T'Alignment use 1;
+
+  type Rec_T is record
+    A : Short_Integer;
+  end record;
+  for Rec_T use record
+    A at 0 range 0 .. 15;
+  end record;
+  for Rec_T'Size use 16;
+
+  Rec : constant Rec_T := (A => 0);
+
+  function Rec_To_B16 is new Ada.Unchecked_Conversion (Rec_T, B16_T);
+
+  procedure Nested (B16 : B16_T) is
+  begin
+    null;
+  end;
+
+begin
+  Nested (Rec_To_B16 (Rec));
+end;