From: Piotr Trojanek Date: Wed, 13 Jan 2021 21:53:32 +0000 (+0100) Subject: [Ada] Refine types of variables with call to Scope as their initial values X-Git-Tag: basepoints/gcc-13~7810 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3870f3bcf02c780d73639080d5195f4be4ef1ac;p=thirdparty%2Fgcc.git [Ada] Refine types of variables with call to Scope as their initial values gcc/ada/ * exp_ch4.adb (User_Defined_Primitive_Equality_Op): Refine type of a local variable. * exp_dbug.adb (Scope_Contains): Refine all types from Node_Id to Entity_Id; rename parameters to match those of the Scope_Within routine (which is similar but not the same); also, simplify an OR ELSE into a membership test. --- diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index e8fa5a8f3f54..e29535ec7028 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -8082,7 +8082,7 @@ package body Exp_Ch4 is function User_Defined_Primitive_Equality_Op (Typ : Entity_Id) return Entity_Id is - Enclosing_Scope : constant Node_Id := Scope (Typ); + Enclosing_Scope : constant Entity_Id := Scope (Typ); E : Entity_Id; begin for Private_Entities in Boolean loop diff --git a/gcc/ada/exp_dbug.adb b/gcc/ada/exp_dbug.adb index a74157c0fc59..8a7536760e83 100644 --- a/gcc/ada/exp_dbug.adb +++ b/gcc/ada/exp_dbug.adb @@ -315,8 +315,11 @@ package body Exp_Dbug is -- output in one of these two forms. The result is prepended to the -- name stored in Name_Buffer. - function Scope_Contains (Sc : Node_Id; Ent : Entity_Id) return Boolean; - -- Return whether Ent belong to the Sc scope + function Scope_Contains + (Outer : Entity_Id; + Inner : Entity_Id) + return Boolean; + -- Return whether Inner belongs to the Outer scope ---------------------------- -- Enable_If_Packed_Array -- @@ -344,8 +347,7 @@ package body Exp_Dbug is elsif Nkind (N) = N_Identifier and then Scope_Contains (Scope (Entity (N)), Ent) - and then (Ekind (Entity (N)) = E_Constant - or else Ekind (Entity (N)) = E_In_Parameter) + and then Ekind (Entity (N)) in E_Constant | E_In_Parameter then Prepend_String_To_Buffer (Get_Name_String (Chars (Entity (N)))); @@ -361,12 +363,16 @@ package body Exp_Dbug is -- Scope_Contains -- -------------------- - function Scope_Contains (Sc : Node_Id; Ent : Entity_Id) return Boolean is - Cur : Node_Id := Scope (Ent); + function Scope_Contains + (Outer : Entity_Id; + Inner : Entity_Id) + return Boolean + is + Cur : Entity_Id := Scope (Inner); begin while Present (Cur) loop - if Cur = Sc then + if Cur = Outer then return True; end if;