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 use before freeze problem


2001-12-03  Ed Schonberg <schonber@gnat.com>

	* sem_ch12.adb:
	(Analyze_generic_subprogram_Declaration): Set outer_generic_scope,
	to prevent freezing within formal packages.
	(Freeze_Subprogram_Body): If body comes from another instance that
	appeared before its own body, place freeze node at end of current
	declarative part, to prevent a back-end crash.
	(Inline_Instance_Body): Handle properly a package instance within
	a subprogram instance that is a child unit.


*** sem_ch12.adb	2001/09/27 01:05:46	1.779
--- sem_ch12.adb	2001/10/03 02:57:23	1.780
***************
*** 2063,2069 ****
--- 2063,2071 ----
  
        Enter_Name (Id);
  
+       Set_Scope_Depth_Value (Id, Scope_Depth (Current_Scope) + 1);
        New_Scope (Id);
+       Enter_Generic_Scope (Id);
        Set_Inner_Instances (Id, New_Elmt_List);
        Set_Is_Pure (Id, Is_Pure (Current_Scope));
  
***************
*** 2101,2106 ****
--- 2103,2109 ----
  
        End_Generic;
        End_Scope;
+       Exit_Generic_Scope (Id);
  
     end Analyze_Generic_Subprogram_Declaration;
  
***************
*** 2717,2723 ****
             and then S /= Standard_Standard
           loop
              exit when Is_Generic_Instance (S)
!                  and then In_Package_Body (S);
  
              if S = Curr_Unit
                or else (Ekind (Curr_Unit) = E_Package_Body
--- 2720,2728 ----
             and then S /= Standard_Standard
           loop
              exit when Is_Generic_Instance (S)
!                  and then (In_Package_Body (S)
!                             or else Ekind (S) = E_Procedure
!                             or else Ekind (S) = E_Function);
  
              if S = Curr_Unit
                or else (Ekind (Curr_Unit) = E_Package_Body
***************
*** 2727,2733 ****
  
                 if Is_Child_Unit (S) then
                    --  Remove child unit from stack, as well as inner scopes.
!                   --  Removing its context of child unit will remove parent
                    --  units as well.
  
                    while Current_Scope /= S loop
--- 2732,2738 ----
  
                 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
                    --  units as well.
  
                    while Current_Scope /= S loop
***************
*** 5007,5013 ****
          and then
            In_Same_Declarative_Part (Freeze_Node (Par), Inst_Node)
        then
!          Insert_After (Freeze_Node (Par), F_Node);
  
        --  The body enclosing the instance should be frozen after the body
        --  that includes the generic, because the body of the instance may
--- 5012,5026 ----
          and then
            In_Same_Declarative_Part (Freeze_Node (Par), Inst_Node)
        then
!          if ABE_Is_Certain (Get_Package_Instantiation_Node (Par)) then
!             --  The parent was a premature instantiation. Insert freeze
!             --  node at the end the current declarative part.
! 
!             Insert_After_Last_Decl (Inst_Node, F_Node);
! 
!          else
!             Insert_After (Freeze_Node (Par), F_Node);
!          end if;
  
        --  The body enclosing the instance should be frozen after the body
        --  that includes the generic, because the body of the instance may


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