[Ada] Refine types of variables with call to Scope as their initial values
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 13 Jan 2021 21:53:32 +0000 (22:53 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 5 May 2021 08:19:05 +0000 (04:19 -0400)
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.

gcc/ada/exp_ch4.adb
gcc/ada/exp_dbug.adb

index e8fa5a8..e29535e 100644 (file)
@@ -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
index a74157c..8a75367 100644 (file)
@@ -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;