That's an old issue, but the fix is quite straightforward.

Tested on x86-64/Linux, applied on the mainline.


2026-02-02  Eric Botcazou  <[email protected]>

        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.


2026-02-02  Eric Botcazou  <[email protected]>

        * 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.

-- 
Eric Botcazou
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 63bfcf36f28..02259044453 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -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
-- { dg-do link }

with Limited_With8_Pkg1;

procedure Limited_With8 is
begin
   null;
end;
with Limited_With8_Pkg2;

package Limited_With8_Pkg1 is
   type T;
   type T is new Integer;
end Limited_With8_Pkg1;
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;
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;

Reply via email to