https://gcc.gnu.org/g:84d9fde22d5e6f0d62d76cf3a6f8c6d973ff2442
commit r16-4680-g84d9fde22d5e6f0d62d76cf3a6f8c6d973ff2442 Author: Eric Botcazou <[email protected]> Date: Tue Oct 28 10:13:35 2025 +0100 Ada: Fix instantiation failure for package with formal package parameters The problem occurs for a generic package with a formal package parameter that contains a nested generic package used in the instantiation of another generic package with two formal package parameters. It turns out that the mapping between formals and actuals for the latter two formal package parameters done by Map_Formal_Package_Entities is blocked by the presence of the first formal package parameter, more precisely by the special name built for the formal in the parent of a child unit. The fix is just to set the Is_Internal flag on this special name. gcc/ada/ PR ada/59234 * sem_ch12.adb (Analyze_Formal_Package_Declaration): Mark the special name built for the formal in the parent of a child unit as internal. gcc/testsuite/ * gnat.dg/specs/generic_inst5.ads: New test. * gnat.dg/specs/generic_inst5_pkg1.ads: New helper. * gnat.dg/specs/generic_inst5_pkg2.ads: Likewise. Diff: --- gcc/ada/sem_ch12.adb | 1 + gcc/testsuite/gnat.dg/specs/generic_inst5.ads | 14 ++++++++++++++ gcc/testsuite/gnat.dg/specs/generic_inst5_pkg1.ads | 9 +++++++++ gcc/testsuite/gnat.dg/specs/generic_inst5_pkg2.ads | 7 +++++++ 4 files changed, 31 insertions(+) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 9a155b9b4810..9acf19326786 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -3883,6 +3883,7 @@ package body Sem_Ch12 is Renaming_In_Par := Make_Defining_Identifier (Loc, Chars (Gen_Unit)); Mutate_Ekind (Renaming_In_Par, E_Package); + Set_Is_Internal (Renaming_In_Par); Set_Is_Not_Self_Hidden (Renaming_In_Par); Set_Etype (Renaming_In_Par, Standard_Void_Type); Set_Scope (Renaming_In_Par, Parent_Instance); diff --git a/gcc/testsuite/gnat.dg/specs/generic_inst5.ads b/gcc/testsuite/gnat.dg/specs/generic_inst5.ads new file mode 100644 index 000000000000..d3d0b2a2783b --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/generic_inst5.ads @@ -0,0 +1,14 @@ +-- { dg-do compile } + +with Ada.Containers.Ordered_Sets; +with Generic_Inst5_Pkg1; +with Generic_Inst5_Pkg2; + +package Generic_Inst5 is + + package Charsets is new Ada.Containers.Ordered_sets (Character); + package P1 is new Generic_Inst5_Pkg1 (Charsets); + package P1_N is new P1.Nested; + package P2 is new Generic_Inst5_Pkg2 (P1, P1_N); + +end Generic_Inst5; diff --git a/gcc/testsuite/gnat.dg/specs/generic_inst5_pkg1.ads b/gcc/testsuite/gnat.dg/specs/generic_inst5_pkg1.ads new file mode 100644 index 000000000000..da599b053f7f --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/generic_inst5_pkg1.ads @@ -0,0 +1,9 @@ +with Ada.Containers.Ordered_Sets; + +generic + with package Sets is new Ada.Containers.Ordered_Sets (<>); +package Generic_Inst5_Pkg1 is + generic + package Nested is + end Nested; +end Generic_Inst5_Pkg1; diff --git a/gcc/testsuite/gnat.dg/specs/generic_inst5_pkg2.ads b/gcc/testsuite/gnat.dg/specs/generic_inst5_pkg2.ads new file mode 100644 index 000000000000..2f5df87d19eb --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/generic_inst5_pkg2.ads @@ -0,0 +1,7 @@ +with Generic_Inst5_Pkg1; + +generic + with package P1 is new Generic_Inst5_Pkg1 (<>); + with package P1_N is new P1.Nested; +package Generic_Inst5_Pkg2 is +end Generic_Inst5_Pkg2;
