This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fix visibility problem with front-end inlining


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. 

*** sem_ch12.adb	2001/10/03 02:57:23	1.780
--- sem_ch12.adb	2001/10/03 19:12:34	1.781
***************
*** 2729,2734 ****
--- 2729,2735 ----
                          and then S = Spec_Entity (Curr_Unit))
              then
                 Removed := True;
+                Save_Scope_Stack;
  
                 if Is_Child_Unit (S) then
                    --  Remove child unit from stack, as well as inner scopes.
***************
*** 2757,2765 ****
--- 2758,2769 ----
              S := Scope (S);
           end loop;
  
+          New_Scope (Standard_Standard);
           Instantiate_Package_Body
             ((N, Act_Decl, Expander_Active, Current_Sem_Unit));
+          Pop_Scope;
  
+ 
           --  Restore context.
  
           Set_Is_Immediately_Visible (Gen_Comp, Vis);
***************
*** 2816,2821 ****
--- 2820,2827 ----
                    New_Scope (Inner_Scopes (J));
                 end loop;
              end if;
+ 
+             Restore_Scope_Stack;
           end if;
  
           for J in reverse 1 .. Num_Scopes loop

*** sem_ch12.adb	2001/10/03 19:12:34	1.781
--- sem_ch12.adb	2001/10/04 14:08:19	1.782
***************
*** 2729,2734 ****
--- 2729,2738 ----
                          and then S = Spec_Entity (Curr_Unit))
              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
***************
*** 2777,2812 ****
           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)
--- 2781,2787 ----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]