diff options
author | Ed Schonberg <schonberg@adacore.com> | 2019-07-09 07:53:35 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-09 07:53:35 +0000 |
commit | 93ba65d54c7d4e5f3dc4612c642a585dc274344e (patch) | |
tree | d010ae08ae7acc4b163a25cd69faec0fee584229 | |
parent | 9ae497cb69e5a944e29225a402883ad359d5c031 (diff) | |
download | gcc-93ba65d54c7d4e5f3dc4612c642a585dc274344e.zip gcc-93ba65d54c7d4e5f3dc4612c642a585dc274344e.tar.gz gcc-93ba65d54c7d4e5f3dc4612c642a585dc274344e.tar.bz2 |
[Ada] Fix scopes for local variables in task/protected bodies
No impact on compilation with GCC.
2019-07-09 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_util.adb (Scope_Within_Or_Same): Handle properly task
bodies and protected bodies, so that local variables within have
their proper scopes after these constructs have been rewritten
during expansion. This patch resembles but is not identical to
the code in Scope_Within.
From-SVN: r273269
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 25 |
2 files changed, 30 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1e109c2..c5fa67f 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2019-07-09 Ed Schonberg <schonberg@adacore.com> + + * sem_util.adb (Scope_Within_Or_Same): Handle properly task + bodies and protected bodies, so that local variables within have + their proper scopes after these constructs have been rewritten + during expansion. This patch resembles but is not identical to + the code in Scope_Within. + 2019-07-09 Arnaud Charlet <charlet@adacore.com> * gnat1drv.adb (Adjust_Global_Switches): Set diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 0d4ec9c..7b7d044 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -24268,13 +24268,32 @@ package body Sem_Util is (Inner : Entity_Id; Outer : Entity_Id) return Boolean is - Curr : Entity_Id; - + Curr : Entity_Id := Inner; begin - Curr := Inner; + -- Similar to the above, but check for scope identity first. + while Present (Curr) and then Curr /= Standard_Standard loop if Curr = Outer then return True; + + elsif Ekind (Curr) = E_Task_Type + and then Outer = Task_Body_Procedure (Curr) + then + return True; + + elsif Is_Subprogram (Curr) + and then Outer = Protected_Body_Subprogram (Curr) + then + return True; + + elsif Is_Private_Type (Curr) + and then Present (Full_View (Curr)) + then + if Full_View (Curr) = Outer then + return True; + else + return Scope_Within (Full_View (Curr), Outer); + end if; end if; Curr := Scope (Curr); |