diff options
author | Ed Schonberg <schonberg@adacore.com> | 2018-07-17 08:06:55 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-07-17 08:06:55 +0000 |
commit | 3567ca3f6be029d5a68722b675df74c2c6945854 (patch) | |
tree | 0fcc14e6808f8c572ba618866885b20f17d5eaab /gcc | |
parent | eae2aa7ce1e52e5789410d0ad2d3e10c77ac2fc4 (diff) | |
download | gcc-3567ca3f6be029d5a68722b675df74c2c6945854.zip gcc-3567ca3f6be029d5a68722b675df74c2c6945854.tar.gz gcc-3567ca3f6be029d5a68722b675df74c2c6945854.tar.bz2 |
[Ada] Fix Enclosing_Subprogram for protected entries and task entries
2018-07-17 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_util.adb (Enclosing_Subprogram): Protected entries and task
entries must be treated separately: task entries are within the
enclosing subprogram of the task type, while protected entries are
transformed into the corresponding Protected_Body_Subprogram, which is
the enclosing_subprogram of any subprogram declared within the entry
body.
From-SVN: r262778
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 19 |
2 files changed, 26 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 8204519..4f747f2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2018-07-17 Ed Schonberg <schonberg@adacore.com> + + * sem_util.adb (Enclosing_Subprogram): Protected entries and task + entries must be treated separately: task entries are within the + enclosing subprogram of the task type, while protected entries are + transformed into the corresponding Protected_Body_Subprogram, which is + the enclosing_subprogram of any subprogram declared within the entry + body. + 2018-07-17 Hristian Kirtchev <kirtchev@adacore.com> * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add missing diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index bc44cd35..31d5c17 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -6906,10 +6906,25 @@ package body Sem_Util is elsif Ekind (Dynamic_Scope) = E_Subprogram_Body then return Corresponding_Spec (Parent (Parent (Dynamic_Scope))); - elsif Ekind_In (Dynamic_Scope, E_Block, E_Return_Statement, E_Entry) - then + elsif Ekind_In (Dynamic_Scope, E_Block, E_Return_Statement) then return Enclosing_Subprogram (Dynamic_Scope); + elsif Ekind (Dynamic_Scope) = E_Entry then + + -- For a task entry, return the enclosing subprogram of the + -- task itself. + + if Ekind (Scope (Dynamic_Scope)) = E_Task_Type then + return Enclosing_Subprogram (Dynamic_Scope); + + -- A protected entry is rewritten as a protected procedure + -- which is the desired enclosing subprogram. This is relevant + -- when unnesting a procedure local to an entry body + + else + return Protected_Body_Subprogram (Dynamic_Scope); + end if; + elsif Ekind (Dynamic_Scope) = E_Task_Type then return Get_Task_Body_Procedure (Dynamic_Scope); |