[Ada] Spurious error on incomplete tagged formal parameter
authorJustin Squirek <squirek@adacore.com>
Thu, 4 Jul 2019 08:06:40 +0000 (08:06 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Thu, 4 Jul 2019 08:06:40 +0000 (08:06 +0000)
This patch fixes an issue whereby a check for competing controlling
formals led to a spurious dispatching error due to an incomplete type
being used within a subprogram specification.

2019-07-04  Justin Squirek  <squirek@adacore.com>

gcc/ada/

* sem_disp.adb (Check_Controlling_Formals): Obtain the full view
before type comparison.

gcc/testsuite/

* gnat.dg/tagged2.adb, gnat.dg/tagged2.ads: New testcase.

From-SVN: r273063

gcc/ada/ChangeLog
gcc/ada/sem_disp.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/tagged2.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/tagged2.ads [new file with mode: 0644]

index 1d6d8c02109a976cf8c55d438038925eb028c1e6..e476413feb77e9e20c9dd6215d2e0b126771e642 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-04  Justin Squirek  <squirek@adacore.com>
+
+       * sem_disp.adb (Check_Controlling_Formals): Obtain the full view
+       before type comparison.
+
 2019-07-04  Ed Schonberg  <schonberg@adacore.com>
 
        * exp_ch4.ads, exp_ch4.adb (Build_Eq_Call): New visible
index a2f753ba76e7be31fc635d7eba8f9af9fe6eaa7b..92486cd26913fe4edc68b5f57119fbe72bf4e531 100644 (file)
@@ -210,6 +210,14 @@ package body Sem_Disp is
          Ctrl_Type := Check_Controlling_Type (Etype (Formal), Subp);
 
          if Present (Ctrl_Type) then
+            --  Obtain the full type in case we are looking at an incomplete
+            --  view.
+
+            if Ekind (Ctrl_Type) = E_Incomplete_Type
+              and then Present (Full_View (Ctrl_Type))
+            then
+               Ctrl_Type := Full_View (Ctrl_Type);
+            end if;
 
             --  When controlling type is concurrent and declared within a
             --  generic or inside an instance use corresponding record type.
index 996a0ece0c01e365740298ba952dcdb82df076a5..6873356c469f2854cf359858c9506ae5ef78da83 100644 (file)
@@ -1,3 +1,7 @@
+2019-07-04  Justin Squirek  <squirek@adacore.com>
+
+       * gnat.dg/tagged2.adb, gnat.dg/tagged2.ads: New testcase.
+
 2019-07-04  Ed Schonberg  <schonberg@adacore.com>
 
        * gnat.dg/equal6.adb, gnat.dg/equal6_types.adb,
diff --git a/gcc/testsuite/gnat.dg/tagged2.adb b/gcc/testsuite/gnat.dg/tagged2.adb
new file mode 100644 (file)
index 0000000..2cf9fc5
--- /dev/null
@@ -0,0 +1,9 @@
+--  { dg-do compile }
+
+package body Tagged2 is
+
+   procedure Get_Parent
+     (DeviceX : Device;
+      Parent  : out Device) is null;
+
+end Tagged2;
diff --git a/gcc/testsuite/gnat.dg/tagged2.ads b/gcc/testsuite/gnat.dg/tagged2.ads
new file mode 100644 (file)
index 0000000..8bbc485
--- /dev/null
@@ -0,0 +1,9 @@
+package Tagged2 is
+   type Device;
+
+   procedure Get_Parent
+     (DeviceX : Device;
+      Parent  : out Device);
+
+   type Device is tagged null record;
+end Tagged2;