From: Eric Botcazou Date: Mon, 2 Feb 2026 18:40:33 +0000 (+0100) Subject: Ada: Fix profile conformance glitch with limited_with and incomplete type X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dda809f25ee115af1566a44340d7570f2bde09d8;p=thirdparty%2Fgcc.git Ada: Fix profile conformance glitch with limited_with and incomplete type 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. --- 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 diff --git a/gcc/testsuite/gnat.dg/limited_with8.adb b/gcc/testsuite/gnat.dg/limited_with8.adb new file mode 100644 index 00000000000..bd413edfb94 --- /dev/null +++ b/gcc/testsuite/gnat.dg/limited_with8.adb @@ -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 index 00000000000..0f196a507da --- /dev/null +++ b/gcc/testsuite/gnat.dg/limited_with8_pkg1.ads @@ -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 index 00000000000..be8d9ff9f40 --- /dev/null +++ b/gcc/testsuite/gnat.dg/limited_with8_pkg2.adb @@ -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 index 00000000000..35498d4f215 --- /dev/null +++ b/gcc/testsuite/gnat.dg/limited_with8_pkg2.ads @@ -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;