diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2021-02-21 18:27:25 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-06-16 04:42:59 -0400 |
commit | 663e6d7960199559ebd3107a28ea1cfda3e5be00 (patch) | |
tree | adccdbdaf9d9dd4293ec53298b66a1240b6e4fb1 /gcc | |
parent | 3e07c2df705ca3e8be98c708773e450e0543480b (diff) | |
download | gcc-663e6d7960199559ebd3107a28ea1cfda3e5be00.zip gcc-663e6d7960199559ebd3107a28ea1cfda3e5be00.tar.gz gcc-663e6d7960199559ebd3107a28ea1cfda3e5be00.tar.bz2 |
[Ada] Use more straightforward implementation for Current_Entity_In_Scope
gcc/ada/
* sem_util.adb (Current_Entity_In_Scope): Reimplement.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_util.adb | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index c9a2c9f..9b2bf86 100644 --- 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; |