* [Ada] Use more straightforward implementation for Current_Entity_In_Scope
@ 2021-06-16 8:43 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-16 8:43 UTC (permalink / raw)
To: gcc-patches; +Cc: Eric Botcazou
[-- Attachment #1: Type: text/plain, Size: 256 bytes --]
This new version is both more straightforward to understand and to map
to the generated code at high optimization. No functional changes.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_util.adb (Current_Entity_In_Scope): Reimplement.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1106 bytes --]
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -6955,19 +6955,30 @@ package body Sem_Util is
-----------------------------
function Current_Entity_In_Scope (N : Name_Id) return Entity_Id is
- E : Entity_Id;
CS : constant Entity_Id := Current_Scope;
- Transient_Case : constant Boolean := Scope_Is_Transient;
+ E : Entity_Id;
begin
E := Get_Name_Entity_Id (N);
- while Present (E)
- and then Scope (E) /= CS
- and then (not Transient_Case or else Scope (E) /= Scope (CS))
- loop
- E := Homonym (E);
- end loop;
+
+ if No (E) then
+ null;
+
+ elsif Scope_Is_Transient then
+ while Present (E) loop
+ exit when Scope (E) = CS or else Scope (E) = Scope (CS);
+
+ E := Homonym (E);
+ end loop;
+
+ else
+ while Present (E) loop
+ exit when Scope (E) = CS;
+
+ E := Homonym (E);
+ end loop;
+ end if;
return E;
end Current_Entity_In_Scope;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-16 8:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 8:43 [Ada] Use more straightforward implementation for Current_Entity_In_Scope 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).