-- the latter case it is critical to make a call to Set_RTU_Loaded to
-- ensure that the entry in this table reflects the load.
+ -- Withed is True if an implicit with_clause has been added from some unit
+ -- other than the main unit to this unit. Withed_By_Main is the same,
+ -- except from the main unit.
+
type RT_Unit_Table_Record is record
- Entity : Entity_Id;
- Uname : Unit_Name_Type;
- Unum : Unit_Number_Type;
- Withed : Boolean;
+ Entity : Entity_Id;
+ Uname : Unit_Name_Type;
+ Unum : Unit_Number_Type;
+ Withed : Boolean;
+ Withed_By_Main : Boolean;
end record;
RT_Unit_Table : array (RTU_Id) of RT_Unit_Table_Record;
RE_Table : array (RE_Id) of Entity_Id;
- --------------------------
- -- Generation of WITH's --
- --------------------------
+ --------------------------------
+ -- Generation of with_clauses --
+ --------------------------------
-- When a unit is implicitly loaded as a result of a call to RTE, it is
- -- necessary to create an implicit WITH to ensure that the object is
- -- correctly loaded by the binder. Such WITH statements are only required
- -- when the request is from the extended main unit (if a client needs a
- -- WITH, that will be taken care of when the client is compiled).
+ -- necessary to create one or two implicit with_clauses. We add such
+ -- with_clauses to the extended main unit if needed, and also to whatever
+ -- unit first needs them, which is not necessarily the main unit. The
+ -- former ensures that the object is correctly loaded by the binder. The
+ -- latter is necessary for SofCheck Inspector.
- -- We always attach the WITH to the main unit. This is not perfectly
- -- accurate in terms of elaboration requirements, but it is close enough,
- -- since the units that are accessed using rtsfind do not have delicate
- -- elaboration requirements.
-
- -- The flag Withed in the unit table record is initially set to False. It
- -- is set True if a WITH has been generated for the main unit for the
- -- corresponding unit.
+ -- The flags Withed and Withed_By_Main in the unit table record are used to
+ -- avoid duplicates.
-----------------------
-- Local Subprograms --
-- If the unit is a child unit, build fully qualified name for use in
-- With_Clause.
+ procedure Maybe_Add_With (E : RE_Id; U : in out RT_Unit_Table_Record);
+ -- If necessary, add an implicit with_clause from the current unit to the
+ -- one represented by E and U.
+
procedure Output_Entity_Name (Id : RE_Id; Msg : String);
-- Output continuation error message giving qualified name of entity
-- corresponding to Id, appending the string given by Msg. This call
procedure Save_Private_Visibility;
-- If the current unit is the body of child unit or the spec of a
- -- private child unit, the private declarations of the parent (s)
- -- are visible. If the unit to be loaded is another public sibling,
- -- its compilation will affect the visibility of the common ancestors.
+ -- private child unit, the private declarations of the parent(s) are
+ -- visible. If the unit to be loaded is another public sibling, its
+ -- compilation will affect the visibility of the common ancestors.
-- Indicate those that must be restored.
procedure Restore_Private_Visibility;
-- Otherwise we need to load the unit, First build unit name
-- from the enumeration literal name in type RTU_Id.
- U.Uname := Get_Unit_Name (U_Id);
- U.Withed := False;
-
- declare
- Loaded : Boolean;
- pragma Warnings (Off, Loaded);
- begin
- Loaded := Is_Loaded (U.Uname);
- end;
+ U.Uname := Get_Unit_Name (U_Id);
+ U.Withed := False;
+ U.Withed_By_Main := False;
-- Now do the load call, note that setting Error_Node to Empty is
-- a signal to Load_Unit that we will regard a failure to find the
if not Analyzed (Cunit (U.Unum)) then
- -- If the unit is already loaded through a limited_with clauses,
+ -- If the unit is already loaded through a limited_with_clause,
-- the relevant entities must already be available. We do not
-- want to load and analyze the unit because this would create
-- a real semantic dependence when the purpose of the limited_with
return Nam;
end Make_Unit_Name;
- -----------------------
+ --------------------
+ -- Maybe_Add_With --
+ --------------------
+
+ procedure Maybe_Add_With (E : RE_Id; U : in out RT_Unit_Table_Record) is
+ Is_Main : constant Boolean :=
+ In_Extended_Main_Code_Unit (Cunit_Entity (Current_Sem_Unit));
+
+ begin
+ -- We do not need to generate a with_clause for a call issued from
+ -- RTE_Component_Available.
+
+ if RTE_Available_Call then
+ return;
+ end if;
+
+ -- If the current unit is the main one, add the with_clause unless it's
+ -- already been done.
+
+ if Is_Main then
+ if U.Withed_By_Main then
+ return;
+ else
+ U.Withed_By_Main := True;
+ end if;
+
+ -- If the current unit is not the main one, add the with_clause unless
+ -- it's already been done for some non-main unit.
+
+ else
+ if U.Withed then
+ return;
+ else
+ U.Withed := True;
+ end if;
+ end if;
+
+ -- Here if we've decided to add the with_clause
+
+ declare
+ LibUnit : constant Node_Id := Unit (Cunit (U.Unum));
+ Withn : constant Node_Id :=
+ Make_With_Clause (Standard_Location,
+ Name =>
+ Make_Unit_Name
+ (E, Defining_Unit_Name (Specification (LibUnit))));
+
+ begin
+ Set_Library_Unit (Withn, Cunit (U.Unum));
+ Set_Corresponding_Spec (Withn, U.Entity);
+ Set_First_Name (Withn, True);
+ Set_Implicit_With (Withn, True);
+
+ Mark_Rewrite_Insertion (Withn);
+ Append (Withn, Context_Items (Cunit (Current_Sem_Unit)));
+ Check_Restriction_No_Dependence (Name (Withn), Current_Error_Node);
+ end;
+ end Maybe_Add_With;
+
+ ------------------------
-- Output_Entity_Name --
------------------------
---------------
procedure Check_RPC is
-
- procedure Check_RPC_Failure (Msg : String);
- pragma No_Return (Check_RPC_Failure);
- -- Display Msg on standard error and raise Unrecoverable_Error
-
- -----------------------
- -- Check_RPC_Failure --
- -----------------------
-
- procedure Check_RPC_Failure (Msg : String) is
- begin
- Set_Standard_Error;
- Write_Str (Msg);
- Write_Eol;
- raise Unrecoverable_Error;
- end Check_RPC_Failure;
-
- -- Start of processing for Check_RPC
-
begin
-- Bypass this check if debug flag -gnatdR set
return;
end if;
- -- Otherwise we need the check if we are going after one of
- -- the critical entities in System.RPC in stubs mode.
-
- -- ??? Should we do this for other s-parint entities too?
-
- if (Distribution_Stub_Mode = Generate_Receiver_Stub_Body
- or else
- Distribution_Stub_Mode = Generate_Caller_Stub_Body)
- and then (E = RE_Do_Rpc
- or else
- E = RE_Do_Apc
- or else
- E = RE_Params_Stream_Type
- or else
- E = RE_Request_Access)
+ -- Otherwise we need the check if we are going after one of the
+ -- critical entities in System.RPC / System.Partition_Interface.
+
+ if E = RE_Do_Rpc
+ or else
+ E = RE_Do_Apc
+ or else
+ E = RE_Params_Stream_Type
+ or else
+ E = RE_Request_Access
then
- if Get_PCS_Name = Name_No_DSA then
- Check_RPC_Failure ("distribution feature not supported");
+ -- If generating RCI stubs, check that we have a real PCS
+
+ if (Distribution_Stub_Mode = Generate_Receiver_Stub_Body
+ or else
+ Distribution_Stub_Mode = Generate_Caller_Stub_Body)
+ and then Get_PCS_Name = Name_No_DSA
+ then
+ Set_Standard_Error;
+ Write_Str ("distribution feature not supported");
+ Write_Eol;
+ raise Unrecoverable_Error;
+
+ -- In all cases, check Exp_Dist and System.Partition_Interface
+ -- consistency.
elsif Get_PCS_Version /=
Exp_Dist.PCS_Version_Number (Get_PCS_Name)
then
- Check_RPC_Failure ("PCS version mismatch");
-
+ Set_Standard_Error;
+ Write_Str ("PCS version mismatch: expander ");
+ Write_Int (Exp_Dist.PCS_Version_Number (Get_PCS_Name));
+ Write_Str (", PCS (");
+ Write_Name (Get_PCS_Name);
+ Write_Str (") ");
+ Write_Int (Get_PCS_Version);
+ Write_Eol;
+ raise Unrecoverable_Error;
end if;
end if;
end Check_RPC;
end if;
end if;
- -- See if we have to generate a WITH for this entity. We generate
- -- a WITH if the current unit is part of the extended main code
- -- unit, and if we have not already added the with. The WITH is
- -- added to the appropriate unit (the current one). We do not need
- -- to generate a WITH for a call issued from RTE_Available.
-
<<Found>>
- if (not U.Withed)
- and then
- In_Extended_Main_Code_Unit (Cunit_Entity (Current_Sem_Unit))
- and then not RTE_Available_Call
- then
- U.Withed := True;
-
- declare
- Withn : Node_Id;
- Lib_Unit : Node_Id;
-
- begin
- Lib_Unit := Unit (Cunit (U.Unum));
- Withn :=
- Make_With_Clause (Standard_Location,
- Name =>
- Make_Unit_Name
- (E, Defining_Unit_Name (Specification (Lib_Unit))));
- Set_Library_Unit (Withn, Cunit (U.Unum));
- Set_Corresponding_Spec (Withn, U.Entity);
- Set_First_Name (Withn, True);
- Set_Implicit_With (Withn, True);
-
- Mark_Rewrite_Insertion (Withn);
- Append (Withn, Context_Items (Cunit (Current_Sem_Unit)));
- Check_Restriction_No_Dependence (Name (Withn), Current_Error_Node);
- end;
- end if;
+ Maybe_Add_With (E, U);
Front_End_Inlining := Save_Front_End_Inlining;
return Check_CRT (E, RE_Table (E));
-- If we didn't find the entity we want, something is wrong. The
-- appropriate action will be taken by Check_CRT when we exit.
- -- Generate a with-clause if the current unit is part of the extended
- -- main code unit, and if we have not already added the with. The clause
- -- is added to the appropriate unit (the current one). We do not need to
- -- generate it for a call issued from RTE_Component_Available.
-
- if (not U.Withed)
- and then
- In_Extended_Main_Code_Unit (Cunit_Entity (Current_Sem_Unit))
- and then not RTE_Available_Call
- then
- U.Withed := True;
-
- declare
- Withn : Node_Id;
- Lib_Unit : Node_Id;
-
- begin
- Lib_Unit := Unit (Cunit (U.Unum));
- Withn :=
- Make_With_Clause (Standard_Location,
- Name =>
- Make_Unit_Name
- (E, Defining_Unit_Name (Specification (Lib_Unit))));
- Set_Library_Unit (Withn, Cunit (U.Unum));
- Set_Corresponding_Spec (Withn, U.Entity);
- Set_First_Name (Withn, True);
- Set_Implicit_With (Withn, True);
-
- Mark_Rewrite_Insertion (Withn);
- Append (Withn, Context_Items (Cunit (Current_Sem_Unit)));
- Check_Restriction_No_Dependence (Name (Withn), Current_Error_Node);
- end;
- end if;
+ Maybe_Add_With (E, U);
Front_End_Inlining := Save_Front_End_Inlining;
return Check_CRT (E, Found_E);
-- If entry is not set, set it now
if No (U.Entity) then
- U.Entity := E;
- U.Uname := Get_Unit_Name (U_Id);
- U.Unum := Unum;
- U.Withed := False;
+ U := (Entity => E,
+ Uname => Get_Unit_Name (U_Id),
+ Unum => Unum,
+ Withed => False,
+ Withed_By_Main => False);
end if;
return;