aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch9.adb
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-11-08 12:36:43 +0100
committerMartin Liska <mliska@suse.cz>2022-11-08 12:36:43 +0100
commit4b13c73bba935443be3207abf26f7ba05f79badc (patch)
treea6bb1525d07859fa8fc6f61dd13df7ddfd1ac254 /gcc/ada/exp_ch9.adb
parent33f5dde0cd15df9cf89b29280d4ff5fcf7b30e66 (diff)
parentfa271afb58423014e2feef9f15c1a87428e64ddc (diff)
downloadgcc-devel/sphinx.zip
gcc-devel/sphinx.tar.gz
gcc-devel/sphinx.tar.bz2
Merge branch 'master' into devel/sphinxdevel/sphinx
Diffstat (limited to 'gcc/ada/exp_ch9.adb')
-rw-r--r--gcc/ada/exp_ch9.adb37
1 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index decf617..70ede15 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -3207,10 +3207,45 @@ package body Exp_Ch9 is
Find_Enclosing_Context (Par, Context, Context_Id, Decls);
end if;
+ -- When the enclosing context is a BIP function whose result type has
+ -- tasks, the function has an extra formal that is the master of the
+ -- tasks to be created by its returned object (that is, when its
+ -- enclosing context is a return statement). However, if the body of
+ -- the function creates tasks before its return statements, such tasks
+ -- need their own master.
+
+ if Has_Master_Entity (Context_Id)
+ and then Ekind (Context_Id) = E_Function
+ and then Is_Build_In_Place_Function (Context_Id)
+ and then Needs_BIP_Task_Actuals (Context_Id)
+ then
+ -- No need to add it again if previously added
+
+ declare
+ Master_Present : Boolean;
+
+ begin
+ -- Handle transient scopes
+
+ if Context_Id /= Current_Scope then
+ Push_Scope (Context_Id);
+ Master_Present :=
+ Present (Current_Entity_In_Scope (Name_uMaster));
+ Pop_Scope;
+ else
+ Master_Present :=
+ Present (Current_Entity_In_Scope (Name_uMaster));
+ end if;
+
+ if Master_Present then
+ return;
+ end if;
+ end;
+
-- Nothing to do if the context already has a master; internally built
-- finalizers don't need a master.
- if Has_Master_Entity (Context_Id)
+ elsif Has_Master_Entity (Context_Id)
or else Is_Finalizer (Context_Id)
then
return;