From 847ec40a79b07dce226253ead15a9c292354ed00 Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Mon, 26 May 2008 14:44:53 +0200 Subject: [PATCH] sem_ch12.adb (Remove_Parent): Use specification of instance to retrieve generic parent... 2008-05-26 Ed Schonberg * sem_ch12.adb (Remove_Parent): Use specification of instance to retrieve generic parent, to handle properly the case where the instance is a child unit. Add guard to handle properly wrapper packages. Minor reformatting From-SVN: r135914 --- gcc/ada/sem_ch12.adb | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 9a79d424f1e..3efe7fc2bed 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -10806,7 +10806,7 @@ package body Sem_Ch12 is ------------------- procedure Remove_Parent (In_Body : Boolean := False) is - S : Entity_Id := Current_Scope; + S : Entity_Id := Current_Scope; -- S is the scope containing the instantiation just completed. The -- scope stack contains the parent instances of the instantiation, -- followed by the original S. @@ -10828,7 +10828,6 @@ package body Sem_Ch12 is if In_Open_Scopes (P) then E := First_Entity (P); - while Present (E) loop Set_Is_Immediately_Visible (E, True); Next_Entity (E); @@ -10866,20 +10865,29 @@ package body Sem_Ch12 is -- of a child unit of its generic parent unit. elsif S = Current_Scope - and then Is_Generic_Instance (S) - and then P = Scope (Generic_Parent (Parent (S))) - and then (In_Package_Body (S) or else In_Private_Part (S)) + and then Is_Generic_Instance (S) then - Set_In_Private_Part (P); - Install_Private_Declarations (P); + declare + Par : constant Entity_Id := + Generic_Parent + (Specification (Unit_Declaration_Node (S))); + begin + if Present (Par) + and then P = Scope (Par) + and then (In_Package_Body (S) or else In_Private_Part (S)) + then + Set_In_Private_Part (P); + Install_Private_Declarations (P); + end if; + end; end if; end loop; -- Reset visibility of entities in the enclosing scope Set_Is_Hidden_Open_Scope (Current_Scope, False); - Hidden := First_Elmt (Hidden_Entities); + Hidden := First_Elmt (Hidden_Entities); while Present (Hidden) loop Set_Is_Immediately_Visible (Node (Hidden), True); Next_Elmt (Hidden); -- 2.30.2