-- use-package clauses to avoid circularities when installing context.
procedure Install_Siblings (U_Name : Entity_Id; N : Node_Id);
- -- In the compilation of a child unit, a child of any of the ancestor
+ -- In the compilation of a child unit, a child of any of the ancestor
-- units is directly visible if it is visible, because the parent is in
-- an enclosing scope. Iterate over context to find child units of U_Name
-- or of some ancestor of it.
----------------------
procedure Install_Siblings (U_Name : Entity_Id; N : Node_Id) is
- Item : Node_Id;
- Id : Entity_Id;
- Prev : Entity_Id;
+ Item : Node_Id;
+ Item_E : Entity_Id;
begin
-- Iterate over explicit with clauses, and check whether the scope of
or else Private_Present (N)
or else Nkind (Unit (N)) = N_Package_Body
then
- Id := Entity (Name (Item));
+ Item_E := Entity (Name (Item));
- if Is_Child_Unit (Id)
- and then Is_Ancestor_Package (Scope (Id), U_Name)
+ if Is_Child_Unit (Item_E)
+ and then Is_Ancestor_Package (Scope (Item_E), U_Name)
then
- Set_Is_Immediately_Visible (Id);
+ Set_Is_Immediately_Visible (Item_E);
-- Check for the presence of another unit in the context that
-- may be inadvertently hidden by the child.
- Prev := Current_Entity (Id);
+ declare
+ Clause : Node_Id;
+ Clause_E : Entity_Id;
- if Present (Prev)
- and then Is_Immediately_Visible (Prev)
- and then not Is_Child_Unit (Prev)
- then
- declare
- Clause : Node_Id;
+ begin
+ Clause := First (Context_Items (N));
+ while Present (Clause) loop
+ if Clause /= Item
+ and then Nkind (Clause) = N_With_Clause
+ and then not Limited_Present (Clause)
+ then
+ Clause_E := Entity (Name (Clause));
- begin
- Clause := First (Context_Items (N));
- while Present (Clause) loop
- if Nkind (Clause) = N_With_Clause
- and then Entity (Name (Clause)) = Prev
+ if not Is_Ancestor_Package (Clause_E, U_Name)
+ and then Chars (Clause_E) = Chars (Item_E)
+ and then not Has_Prefix (Name (Clause))
+ and then not In_Use (Clause_E)
then
Error_Msg_NE
- ("child unit& hides compilation unit " &
- "with the same name??",
- Name (Item), Id);
+ ("child unit& hides compilation unit "
+ & "with the same name??",
+ Name (Item),
+ Item_E);
exit;
end if;
+ end if;
- Next (Clause);
- end loop;
- end;
- end if;
+ Next (Clause);
+ end loop;
+ end;
-- The With_Clause may be on a grandchild or one of its further
-- descendants, which makes a child immediately visible. Examine
-- if current unit is A.C, and with_clause is on A.X.Y.Z, then X
-- is immediately visible.
- elsif Is_Child_Unit (Id) then
+ elsif Is_Child_Unit (Item_E) then
declare
Par : Entity_Id;
begin
- Par := Scope (Id);
+ Par := Scope (Item_E);
while Is_Child_Unit (Par) loop
if Is_Ancestor_Package (Scope (Par), U_Name) then
Set_Is_Immediately_Visible (Par);
-- is already a regular with_clause for it in the current unit.
elsif Private_Present (Item) then
- Id := Entity (Name (Item));
+ Item_E := Entity (Name (Item));
- if Is_Child_Unit (Id) then
+ if Is_Child_Unit (Item_E) then
declare
Clause : Node_Id;
and then Is_Entity_Name (Name (Clause))
and then not Private_Present (Clause)
then
- if Entity (Name (Clause)) = Id
+ if Entity (Name (Clause)) = Item_E
or else
(Nkind (Name (Clause)) = N_Expanded_Name
and then
Is_Entity_Name (Prefix (Name (Clause)))
- and then Entity (Prefix (Name (Clause))) = Id)
+ and then Entity (Prefix (Name (Clause)))
+ = Item_E)
then
return True;
end if;
end In_Context;
begin
- Set_Is_Visible_Lib_Unit (Id, In_Context);
+ Set_Is_Visible_Lib_Unit (Item_E, In_Context);
end;
end if;
end if;