https://gcc.gnu.org/g:dda809f25ee115af1566a44340d7570f2bde09d8
commit r16-7245-gdda809f25ee115af1566a44340d7570f2bde09d8 Author: Eric Botcazou <[email protected]> Date: Mon Feb 2 19:40:33 2026 +0100 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: --- gcc/ada/sem_ch6.adb | 9 +++++++++ gcc/testsuite/gnat.dg/limited_with8.adb | 8 ++++++++ gcc/testsuite/gnat.dg/limited_with8_pkg1.ads | 6 ++++++ gcc/testsuite/gnat.dg/limited_with8_pkg2.adb | 10 ++++++++++ gcc/testsuite/gnat.dg/limited_with8_pkg2.ads | 7 +++++++ 5 files changed, 40 insertions(+) diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 63bfcf36f28d..022590444537 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 000000000000..bd413edfb94f --- /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 000000000000..0f196a507da3 --- /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 000000000000..be8d9ff9f404 --- /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 000000000000..35498d4f2152 --- /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;
