* [Ada] Refine types of variables with call to Scope as their initial values
@ 2021-05-05 8:20 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-05 8:20 UTC (permalink / raw)
To: gcc-patches; +Cc: Piotr Trojanek
[-- Attachment #1: Type: text/plain, Size: 559 bytes --]
Call to Scope returns an Entity_Id, not just Node_Id. This patch refines
the types in two occurrences of a call to Scope as an initial value.
Code cleanup; semantics is unaffected.
Tested on x86_64-pc-linux-gnu, committed on trunk
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.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2122 bytes --]
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
--- 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
--- 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-05 8:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 8:20 [Ada] Refine types of variables with call to Scope as their initial values Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).