From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 2D6463858421; Tue, 8 Nov 2022 08:40:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D6463858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667896828; bh=vJ+nNeoHzNkEdkoyYHzPAFftgrUs43y1HCSHVHw2NTY=; h=From:To:Subject:Date:From; b=Y3JtqUS0md/yo7IavKDEb0Rtc3HiC5Ag1qDrAyDlqPibiYqYSs5s6bIMjY1aJ0zwz xYL+PApJOinhSL1oHrQCwyLrJJF6CpluoLD6s7feuNAoSV5PJ3yA2M2XmYZzsFSC1O FBHevr2qm6JLVIa4u6+3Yt7ynRsX6y5k7wdF+apE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3777] ada: Missing master of task causing assertion failure X-Act-Checkin: gcc X-Git-Author: Javier Miranda X-Git-Refname: refs/heads/master X-Git-Oldrev: 59dd07ef2534c00f0144431bf54d8219ebb91218 X-Git-Newrev: b9d8ad7175359f7a6dfd803fcc3b3f619301e734 Message-Id: <20221108084028.2D6463858421@sourceware.org> Date: Tue, 8 Nov 2022 08:40:28 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b9d8ad7175359f7a6dfd803fcc3b3f619301e734 commit r13-3777-gb9d8ad7175359f7a6dfd803fcc3b3f619301e734 Author: Javier Miranda Date: Sat Oct 15 16:29:38 2022 +0000 ada: Missing master of task causing assertion failure gcc/ada/ * exp_ch9.adb (Build_Master_Entity): Handle missing case: when the context of the master is a BIP function whose result type has tasks. Diff: --- gcc/ada/exp_ch9.adb | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index decf61782af..70ede15901e 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;