diff options
author | Bob Duff <duff@adacore.com> | 2021-09-10 11:18:47 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-10-25 15:07:19 +0000 |
commit | 19e7eae5b917d782d20d59f3cbe3c344a06aafb7 (patch) | |
tree | 9ce172ecdff263011b199d8930143ca5fb481a51 /gcc | |
parent | bb20000c9f7fbe58e6630196dbfdf0a2ac440c34 (diff) | |
download | gcc-19e7eae5b917d782d20d59f3cbe3c344a06aafb7.zip gcc-19e7eae5b917d782d20d59f3cbe3c344a06aafb7.tar.gz gcc-19e7eae5b917d782d20d59f3cbe3c344a06aafb7.tar.bz2 |
[Ada] Renamed_Or_Alias cleanup
gcc/ada/
* einfo-utils.ads, einfo-utils.adb (Alias, Set_Alias,
Renamed_Entity, Set_Renamed_Entity, Renamed_Object,
Set_Renamed_Object): Add assertions that reflect how these are
supposed to be used and what they are supposed to return.
(Renamed_Entity_Or_Object): New getter.
(Set_Renamed_Object_Of_Possibly_Void): Setter that allows N to
be E_Void.
* checks.adb (Ensure_Valid): Use Renamed_Entity_Or_Object
because this is called for both cases.
* exp_dbug.adb (Debug_Renaming_Declaration): Use
Renamed_Entity_Or_Object because this is called for both cases.
Add assertions.
* exp_util.adb (Possible_Bit_Aligned_Component): Likewise.
* freeze.adb (Freeze_All_Ent): Likewise.
* sem_ch5.adb (Within_Function): Likewise.
* exp_attr.adb (Calculate_Header_Size): Call Renamed_Entity
instead of Renamed_Object.
* exp_ch11.adb (Expand_N_Raise_Statement): Likewise.
* repinfo.adb (Find_Declaration): Likewise.
* sem_ch10.adb (Same_Unit, Process_Spec_Clauses,
Analyze_With_Clause, Install_Parents): Likewise.
* sem_ch12.adb (Build_Local_Package, Needs_Body_Instantiated,
Build_Subprogram_Renaming, Check_Formal_Package_Instance,
Check_Generic_Actuals, In_Enclosing_Instance,
Denotes_Formal_Package, Process_Nested_Formal,
Check_Initialized_Types, Map_Formal_Package_Entities,
Restore_Nested_Formal): Likewise.
* sem_ch6.adb (Report_Conflict): Likewise.
* sem_ch8.adb (Analyze_Exception_Renaming,
Analyze_Generic_Renaming, Analyze_Package_Renaming,
Is_Primitive_Operator_In_Use, Declared_In_Actual,
Note_Redundant_Use): Likewise.
* sem_warn.adb (Find_Package_Renaming): Likewise.
* sem_elab.adb (Ultimate_Variable): Call Renamed_Object instead
of Renamed_Entity.
* exp_ch6.adb (Get_Function_Id): Call
Set_Renamed_Object_Of_Possibly_Void, because the defining
identifer is still E_Void at this point.
* sem_util.adb (Function_Call_Or_Allocator_Level): Likewise.
Remove redundant (unreachable) code.
(Is_Object_Renaming, Is_Valid_Renaming): Call Renamed_Object
instead of Renamed_Entity.
(Get_Fullest_View): Call Renamed_Entity instead of
Renamed_Object.
(Copy_Node_With_Replacement): Call
Set_Renamed_Object_Of_Possibly_Void because the defining entity
is sometimes E_Void.
* exp_ch5.adb (Expand_N_Assignment_Statement): Protect a call to
Renamed_Object with Is_Object to avoid assertion failure.
* einfo.ads: Minor comment fixes.
* inline.adb: Minor comment fixes.
* tbuild.ads: Minor comment fixes.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/checks.adb | 5 | ||||
-rw-r--r-- | gcc/ada/einfo-utils.adb | 75 | ||||
-rw-r--r-- | gcc/ada/einfo-utils.ads | 42 | ||||
-rw-r--r-- | gcc/ada/einfo.ads | 10 | ||||
-rw-r--r-- | gcc/ada/exp_attr.adb | 4 | ||||
-rw-r--r-- | gcc/ada/exp_ch11.adb | 4 | ||||
-rw-r--r-- | gcc/ada/exp_ch5.adb | 1 | ||||
-rw-r--r-- | gcc/ada/exp_ch6.adb | 4 | ||||
-rw-r--r-- | gcc/ada/exp_dbug.adb | 9 | ||||
-rw-r--r-- | gcc/ada/exp_util.adb | 1 | ||||
-rw-r--r-- | gcc/ada/freeze.adb | 2 | ||||
-rw-r--r-- | gcc/ada/inline.adb | 4 | ||||
-rw-r--r-- | gcc/ada/repinfo.adb | 2 | ||||
-rw-r--r-- | gcc/ada/sem_ch10.adb | 12 | ||||
-rw-r--r-- | gcc/ada/sem_ch12.adb | 83 | ||||
-rw-r--r-- | gcc/ada/sem_ch5.adb | 1 | ||||
-rw-r--r-- | gcc/ada/sem_ch6.adb | 8 | ||||
-rw-r--r-- | gcc/ada/sem_ch8.adb | 56 | ||||
-rw-r--r-- | gcc/ada/sem_elab.adb | 8 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 31 | ||||
-rw-r--r-- | gcc/ada/sem_warn.adb | 4 | ||||
-rw-r--r-- | gcc/ada/tbuild.ads | 9 |
22 files changed, 228 insertions, 147 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index c85cba9a5..6823f06 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -6676,8 +6676,9 @@ package body Checks is 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)) diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 0c89c82..eb90d18 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -43,24 +43,87 @@ package body Einfo.Utils is -- 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 -- ---------------- diff --git a/gcc/ada/einfo-utils.ads b/gcc/ada/einfo-utils.ads index 0e6c8cd..c82b469 100644 --- a/gcc/ada/einfo-utils.ads +++ b/gcc/ada/einfo-utils.ads @@ -27,25 +27,37 @@ with Einfo.Entities; use Einfo.Entities; 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); @@ -53,6 +65,8 @@ package Einfo.Utils is 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 -- diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 13440ce..51cb014 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -4762,7 +4762,7 @@ package Einfo is -- 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: @@ -4775,7 +4775,7 @@ package Einfo is -- 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). @@ -4797,9 +4797,9 @@ package Einfo is -- 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. diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 49f5c94..19d8286 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -3898,8 +3898,8 @@ package body Exp_Attr is 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, diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb index 40288e4..d27ac6a 100644 --- a/gcc/ada/exp_ch11.adb +++ b/gcc/ada/exp_ch11.adb @@ -1667,8 +1667,8 @@ package body Exp_Ch11 is -- 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, diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index 21ac2a2..47c6b80 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -2387,6 +2387,7 @@ package body Exp_Ch5 is 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)); diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 3f83685..6015993 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -9707,7 +9707,9 @@ package body Exp_Ch6 is -- 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 diff --git a/gcc/ada/exp_dbug.adb b/gcc/ada/exp_dbug.adb index 96d78cc..19d546e 100644 --- a/gcc/ada/exp_dbug.adb +++ b/gcc/ada/exp_dbug.adb @@ -290,6 +290,11 @@ package body Exp_Dbug is -------------------------------- 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); @@ -410,7 +415,7 @@ package body Exp_Dbug is | 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; @@ -418,7 +423,7 @@ package body Exp_Dbug is -- 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 diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 9bc9449..861442b 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -11257,6 +11257,7 @@ package body Exp_Util is when others => if Is_Entity_Name (N) + and then Is_Object (Entity (N)) and then Present (Renamed_Object (Entity (N))) then return diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index fac7094..5048156 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -2337,7 +2337,7 @@ package body Freeze is -- 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 diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index 773b376..16a9894 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -327,8 +327,8 @@ package body Inline is -- 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 -- diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index 83d9681..f1ab718 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -571,7 +571,7 @@ package body Repinfo is -- 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; diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 5b54e7d..6305bdb 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -341,8 +341,8 @@ package body Sem_Ch10 is 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 @@ -1102,14 +1102,14 @@ package body Sem_Ch10 is 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, @@ -2870,7 +2870,7 @@ package body Sem_Ch10 is -- 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; @@ -4173,7 +4173,7 @@ package body Sem_Ch10 is ("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; diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index a62eb7c..d46d65c 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -2935,7 +2935,7 @@ package body Sem_Ch12 is -- 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. @@ -2945,7 +2945,7 @@ package body Sem_Ch12 is 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 @@ -3117,7 +3117,7 @@ package body Sem_Ch12 is 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; @@ -4287,9 +4287,9 @@ package body Sem_Ch12 is 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; @@ -4312,10 +4312,10 @@ package body Sem_Ch12 is -- 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 @@ -5692,10 +5692,10 @@ package body Sem_Ch12 is -- 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; @@ -6856,9 +6856,9 @@ package body Sem_Ch12 is 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 @@ -6929,7 +6929,7 @@ package body Sem_Ch12 is 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 @@ -7128,7 +7128,7 @@ package body Sem_Ch12 is -- 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 @@ -7144,10 +7144,10 @@ package body Sem_Ch12 is 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); @@ -7380,9 +7380,9 @@ package body Sem_Ch12 is 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 @@ -7584,7 +7584,8 @@ package body Sem_Ch12 is 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 @@ -7621,8 +7622,8 @@ package body Sem_Ch12 is 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)))); @@ -8691,10 +8692,10 @@ package body Sem_Ch12 is 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 @@ -8744,10 +8745,10 @@ package body Sem_Ch12 is 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 @@ -10079,7 +10080,7 @@ package body Sem_Ch12 is 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 @@ -10089,7 +10090,7 @@ package body Sem_Ch12 is 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 @@ -10699,8 +10700,8 @@ package body Sem_Ch12 is -- 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 @@ -11798,7 +11799,7 @@ package body Sem_Ch12 is 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) @@ -14791,7 +14792,7 @@ package body Sem_Ch12 is 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; @@ -15347,11 +15348,11 @@ package body Sem_Ch12 is --------------------------- 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; @@ -15490,20 +15491,20 @@ package body Sem_Ch12 is -- 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 @@ -15512,7 +15513,7 @@ package body Sem_Ch12 is 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)); diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 45d2457..e62161a 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -682,6 +682,7 @@ package body Sem_Ch5 is 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)); diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 1486918..c608c77 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -11981,11 +11981,11 @@ package body Sem_Ch6 is -- 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); diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 7b3dfa6..a7b3a16 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -576,10 +576,10 @@ package body Sem_Ch8 is 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 @@ -706,10 +706,10 @@ package body Sem_Ch8 is 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 @@ -1658,10 +1658,10 @@ package body Sem_Ch8 is 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 @@ -5008,9 +5008,9 @@ package body Sem_Ch8 is 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 @@ -5224,8 +5224,8 @@ package body Sem_Ch8 is ------------------------ 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; @@ -5233,13 +5233,13 @@ package body Sem_Ch8 is 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; @@ -6056,9 +6056,9 @@ package body Sem_Ch8 is 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); @@ -6389,9 +6389,9 @@ package body Sem_Ch8 is -- 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))) @@ -7196,9 +7196,9 @@ package body Sem_Ch8 is 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 @@ -9882,8 +9882,8 @@ package body Sem_Ch8 is -- 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; @@ -9949,10 +9949,10 @@ package body Sem_Ch8 is -- 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; diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index 1fbe037..c906708 100644 --- a/gcc/ada/sem_elab.adb +++ b/gcc/ada/sem_elab.adb @@ -3815,14 +3815,14 @@ package body Sem_Elab is ----------------------- 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; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 4dfee1e..193afc5 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -723,17 +723,11 @@ package body Sem_Util is -- 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 @@ -7369,7 +7363,7 @@ package body Sem_Util is 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; @@ -7561,12 +7555,12 @@ package body Sem_Util is 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; @@ -10888,8 +10882,8 @@ package body Sem_Util is 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; @@ -11406,10 +11400,8 @@ package body Sem_Util is ------------------------ 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; @@ -24097,7 +24089,8 @@ package body Sem_Util is -- 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. diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 9e337f9..85945bb 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -2408,12 +2408,12 @@ package body Sem_Warn is 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); diff --git a/gcc/ada/tbuild.ads b/gcc/ada/tbuild.ads index eb17865..5199e6d 100644 --- a/gcc/ada/tbuild.ads +++ b/gcc/ada/tbuild.ads @@ -312,11 +312,10 @@ package Tbuild is (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; |