From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 0CC423858C39 for ; Tue, 8 Nov 2022 08:41:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0CC423858C39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42e.google.com with SMTP id l14so19818364wrw.2 for ; Tue, 08 Nov 2022 00:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=l8AIHiYXjag3o6oAE56yDNQvnwjgeZlgrCwISHYDEqw=; b=K0Upvhe3KyKABw5jwYZG/R+eHESwas0O3zLVNRX2B1RZJfU9gAB8HYE+4t2M3cpq+8 jELyHSb9YsDSmNyZZ9NxpAe6xcmdXU5jgH91muunPgBPuqeSqkkhqThr7axsN3Vf6TUf FeYmpnAkXy5BUv+hATBu5rry5sg5vE0H7HhINfX8w8bQHv6a2k1kQNXd9n4UjzFXOzeO Fz4mfZTQtfiexij8/agxr5ta+l6+cMe0YzYooumMU18+KkUGCW4gZLRzGaeoNFfRc0Bl GoI0iaesQlaMnvgkGoLOM9MbTIJ0aZUgIXjlL5FNspDBs9fv0F1MTCX1i1iny9LrEWvU ekHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=l8AIHiYXjag3o6oAE56yDNQvnwjgeZlgrCwISHYDEqw=; b=3FnKVOPdhOawsNYKeaTw+vliU70WdQ2/cHItDrgoNq0MhXynA8itYgauJ/sWuaDdUM EpCfmZwRnXBwGDKTudZ1B3kvOMFdb8kQVu4iPcCUJvMEhnkbstcSeIWPnGnpGxAwFb4o 5V6D34BbcsVGItL4/o8syrCGh6Q2pkVGsUwm3K8SZI7B4HQKr98xIQ1malA6B5t4gIqo ZkP+ZxtNqDcrV4lj7Ipg2zxezIlRo5770S2ekoSOSKhFCLjoSzMCi2+/p+vtuTAvnivN O13H58I32wDXf6EpV3alpBeUFK/heoxg2H+rM/NQaj1uf5I+IPZU32IMcPSXHl1N2UVV czoA== X-Gm-Message-State: ACrzQf0LKZ/Pf1fTU8s1fmQYgwIz8Tk9VAIPdPQqcON71GFIiTNmjN64 MEkhZYStYZINwTRCnbtYvDFqhlbxRa/bow== X-Google-Smtp-Source: AMsMyM647zZc8sByGWmS6DODMhFoZQ7g1wX18vPQgM+JLswcTnT6y/YlbiSh85fs+SNvvLylApX2Gw== X-Received: by 2002:a05:6000:43:b0:236:d95e:2be with SMTP id k3-20020a056000004300b00236d95e02bemr27828539wrx.478.1667896903805; Tue, 08 Nov 2022 00:41:43 -0800 (PST) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id bo17-20020a056000069100b002366eb01e07sm9650277wrb.114.2022.11.08.00.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 00:41:43 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED] ada: Missing master of task causing assertion failure Date: Tue, 8 Nov 2022 09:41:39 +0100 Message-Id: <20221108084139.300802-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Javier Miranda 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. Tested on x86_64-pc-linux-gnu, committed on master. --- 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; -- 2.34.1