Commit 5c20b5e2 by Ed Schonberg Committed by Arnaud Charlet

sem.adb (Do_Units_And_Dependents): Process bodies only for units that are in the…

sem.adb (Do_Units_And_Dependents): Process bodies only for units that are in the context of the main unit body.

	* sem.adb (Do_Units_And_Dependents): Process bodies only for units that
	are in the context of the main unit body.

From-SVN: r150008
parent ce14c577
2009-07-23 Ed Schonberg <schonberg@adacore.com>
* sem.adb (Do_Units_And_Dependents): Process bodies only for units that
are in the context of the main unit body.
2009-07-23 Sergey Rybin <rybin@adacore.com> 2009-07-23 Sergey Rybin <rybin@adacore.com>
* gnat_ugn.texi (Misnamed_Controlling_Parameters gnatcheck rule): Fix * gnat_ugn.texi (Misnamed_Controlling_Parameters gnatcheck rule): Fix
......
...@@ -107,6 +107,7 @@ package body Sem is ...@@ -107,6 +107,7 @@ package body Sem is
procedure Analyze (N : Node_Id) is procedure Analyze (N : Node_Id) is
begin begin
Debug_A_Entry ("analyzing ", N); Debug_A_Entry ("analyzing ", N);
-- Immediate return if already analyzed -- Immediate return if already analyzed
if Analyzed (N) then if Analyzed (N) then
...@@ -1688,9 +1689,7 @@ package body Sem is ...@@ -1688,9 +1689,7 @@ package body Sem is
-- Start of processing for Do_Unit_And_Dependents -- Start of processing for Do_Unit_And_Dependents
begin begin
if Seen (Unit_Num) then if not Seen (Unit_Num) then
return;
end if;
Seen (Unit_Num) := True; Seen (Unit_Num) := True;
...@@ -1718,29 +1717,19 @@ package body Sem is ...@@ -1718,29 +1717,19 @@ package body Sem is
if not Nkind_In (Item, N_Package_Body, N_Subprogram_Body) if not Nkind_In (Item, N_Package_Body, N_Subprogram_Body)
or else Acts_As_Spec (CU) or else Acts_As_Spec (CU)
or else (CU = Cunit (Main_Unit) and then Do_Main) or else (CU = Cunit (Main_Unit) and then Do_Main)
then then
Do_Action (CU, Item); Do_Action (CU, Item);
Done (Unit_Num) := True; Done (Unit_Num) := True;
end if; end if;
end if;
-- Process corresponding body of spec last. However, if this body is -- Process corresponding body of spec last. This is either the main
-- the main unit (because some dependent of the main unit depends on -- unit, or the body of a spec that is in the context of the main
-- the main unit's spec), we don't process it now. We also skip -- unit, and that is instantiated, or else contains a generic that
-- processing of the body of a unit named by pragma Extend_System, -- is instantiated, or a subprogram that is inlined in the main unit.
-- because it has cyclic dependences in some cases.
-- A body that is not the main unit is present because of inlining
-- and/or instantiations, and it is best to process a body as early
-- as possible after the spec (as if an Elaborate_Body were present).
-- Currently all such bodies are added to the units list. It might
-- be possible to restrict the list to those bodies that are used
-- in the main unit. Possible optimization ???
-- Such bodies can also appear in a circular dependency list, where -- We exclude bodies that may appear in a circular dependency list,
-- spec A depends on spec B and the body of B depends on spec A. -- where spec A depends on spec B and body of B depends on spec A.
-- This is not an elaboration issue, but body B must be excluded -- This is not an elaboration issue, but body B must be excluded
-- from the processing. -- from the processing.
...@@ -1752,6 +1741,10 @@ package body Sem is ...@@ -1752,6 +1741,10 @@ package body Sem is
-- Check whether this body depends on a spec that is pending, -- Check whether this body depends on a spec that is pending,
-- that is to say has been seen but not processed yet. -- that is to say has been seen but not processed yet.
-------------------------
-- Circular_Dependence --
-------------------------
function Circular_Dependence (B : Node_Id) return Boolean is function Circular_Dependence (B : Node_Id) return Boolean is
Item : Node_Id; Item : Node_Id;
UN : Unit_Number_Type; UN : Unit_Number_Type;
...@@ -1780,6 +1773,7 @@ package body Sem is ...@@ -1780,6 +1773,7 @@ package body Sem is
and then Body_Unit /= Cunit (Main_Unit) and then Body_Unit /= Cunit (Main_Unit)
and then Unit_Num /= Get_Source_Unit (System_Aux_Id) and then Unit_Num /= Get_Source_Unit (System_Aux_Id)
and then not Circular_Dependence (Body_Unit) and then not Circular_Dependence (Body_Unit)
and then Do_Main
then then
Do_Unit_And_Dependents (Body_Unit, Unit (Body_Unit)); Do_Unit_And_Dependents (Body_Unit, Unit (Body_Unit));
Do_Action (Body_Unit, Unit (Body_Unit)); Do_Action (Body_Unit, Unit (Body_Unit));
...@@ -1842,8 +1836,8 @@ package body Sem is ...@@ -1842,8 +1836,8 @@ package body Sem is
-- If it's a body, ignore it. Bodies appear in the list only -- If it's a body, ignore it. Bodies appear in the list only
-- because of inlining/instantiations, and they are processed -- because of inlining/instantiations, and they are processed
-- immediately after the corresponding specs. -- immediately after the corresponding specs. The main unit is
-- The main unit is processed separately after all other units. -- processed separately after all other units.
when N_Package_Body | N_Subprogram_Body => when N_Package_Body | N_Subprogram_Body =>
null; null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment