elsif not Comes_From_Source (Expr)
and then not
(Nkind (Expr) = N_Identifier
- and then Present (Renamed_Object (Entity (Expr)))
- and then Comes_From_Source (Renamed_Object (Entity (Expr))))
+ and then Present (Renamed_Entity_Or_Object (Entity (Expr)))
+ and then
+ Comes_From_Source (Renamed_Entity_Or_Object (Entity (Expr))))
and then not Force_Validity_Checks
and then (Nkind (Expr) /= N_Unchecked_Type_Conversion
or else Kill_Range_Check (Expr))
-- Determine whether abstract state State_Id has particular option denoted
-- by the name Option_Nam.
- -----------------------------------
- -- Renamings of Renamed_Or_Alias --
- -----------------------------------
+ -------------------------------------------
+ -- Aliases/Renamings of Renamed_Or_Alias --
+ -------------------------------------------
function Alias (N : Entity_Id) return Node_Id is
begin
- pragma Assert
- (Is_Overloadable (N) or else Ekind (N) = E_Subprogram_Type);
- return Renamed_Or_Alias (N);
+ return Val : constant Node_Id := Renamed_Or_Alias (N) do
+ pragma Assert
+ (Is_Overloadable (N) or else Ekind (N) = E_Subprogram_Type);
+ pragma Assert (Val in N_Entity_Id | N_Empty_Id);
+ end return;
end Alias;
procedure Set_Alias (N : Entity_Id; Val : Node_Id) is
begin
pragma Assert
(Is_Overloadable (N) or else Ekind (N) = E_Subprogram_Type);
+ pragma Assert (Val in N_Entity_Id | N_Empty_Id);
+
Set_Renamed_Or_Alias (N, Val);
end Set_Alias;
+ function Renamed_Entity (N : Entity_Id) return Node_Id is
+ begin
+ return Val : constant Node_Id := Renamed_Or_Alias (N) do
+ pragma Assert (not Is_Object (N) or else Etype (N) = Any_Type);
+ pragma Assert (Val in N_Entity_Id | N_Empty_Id);
+ end return;
+ end Renamed_Entity;
+
+ procedure Set_Renamed_Entity (N : Entity_Id; Val : Node_Id) is
+ begin
+ pragma Assert (not Is_Object (N));
+ pragma Assert (Val in N_Entity_Id);
+
+ Set_Renamed_Or_Alias (N, Val);
+ end Set_Renamed_Entity;
+
+ function Renamed_Object (N : Entity_Id) return Node_Id is
+ begin
+ return Val : constant Node_Id := Renamed_Or_Alias (N) do
+ -- Formal_Kind uses the entity, not a name of it. This happens
+ -- in front-end inlining, which also sets to Empty. Also in
+ -- Exp_Ch9, where formals are renamed for the benefit of gdb.
+
+ if Ekind (N) not in Formal_Kind then
+ pragma Assert (Is_Object (N));
+ pragma Assert (Val in N_Subexpr_Id | N_Empty_Id);
+ null;
+ end if;
+ end return;
+ end Renamed_Object;
+
+ procedure Set_Renamed_Object (N : Entity_Id; Val : Node_Id) is
+ begin
+ if Ekind (N) not in Formal_Kind then
+ pragma Assert (Is_Object (N));
+ pragma Assert (Val in N_Subexpr_Id | N_Empty_Id);
+ null;
+ end if;
+
+ Set_Renamed_Or_Alias (N, Val);
+ end Set_Renamed_Object;
+
+ function Renamed_Entity_Or_Object (N : Entity_Id) return Node_Id is
+ begin
+ if Is_Object (N) then
+ return Renamed_Object (N);
+ else
+ return Renamed_Entity (N);
+ end if;
+ end Renamed_Entity_Or_Object;
+
+ procedure Set_Renamed_Object_Of_Possibly_Void
+ (N : Entity_Id; Val : Node_Id)
+ is
+ begin
+ pragma Assert (Val in N_Subexpr_Id);
+ Set_Renamed_Or_Alias (N, Val);
+ end Set_Renamed_Object_Of_Possibly_Void;
+
----------------
-- Has_Option --
----------------
package Einfo.Utils is
- -----------------------------------
- -- Renamings of Renamed_Or_Alias --
- -----------------------------------
+ -------------------------------------------
+ -- Aliases/Renamings of Renamed_Or_Alias --
+ -------------------------------------------
-- See the comment in einfo.ads, "Renaming and Aliasing", which is somewhat
- -- incorrect. In fact, the compiler uses Alias, Renamed_Entity, and
- -- Renamed_Object more-or-less interchangeably, so we rename them here.
- -- Alias isn't really renamed, because we want an assertion in the body.
+ -- incorrect. Each of the following calls [Set_]Renamed_Or_Alias. Alias and
+ -- Renamed_Entity are fields of nonobject Entity_Ids, and the value of the
+ -- field is Entity_Id. Alias is only for callable entities and subprogram
+ -- types. We sometimes call Set_Renamed_Entity and then expect Alias to
+ -- return the value set. Renamed_Object is a field of Entity_Ids that are
+ -- objects, and it returns an expression, because you can rename things
+ -- like "X.all(J).Y". Renamings of entries and subprograms can also be
+ -- expressions, but those use different mechanisms; the fields here are not
+ -- used.
function Alias (N : Entity_Id) return Node_Id;
procedure Set_Alias (N : Entity_Id; Val : Node_Id);
- function Renamed_Entity
- (N : Entity_Id) return Node_Id renames Renamed_Or_Alias;
- procedure Set_Renamed_Entity
- (N : Entity_Id; Val : Node_Id) renames Set_Renamed_Or_Alias;
- function Renamed_Object
- (N : Entity_Id) return Node_Id renames Renamed_Or_Alias;
- procedure Set_Renamed_Object
- (N : Entity_Id; Val : Node_Id) renames Set_Renamed_Or_Alias;
+ function Renamed_Entity (N : Entity_Id) return Node_Id;
+ procedure Set_Renamed_Entity (N : Entity_Id; Val : Node_Id);
+ function Renamed_Object (N : Entity_Id) return Node_Id;
+ procedure Set_Renamed_Object (N : Entity_Id; Val : Node_Id);
+
+ function Renamed_Entity_Or_Object (N : Entity_Id) return Node_Id;
+ -- This getter is used when we don't know statically whether we want to
+ -- call Renamed_Entity or Renamed_Object.
+
+ procedure Set_Renamed_Object_Of_Possibly_Void
+ (N : Entity_Id; Val : Node_Id);
+ -- Set_Renamed_Object doesn't allow Void; this is used in the rare cases
+ -- where we set the field of an entity that might be Void. It might be a
+ -- good idea to get rid of calls to this.
pragma Inline (Alias);
pragma Inline (Set_Alias);
pragma Inline (Set_Renamed_Entity);
pragma Inline (Renamed_Object);
pragma Inline (Set_Renamed_Object);
+ pragma Inline (Renamed_Entity_Or_Object);
+ pragma Inline (Set_Renamed_Object_Of_Possibly_Void);
-------------------
-- Type Synonyms --
-- Several entity attributes relate to renaming constructs, and to the use of
-- different names to refer to the same entity. The following is a summary of
--- these constructs and their prefered uses.
+-- these constructs and their preferred uses.
-- There are three related attributes:
-- a) Renamed_Entity applies to entities in renaming declarations that rename
-- an entity, so the value of the attribute IS an entity. This applies to
--- generic renamings, package renamings, exception renamings, and subprograms
+-- generic renamings, package renamings, exception renamings, and subprogram
-- renamings that rename a subprogram (rather than an attribute, an entry, a
-- protected operation, etc).
-- in a few cases we need to use a loop to trace a chain of object renamings
-- where all of them happen to be entities. So:
--- X : integer;
--- Y : integer renames X; -- renamed object is the identifier X
--- Z : integer renames Y; -- renamed object is the identifier Y
+-- X : Integer;
+-- Y : Integer renames X; -- renamed object is the identifier X
+-- Z : Integer renames Y; -- renamed object is the identifier Y
-- The front-end does not store explicitly the fact that Z renames X.
if Ptyp = Standard_Exception_Type then
Id_Kind := RTE (RE_Exception_Id);
- if Present (Renamed_Object (Entity (Pref))) then
- Set_Entity (Pref, Renamed_Object (Entity (Pref)));
+ if Present (Renamed_Entity (Entity (Pref))) then
+ Set_Entity (Pref, Renamed_Entity (Entity (Pref)));
end if;
Rewrite (N,
-- If the exception is a renaming, use the exception that it
-- renames (which might be a predefined exception, e.g.).
- if Present (Renamed_Object (Id)) then
- Id := Renamed_Object (Id);
+ if Present (Renamed_Entity (Id)) then
+ Id := Renamed_Entity (Id);
end if;
-- Build a C-compatible string in case of no exception handlers,
Ent := Name (N);
while Nkind (Ent) in N_Has_Entity
and then Present (Entity (Ent))
+ and then Is_Object (Entity (Ent))
and then Present (Renamed_Object (Entity (Ent)))
loop
Ent := Renamed_Object (Entity (Ent));
-- At this point, Defining_Identifier (Obj_Decl) is no longer equal
-- to Obj_Def_Id.
- Set_Renamed_Object (Defining_Identifier (Obj_Decl), Call_Deref);
+ pragma Assert (Ekind (Defining_Identifier (Obj_Decl)) = E_Void);
+ Set_Renamed_Object_Of_Possibly_Void
+ (Defining_Identifier (Obj_Decl), Call_Deref);
-- If the original entity comes from source, then mark the new
-- entity as needing debug information, even though it's defined
--------------------------------
function Debug_Renaming_Declaration (N : Node_Id) return Node_Id is
+ pragma Assert
+ (Nkind (N) in N_Object_Renaming_Declaration
+ | N_Package_Renaming_Declaration
+ | N_Exception_Renaming_Declaration);
+
Loc : constant Source_Ptr := Sloc (N);
Ent : constant Node_Id := Defining_Entity (N);
Nam : constant Node_Id := Name (N);
| N_Identifier
=>
if No (Entity (Ren))
- or else not Present (Renamed_Object (Entity (Ren)))
+ or else not Present (Renamed_Entity_Or_Object (Entity (Ren)))
then
exit;
end if;
-- This is a renaming of a renaming: traverse until the final
-- renaming to see if anything is packed along the way.
- Ren := Renamed_Object (Entity (Ren));
+ Ren := Renamed_Entity_Or_Object (Entity (Ren));
when N_Selected_Component =>
declare
when others =>
if Is_Entity_Name (N)
+ and then Is_Object (Entity (N))
and then Present (Renamed_Object (Entity (N)))
then
return
-- created for entry parameters must be frozen.
if Ekind (E) = E_Package
- and then No (Renamed_Object (E))
+ and then No (Renamed_Entity (E))
and then not Is_Child_Unit (E)
and then not Is_Frozen (E)
then
-- Unreferenced
procedure Reset_Actual_Mapping_For_Inlined_Call (Subp : Entity_Id);
- -- Reset the Renamed_Object flags on the formals of Subp, which can be set
- -- by a call to Establish_Actual_Mapping_For_Inlined_Call.
+ -- Reset the Renamed_Object field to Empty on all formals of Subp, which
+ -- can be set by a call to Establish_Actual_Mapping_For_Inlined_Call.
------------------------------
-- Deferred Cleanup Actions --
-- as for some Java bindings and for generic instances).
if Ekind (E) = E_Package then
- if No (Renamed_Object (E)) then
+ if No (Renamed_Entity (E)) then
List_Entities (E, Bytes_Big_Endian);
end if;
function Same_Unit (N : Node_Id; P : Entity_Id) return Boolean is
begin
return Entity (N) = P
- or else (Present (Renamed_Object (P))
- and then Entity (N) = Renamed_Object (P));
+ or else (Present (Renamed_Entity (P))
+ and then Entity (N) = Renamed_Entity (P));
end Same_Unit;
-- Start of processing for Process_Body_Clauses
then
Style_Check := False;
- if Present (Renamed_Object (Nam)) then
+ if Present (Renamed_Entity (Nam)) then
Un :=
Load_Unit
(Load_Name =>
Get_Body_Name
(Get_Unit_Name
(Unit_Declaration_Node
- (Renamed_Object (Nam)))),
+ (Renamed_Entity (Nam)))),
Required => False,
Subunit => False,
Error_Node => N,
-- been analyzed.
Analyze (Parent (Parent (Entity (Pref))));
- pragma Assert (Renamed_Object (Entity (Pref)) = Par_Name);
+ pragma Assert (Renamed_Entity (Entity (Pref)) = Par_Name);
Par_Name := Entity (Pref);
end if;
("parent unit must be package or generic package", Lib_Unit);
raise Unrecoverable_Error;
- elsif Present (Renamed_Object (P_Name)) then
+ elsif Present (Renamed_Entity (P_Name)) then
Error_Msg_N ("parent unit cannot be a renaming", Lib_Unit);
raise Unrecoverable_Error;
-- Check for a formal package that is a package renaming
- if Present (Renamed_Object (Gen_Unit)) then
+ if Present (Renamed_Entity (Gen_Unit)) then
-- Indicate that unit is used, before replacing it with renamed
-- entity for use below.
Generate_Reference (Gen_Unit, N);
end if;
- Gen_Unit := Renamed_Object (Gen_Unit);
+ Gen_Unit := Renamed_Entity (Gen_Unit);
end if;
if Ekind (Gen_Unit) /= E_Generic_Package then
Set_Etype (Renaming_In_Par, Standard_Void_Type);
Set_Scope (Renaming_In_Par, Parent_Instance);
Set_Parent (Renaming_In_Par, Parent (Formal));
- Set_Renamed_Object (Renaming_In_Par, Formal);
+ Set_Renamed_Entity (Renaming_In_Par, Formal);
Append_Entity (Renaming_In_Par, Parent_Instance);
end if;
Set_Is_Instantiated (Gen_Unit);
Generate_Reference (Gen_Unit, N);
- if Present (Renamed_Object (Gen_Unit)) then
- Set_Is_Instantiated (Renamed_Object (Gen_Unit));
- Generate_Reference (Renamed_Object (Gen_Unit), N);
+ if Present (Renamed_Entity (Gen_Unit)) then
+ Set_Is_Instantiated (Renamed_Entity (Gen_Unit));
+ Generate_Reference (Renamed_Entity (Gen_Unit), N);
end if;
end if;
-- If generic is a renaming, get original generic unit
- if Present (Renamed_Object (Gen_Unit))
- and then Ekind (Renamed_Object (Gen_Unit)) = E_Generic_Package
+ if Present (Renamed_Entity (Gen_Unit))
+ and then Ekind (Renamed_Entity (Gen_Unit)) = E_Generic_Package
then
- Gen_Unit := Renamed_Object (Gen_Unit);
+ Gen_Unit := Renamed_Entity (Gen_Unit);
end if;
-- Verify that there are no circular instantiations
-- If renaming, get original unit
- if Present (Renamed_Object (Gen_Unit))
- and then Is_Generic_Subprogram (Renamed_Object (Gen_Unit))
+ if Present (Renamed_Entity (Gen_Unit))
+ and then Is_Generic_Subprogram (Renamed_Entity (Gen_Unit))
then
- Gen_Unit := Renamed_Object (Gen_Unit);
+ Gen_Unit := Renamed_Entity (Gen_Unit);
Set_Is_Instantiated (Gen_Unit);
Generate_Reference (Gen_Unit, N);
end if;
elsif Ekind (E1) = E_Package then
Check_Mismatch
(Ekind (E1) /= Ekind (E2)
- or else (Present (Renamed_Object (E2))
- and then Renamed_Object (E1) /=
- Renamed_Object (E2)));
+ or else (Present (Renamed_Entity (E2))
+ and then Renamed_Entity (E1) /=
+ Renamed_Entity (E2)));
elsif Is_Overloadable (E1) then
-- Verify that the actual subprograms match. Note that actuals
E := First_Entity (P_Id);
while Present (E) loop
if Ekind (E) = E_Package then
- if Renamed_Object (E) = P_Id then
+ if Renamed_Entity (E) = P_Id then
exit;
elsif Nkind (Parent (E)) /= N_Package_Renaming_Declaration then
-- formal part are also visible. Otherwise, ignore the entity
-- created to validate the actuals.
- if Renamed_Object (E) = Instance then
+ if Renamed_Entity (E) = Instance then
exit;
elsif Nkind (Parent (E)) /= N_Package_Renaming_Declaration then
and then not Is_Generic_Formal (E)
then
if Box_Present (Parent (Associated_Formal_Package (E))) then
- Check_Generic_Actuals (Renamed_Object (E), True);
+ Check_Generic_Actuals (Renamed_Entity (E), True);
else
- Check_Generic_Actuals (Renamed_Object (E), False);
+ Check_Generic_Actuals (Renamed_Entity (E), False);
end if;
Set_Is_Hidden (E, False);
Inst_Par := Entity (Prefix (Gen_Id));
if Ekind (Inst_Par) = E_Package
- and then Present (Renamed_Object (Inst_Par))
+ and then Present (Renamed_Entity (Inst_Par))
then
- Inst_Par := Renamed_Object (Inst_Par);
+ Inst_Par := Renamed_Entity (Inst_Par);
end if;
if Ekind (Inst_Par) = E_Package then
E := First_Entity (Entity (Prefix (Gen_Id)));
while Present (E) loop
- if Present (Renamed_Entity (E))
+ if not Is_Object (E)
+ and then Present (Renamed_Entity (E))
and then
Renamed_Entity (E) = Renamed_Entity (Entity (Gen_Id))
then
if Is_Generic_Unit (E)
and then Nkind (Parent (E)) in N_Generic_Renaming_Declaration
- and then Is_Child_Unit (Renamed_Object (E))
- and then Is_Generic_Unit (Scope (Renamed_Object (E)))
+ and then Is_Child_Unit (Renamed_Entity (E))
+ and then Is_Generic_Unit (Scope (Renamed_Entity (E)))
and then Nkind (Name (Parent (E))) = N_Expanded_Name
then
Rewrite (Gen_Id, New_Copy_Tree (Name (Parent (E))));
if Ekind (E1) = E_Package
and then Nkind (Parent (E1)) = N_Package_Renaming_Declaration
then
- if Renamed_Object (E1) = Pack then
+ if Renamed_Entity (E1) = Pack then
return True;
- elsif E1 = P or else Renamed_Object (E1) = P then
+ elsif E1 = P or else Renamed_Entity (E1) = P then
return False;
elsif Is_Actual_Of_Previous_Formal (E1) then
then
null;
- elsif Renamed_Object (E) = Par then
+ elsif Renamed_Entity (E) = Par then
return False;
- elsif Renamed_Object (E) = Pack then
+ elsif Renamed_Entity (E) = Pack then
return True;
elsif Is_Actual_Of_Previous_Formal (E) then
then
-- If this is the renaming for the parent instance, done
- if Renamed_Object (E) = Par then
+ if Renamed_Entity (E) = Par then
exit;
-- The visibility of a formal of an enclosing generic is already
null;
elsif Present (Associated_Formal_Package (E)) then
- Check_Generic_Actuals (Renamed_Object (E), True);
+ Check_Generic_Actuals (Renamed_Entity (E), True);
Set_Is_Hidden (E, False);
-- Find formal package in generic unit that corresponds to
-- The actual may be a renamed package, or an outer generic formal
-- package whose instantiation is converted into a renaming.
- if Present (Renamed_Object (Actual_Pack)) then
- Actual_Pack := Renamed_Object (Actual_Pack);
+ if Present (Renamed_Entity (Actual_Pack)) then
+ Actual_Pack := Renamed_Entity (Actual_Pack);
end if;
if Nkind (Analyzed_Formal) = N_Formal_Package_Declaration then
while Present (Actual) loop
exit when Ekind (Actual) = E_Package
- and then Present (Renamed_Object (Actual));
+ and then Present (Renamed_Entity (Actual));
if Chars (Actual) = Chars (Formal)
and then not Is_Scalar_Type (Actual)
Set_Instance_Of (Base_Type (E1), Base_Type (E2));
end if;
- if Ekind (E1) = E_Package and then No (Renamed_Object (E1)) then
+ if Ekind (E1) = E_Package and then No (Renamed_Entity (E1)) then
Map_Formal_Package_Entities (E1, E2);
end if;
end if;
---------------------------
procedure Restore_Nested_Formal (Formal : Entity_Id) is
+ pragma Assert (Ekind (Formal) = E_Package);
Ent : Entity_Id;
-
begin
- if Present (Renamed_Object (Formal))
- and then Denotes_Formal_Package (Renamed_Object (Formal), True)
+ if Present (Renamed_Entity (Formal))
+ and then Denotes_Formal_Package (Renamed_Entity (Formal), True)
then
return;
-- visible on exit from the instance, and therefore nothing needs
-- to be done either, except to keep it accessible.
- if Is_Package and then Renamed_Object (E) = Pack_Id then
+ if Is_Package and then Renamed_Entity (E) = Pack_Id then
exit;
elsif Nkind (Parent (E)) /= N_Package_Renaming_Declaration then
null;
elsif
- Denotes_Formal_Package (Renamed_Object (E), True, Pack_Id)
+ Denotes_Formal_Package (Renamed_Entity (E), True, Pack_Id)
then
Set_Is_Hidden (E, False);
else
declare
- Act_P : constant Entity_Id := Renamed_Object (E);
+ Act_P : constant Entity_Id := Renamed_Entity (E);
Id : Entity_Id;
begin
and then Id /= First_Private_Entity (Act_P)
loop
exit when Ekind (Id) = E_Package
- and then Renamed_Object (Id) = Act_P;
+ and then Renamed_Entity (Id) = Act_P;
Set_Is_Hidden (Id, True);
Set_Is_Potentially_Use_Visible (Id, In_Use (Act_P));
Ent := Lhs;
while Nkind (Ent) in N_Has_Entity
and then Present (Entity (Ent))
+ and then Is_Object (Entity (Ent))
and then Present (Renamed_Object (Entity (Ent)))
loop
Ent := Renamed_Object (Entity (Ent));
-- renaming declaration becomes hidden.
if Ekind (E) = E_Package
- and then Present (Renamed_Object (E))
- and then Renamed_Object (E) = Current_Scope
- and then Nkind (Parent (Renamed_Object (E))) =
+ and then Present (Renamed_Entity (E))
+ and then Renamed_Entity (E) = Current_Scope
+ and then Nkind (Parent (Renamed_Entity (E))) =
N_Package_Specification
- and then Present (Generic_Parent (Parent (Renamed_Object (E))))
+ and then Present (Generic_Parent (Parent (Renamed_Entity (E))))
then
Set_Is_Hidden (E);
Set_Is_Immediately_Visible (E, False);
and then Present (Entity (Nam))
and then Ekind (Entity (Nam)) = E_Exception
then
- if Present (Renamed_Object (Entity (Nam))) then
- Set_Renamed_Object (Id, Renamed_Object (Entity (Nam)));
+ if Present (Renamed_Entity (Entity (Nam))) then
+ Set_Renamed_Entity (Id, Renamed_Entity (Entity (Nam)));
else
- Set_Renamed_Object (Id, Entity (Nam));
+ Set_Renamed_Entity (Id, Entity (Nam));
end if;
-- The exception renaming declaration may become Ghost if it renames
Error_Msg_N ("invalid generic unit name", Name (N));
else
- if Present (Renamed_Object (Old_P)) then
- Set_Renamed_Object (New_P, Renamed_Object (Old_P));
+ if Present (Renamed_Entity (Old_P)) then
+ Set_Renamed_Entity (New_P, Renamed_Entity (Old_P));
else
- Set_Renamed_Object (New_P, Old_P);
+ Set_Renamed_Entity (New_P, Old_P);
end if;
-- The generic renaming declaration may become Ghost if it renames a
Mutate_Ekind (New_P, E_Package);
Set_Etype (New_P, Standard_Void_Type);
- if Present (Renamed_Object (Old_P)) then
- Set_Renamed_Object (New_P, Renamed_Object (Old_P));
+ if Present (Renamed_Entity (Old_P)) then
+ Set_Renamed_Entity (New_P, Renamed_Entity (Old_P));
else
- Set_Renamed_Object (New_P, Old_P);
+ Set_Renamed_Entity (New_P, Old_P);
end if;
-- The package renaming declaration may become Ghost if it renames a
Next_Entity (Id);
end loop;
- if Present (Renamed_Object (Pack)) then
- Set_In_Use (Renamed_Object (Pack), False);
- Set_Current_Use_Clause (Renamed_Object (Pack), Empty);
+ if Present (Renamed_Entity (Pack)) then
+ Set_In_Use (Renamed_Entity (Pack), False);
+ Set_Current_Use_Clause (Renamed_Entity (Pack), Empty);
end if;
if Chars (Pack) = Name_System
------------------------
function Declared_In_Actual (Pack : Entity_Id) return Boolean is
+ pragma Assert (Ekind (Pack) = E_Package);
Act : Entity_Id;
-
begin
if No (Associated_Formal_Package (Pack)) then
return False;
else
Act := First_Entity (Pack);
while Present (Act) loop
- if Renamed_Object (Pack) = Scop then
+ if Renamed_Entity (Pack) = Scop then
return True;
-- Check for end of list of actuals
elsif Ekind (Act) = E_Package
- and then Renamed_Object (Act) = Pack
+ and then Renamed_Entity (Act) = Pack
then
return False;
if Scope (E) = Scope (E2)
and then Ekind (E) = E_Package
- and then Present (Renamed_Object (E))
- and then Is_Generic_Instance (Renamed_Object (E))
- and then In_Open_Scopes (Renamed_Object (E))
+ and then Present (Renamed_Entity (E))
+ and then Is_Generic_Instance (Renamed_Entity (E))
+ and then In_Open_Scopes (Renamed_Entity (E))
and then Comes_From_Source (N)
then
Set_Is_Immediately_Visible (E, False);
-- original package.
if Ekind (P_Name) = E_Package
- and then Present (Renamed_Object (P_Name))
+ and then Present (Renamed_Entity (P_Name))
then
- P_Name := Renamed_Object (P_Name);
+ P_Name := Renamed_Entity (P_Name);
if From_Limited_With (P_Name)
and then not Unit_Is_Visible (Cunit (Get_Source_Unit (P_Name)))
Scop := Entity (Prefix (Nam));
if Ekind (Scop) = E_Package
- and then Present (Renamed_Object (Scop))
+ and then Present (Renamed_Entity (Scop))
then
- Scop := Renamed_Object (Scop);
+ Scop := Renamed_Entity (Scop);
end if;
-- Operator is visible if prefix of expanded name denotes
-- When a renaming exists we must check it for redundancy. The
-- original package would have already been seen at this point.
- if Present (Renamed_Object (Entity (Pack_Name))) then
- P := Renamed_Object (Entity (Pack_Name));
+ if Present (Renamed_Entity (Entity (Pack_Name))) then
+ P := Renamed_Entity (Entity (Pack_Name));
else
P := Entity (Pack_Name);
end if;
-- also in use (the flags on both entities must remain consistent, and a
-- subsequent use of either of them should be recognized as redundant).
- if Present (Renamed_Object (P)) then
- Set_In_Use (Renamed_Object (P));
- Set_Current_Use_Clause (Renamed_Object (P), N);
- Real_P := Renamed_Object (P);
+ if Present (Renamed_Entity (P)) then
+ Set_In_Use (Renamed_Entity (P));
+ Set_Current_Use_Clause (Renamed_Entity (P), N);
+ Real_P := Renamed_Entity (P);
else
Real_P := P;
end if;
-----------------------
function Ultimate_Variable (Var_Id : Entity_Id) return Entity_Id is
+ pragma Assert (Ekind (Var_Id) = E_Variable);
Ren_Id : Entity_Id;
-
begin
Ren_Id := Var_Id;
- while Present (Renamed_Entity (Ren_Id))
- and then Nkind (Renamed_Entity (Ren_Id)) in N_Entity
+ while Present (Renamed_Object (Ren_Id))
+ and then Nkind (Renamed_Object (Ren_Id)) in N_Entity
loop
- Ren_Id := Renamed_Entity (Ren_Id);
+ Ren_Id := Renamed_Object (Ren_Id);
end loop;
return Ren_Id;
-- Note: We check if the original node of the renaming comes
-- from source because the node may have been rewritten.
- elsif Present (Renamed_Object (E))
- and then Comes_From_Source (Original_Node (Renamed_Object (E)))
+ elsif Present (Renamed_Entity_Or_Object (E))
+ and then Comes_From_Source
+ (Original_Node (Renamed_Entity_Or_Object (E)))
then
- return Accessibility_Level (Renamed_Object (E));
-
- -- Move up renamed entities
-
- elsif Present (Renamed_Entity (E))
- and then Comes_From_Source (Original_Node (Renamed_Entity (E)))
- then
- return Accessibility_Level (Renamed_Entity (E));
+ return Accessibility_Level (Renamed_Entity_Or_Object (E));
-- Named access types get their level from their associated type
function Is_Valid_Renaming (N : Node_Id) return Boolean is
begin
if Is_Object_Renaming (N)
- and then not Is_Valid_Renaming (Renamed_Entity (Entity (N)))
+ and then not Is_Valid_Renaming (Renamed_Object (Entity (N)))
then
return False;
end if;
elsif Is_Object_Renaming (A1)
and then Is_Valid_Renaming (A1)
then
- return Denotes_Same_Object (Renamed_Entity (Entity (A1)), A2);
+ return Denotes_Same_Object (Renamed_Object (Entity (A1)), A2);
elsif Is_Object_Renaming (A2)
and then Is_Valid_Renaming (A2)
then
- return Denotes_Same_Object (A1, Renamed_Entity (Entity (A2)));
+ return Denotes_Same_Object (A1, Renamed_Object (Entity (A2)));
else
return False;
function Get_Generic_Entity (N : Node_Id) return Entity_Id is
Ent : constant Entity_Id := Entity (Name (N));
begin
- if Present (Renamed_Object (Ent)) then
- return Renamed_Object (Ent);
+ if Present (Renamed_Entity (Ent)) then
+ return Renamed_Entity (Ent);
else
return Ent;
end if;
------------------------
function Get_Renamed_Entity (E : Entity_Id) return Entity_Id is
- R : Entity_Id;
-
+ R : Entity_Id := E;
begin
- R := E;
while Present (Renamed_Entity (R)) loop
R := Renamed_Entity (R);
end loop;
-- declaration.
elsif Nkind (N) = N_Object_Renaming_Declaration then
- Set_Renamed_Object (Defining_Entity (Result), Name (Result));
+ Set_Renamed_Object_Of_Possibly_Void
+ (Defining_Entity (Result), Name (Result));
-- Update the First_Real_Statement attribute of a replicated
-- handled sequence of statements.
E1 := First_Entity (P);
while Present (E1) loop
- if Ekind (E1) = E_Package and then Renamed_Object (E1) = L then
+ if Ekind (E1) = E_Package and then Renamed_Entity (E1) = L then
Is_Visible_Renaming := not Is_Hidden (E1);
return E1;
elsif Ekind (E1) = E_Package
- and then No (Renamed_Object (E1))
+ and then No (Renamed_Entity (E1))
and then not Is_Generic_Instance (E1)
then
R := Find_Package_Renaming (E1, L);
(Def_Id : Entity_Id;
Loc : Source_Ptr) return Node_Id;
-- New_Occurrence_Of creates an N_Identifier node that is an occurrence of
- -- the defining identifier Def_Id. The Entity and Etype of the result are
- -- set from the given defining identifier as follows: Entity is a copy of
- -- Def_Id. Etype is a copy of Def_Id for types, and a copy of the Etype of
- -- Def_Id for other entities. Note that Is_Static_Expression is set if this
- -- call creates an occurrence of an enumeration literal.
+ -- the defining identifier Def_Id. The Entity of the result is Def_Id. The
+ -- Etype of the result is Def_Id for types, and Etype (Def_Id) otherwise.
+ -- Is_Static_Expression is set if this call creates an occurrence of an
+ -- enumeration literal.
function New_Suffixed_Name
(Related_Id : Name_Id;