]> git.ipfire.org Git - thirdparty/gcc.git/commit
Ada: Fix incorrect legality check in instantiation of child generic unit
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 4 Nov 2025 18:54:45 +0000 (19:54 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Tue, 4 Nov 2025 19:08:48 +0000 (20:08 +0100)
commit8836210fb62058980aeb02d6aad7f6dbca87b50b
treecc9f82d07c8e1e7f9812f55039f5b7a9bf0d8eb5
parent4cad566793d0a2587a10f9669dfd0f5cdbd6d82d
Ada: Fix incorrect legality check in instantiation of child generic unit

The problem arises when the generic unit has a formal access type parameter,
because the manual resolution implemented in Find_Actual_Type does not pick
the correct entity for the designated type.  The fix replaces it with a bona
fide resolution and cleans up the associated code in the callers.

gcc/ada/
PR ada/18453
* sem_ch12.adb (Find_Actual_Type): Add Typ_Ref parameter and
perform a standard resolution on it in the fallback case.
Call Get_Instance_Of if the type is declared in a formal of
the child unit.
(Instantiate_Type.Validate_Access_Type_Instance): Adjust call
to Find_Actual_Type.
(Instantiate_Type.Validate_Array_Type_Instance): Likewise and
streamline the check for matching component subtypes.

gcc/testsuite/
* gnat.dg/specs/generic_inst9.ads: New test.
* gnat.dg/specs/generic_inst9_pkg1.ads: New helper.
* gnat.dg/specs/generic_inst9_pkg2.ads: Likewise.
* gnat.dg/specs/generic_inst9_pkg2-g.ads: Likewise.
gcc/ada/sem_ch12.adb
gcc/testsuite/gnat.dg/specs/generic_inst9.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/generic_inst9_pkg1.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/generic_inst9_pkg2-g.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/generic_inst9_pkg2.ads [new file with mode: 0644]