sem_ch12.adb (Inline_Instance_Body): Use Save_Scope_Stack and push Standard on the...
authorEd Schonberg <schonber@gnat.com>
Mon, 3 Dec 2001 19:21:33 +0000 (19:21 +0000)
committerGeert Bosch <bosch@gcc.gnu.org>
Mon, 3 Dec 2001 19:21:33 +0000 (20:21 +0100)
2001-12-03  Ed Schonberg <schonber@gnat.com>

* sem_ch12.adb (Inline_Instance_Body): Use Save_Scope_Stack and
push Standard on the stack before analyzing the instance body,
in order to have a clean visibility environment.

* sem_ch12.adb (Inline_Instance_Body): Remove redundant code.

From-SVN: r47559

gcc/ada/ChangeLog
gcc/ada/sem_ch12.adb

index f28fac2f21bdcde52049fc631b1089dfbb024812..93613407ab942746110b60a5c00cd9000e0dd7e8 100644 (file)
@@ -1,3 +1,11 @@
+2001-12-03  Ed Schonberg <schonber@gnat.com>
+
+       * sem_ch12.adb (Inline_Instance_Body): Use Save_Scope_Stack and 
+       push Standard on the stack before analyzing the instance body, 
+       in order to have a clean visibility environment.
+       
+       * sem_ch12.adb (Inline_Instance_Body): Remove redundant code. 
+
 2001-12-03  Ed Schonberg <schonber@gnat.com>
 
        * sem_ch12.adb (Instantiate_Package_Body): Protect against double 
index 811644d2d3c044315e74ff65b253fd61cf271cd8..b7c880422a2702d28fea6630b8c158e632a12d4b 100644 (file)
@@ -2728,6 +2728,11 @@ package body Sem_Ch12 is
             then
                Removed := True;
 
+               --  Remove entities in current scopes from visibility, so
+               --  than instance body is compiled in a clean environment.
+
+               Save_Scope_Stack;
+
                if Is_Child_Unit (S) then
                   --  Remove child unit from stack, as well as inner scopes.
                   --  Removing the context of a child unit removes parent
@@ -2755,8 +2760,11 @@ package body Sem_Ch12 is
             S := Scope (S);
          end loop;
 
+         New_Scope (Standard_Standard);
          Instantiate_Package_Body
            ((N, Act_Decl, Expander_Active, Current_Sem_Unit));
+         Pop_Scope;
+
 
          --  Restore context.
 
@@ -2771,37 +2779,8 @@ package body Sem_Ch12 is
          end loop;
 
          if Removed then
-            --  Make local entities not visible, so that when the context of
-            --  unit is restored, there are not spurious hidings of use-
-            --  visible entities (which appear in the environment before the
-            --  current scope).
-
-            if Current_Scope /= Standard_Standard then
-               S := First_Entity (Current_Scope);
-
-               while Present (S) loop
-                  if Is_Overloadable (S) then
-                     Set_Is_Immediately_Visible (S, False);
-                  end if;
-
-                  Next_Entity (S);
-               end loop;
-            end if;
-
             Install_Context (Curr_Comp);
 
-            if Current_Scope /= Standard_Standard then
-               S := First_Entity (Current_Scope);
-
-               while Present (S) loop
-                  if Is_Overloadable (S) then
-                     Set_Is_Immediately_Visible (S);
-                  end if;
-
-                  Next_Entity (S);
-               end loop;
-            end if;
-
             if Present (Curr_Scope)
               and then Is_Child_Unit (Curr_Scope)
             then
@@ -2814,6 +2793,8 @@ package body Sem_Ch12 is
                   New_Scope (Inner_Scopes (J));
                end loop;
             end if;
+
+            Restore_Scope_Stack;
          end if;
 
          for J in reverse 1 .. Num_Scopes loop