]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Ada: Fix profile conformance glitch with limited_with and incomplete type
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 2 Feb 2026 18:40:33 +0000 (19:40 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 2 Feb 2026 18:43:08 +0000 (19:43 +0100)
That's an old issue, but the fix is quite straightforward.

gcc/ada/
PR ada/89159
* sem_ch6.adb (Conforming_Types.Is_Matching_Limited_View): Return
true when the type is an incomplete view of the non-limited view.

gcc/testsuite/
* gnat.dg/limited_with8.adb: New test.
* gnat.dg/limited_with8_pkg1.ads: New helper.
* gnat.dg/limited_with8_pkg2.ads: Likewise.
* gnat.dg/limited_with8_pkg2.adb: Likewise.

gcc/ada/sem_ch6.adb
gcc/testsuite/gnat.dg/limited_with8.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/limited_with8_pkg1.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/limited_with8_pkg2.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/limited_with8_pkg2.ads [new file with mode: 0644]

index 63bfcf36f28d826a85c8b24706a511f4023ec1e4..022590444537538d284100588047d28267086d41 100644 (file)
@@ -5796,6 +5796,10 @@ package body Sem_Ch6 is
          end if;
       end Null_Exclusions_Match;
 
+      -----------------------------------------------
+      -- Subprogram_Subtypes_Have_Same_Declaration --
+      -----------------------------------------------
+
       function Subprogram_Subtypes_Have_Same_Declaration
         (Subp         : Entity_Id;
          Decl_Subtype : Entity_Id;
@@ -8344,6 +8348,11 @@ package body Sem_Ch6 is
             if Typ = View then
                return True;
 
+            --  The type is an incomplete view of the non-limited view
+
+            elsif Is_Incomplete_Type (Typ) and then Full_View (Typ) = View then
+               return True;
+
             --  The type is a subtype of the non-limited view
 
             elsif Is_Subtype_Of (Typ, View) then
diff --git a/gcc/testsuite/gnat.dg/limited_with8.adb b/gcc/testsuite/gnat.dg/limited_with8.adb
new file mode 100644 (file)
index 0000000..bd413ed
--- /dev/null
@@ -0,0 +1,8 @@
+-- { dg-do link }
+
+with Limited_With8_Pkg1;
+
+procedure Limited_With8 is
+begin
+   null;
+end;
diff --git a/gcc/testsuite/gnat.dg/limited_with8_pkg1.ads b/gcc/testsuite/gnat.dg/limited_with8_pkg1.ads
new file mode 100644 (file)
index 0000000..0f196a5
--- /dev/null
@@ -0,0 +1,6 @@
+with Limited_With8_Pkg2;
+
+package Limited_With8_Pkg1 is
+   type T;
+   type T is new Integer;
+end Limited_With8_Pkg1;
diff --git a/gcc/testsuite/gnat.dg/limited_with8_pkg2.adb b/gcc/testsuite/gnat.dg/limited_with8_pkg2.adb
new file mode 100644 (file)
index 0000000..be8d9ff
--- /dev/null
@@ -0,0 +1,10 @@
+with Limited_With8_Pkg1;
+
+package body Limited_With8_Pkg2 is
+   procedure G (Container : in M;
+                F         : access function return Limited_With8_Pkg1.T) is
+      Item : Limited_With8_Pkg1.T := F.all;
+   begin
+      null;
+   end G;
+end Limited_With8_Pkg2;
diff --git a/gcc/testsuite/gnat.dg/limited_with8_pkg2.ads b/gcc/testsuite/gnat.dg/limited_with8_pkg2.ads
new file mode 100644 (file)
index 0000000..35498d4
--- /dev/null
@@ -0,0 +1,7 @@
+limited with Limited_With8_Pkg1;
+
+package Limited_With8_Pkg2 is
+   type M is tagged null record;
+   procedure G (Container : in M;
+                F         : access function return Limited_With8_Pkg1.T);
+end Limited_With8_Pkg2;