This patch fixes a visbility error involving the use the name of a generic package GP as a selector for a formal package that is an instantiation of GP.
Compiling p-child.adb below must yield: p-child.ads:9:43: "P1" is not a visible entity of "Tested" package body P.Child is package body P1 is package body P2 is procedure Proc_2 is begin null; end Proc_2; end P2; end P1; end P.Child; --- package P.Child is generic with package Tested is new P.P1 (<>); package P1 is generic -- with package Tested is new Tested.P2 (<>); with package Tested is new Tested.P1.P2 (<>); package P2 is procedure Proc_2; end P2; end P1; end P.Child; --- package P is generic package P1 is generic package P2 is procedure Proc; end P2; end P1; end P; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-05 Ed Schonberg <schonb...@adacore.com> * sem_ch12.adb (Analyze_Formal_Package_Declaration): in an instantiation and a formal package the compiler generates a package renaming declaration so that the generic name within the declaration is interpreted as a renaming of the instance. At the end of a formal package declaration, this renaming must become invisible.
Index: sem_ch12.adb =================================================================== --- sem_ch12.adb (revision 177431) +++ sem_ch12.adb (working copy) @@ -2015,7 +2015,7 @@ Renaming : Node_Id; Parent_Instance : Entity_Id; Renaming_In_Par : Entity_Id; - No_Associations : Boolean := False; + Associations : Boolean := True; function Build_Local_Package return Node_Id; -- The formal package is rewritten so that its parameters are replaced @@ -2186,7 +2186,7 @@ or else No (Generic_Associations (N)) or else Nkind (First (Generic_Associations (N))) = N_Others_Choice then - No_Associations := True; + Associations := False; end if; -- If there are no generic associations, the generic parameters appear @@ -2266,26 +2266,33 @@ -- The formals for which associations are provided are not visible -- outside of the formal package. The others are still declared by a -- formal parameter declaration. + -- If there are no associations, the only local entity to hide is the + -- generated package renaming itself. - if not No_Associations then - declare - E : Entity_Id; + declare + E : Entity_Id; - begin - E := First_Entity (Formal); - while Present (E) loop - exit when Ekind (E) = E_Package - and then Renamed_Entity (E) = Formal; + begin + E := First_Entity (Formal); + while Present (E) loop - if not Is_Generic_Formal (E) then - Set_Is_Hidden (E); - end if; + if Associations + and then not Is_Generic_Formal (E) + then + Set_Is_Hidden (E); + end if; - Next_Entity (E); - end loop; - end; - end if; + if Ekind (E) = E_Package + and then Renamed_Entity (E) = Formal + then + Set_Is_Hidden (E); + exit; + end if; + Next_Entity (E); + end loop; + end; + End_Package_Scope (Formal); if Parent_Installed then