From patchwork Tue Nov 8 08:41:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 16934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2569689wru; Tue, 8 Nov 2022 00:44:42 -0800 (PST) X-Google-Smtp-Source: AMsMyM7EUl0tKZRswHQ2rvAgmREvpPP8pG/9gTlXA7TwMpMOSphnZ+g6Q7oyGT7d5MtbWA+h06TK X-Received: by 2002:a50:fe01:0:b0:463:10fd:943d with SMTP id f1-20020a50fe01000000b0046310fd943dmr50801085edt.314.1667897082490; Tue, 08 Nov 2022 00:44:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667897082; cv=none; d=google.com; s=arc-20160816; b=L62PCz3iuljqPPGSAZ6OSJVHJuUsKk4Q85vDq1Y/Z6zAwVvYqGy7++ReFdRvZn976O KXu5JItdKW437inbovyXZEJ6J23IJxIbgebKduH9uPQSXkvfDdZaGLh052Dd3MXs72rd nrxVIKVKYhxCdk3m0A5q4XzI8S0zhjY+V77by2EPgJRmtNvopg0M5Fzw7zv1fc3JxRmo WfapOJDLR5PhyJZkfUosBlmfWAX4B7YeJ+ygaFaLD6Mve1qCKipsePZq0W7IBnECXxd5 aQnz0VBPJP3OW7i03nqq0e20aFUBFVJFQpSU0RyK8Fhj0ugmhkruX8Qit6UjomZ0anJ3 Z/sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=l8AIHiYXjag3o6oAE56yDNQvnwjgeZlgrCwISHYDEqw=; b=lk2HKkmYmC/QN9je3p55RSh4OUhqDyWo6uG2dUecrrMIKbJZxFhBBTzndjC/YTw/dZ pqRhbShPYMHorSLu/x7esVYkbvz+YPxDRjI54CA2+GUXmU18EgPycNzUKYHR28vCDTTo LEaCAgwoTwBcqtOSSe1P9I16liAUdBE0s5XEApFDVsus0WCVoh1GgbvmJI0Zc3KaVQeP d8bSpsL7SC+hs4am/eJaKmwhg83xCPCKR5xa/owbURvIc/cE++ajlFu7llaxOAZM5ErE IpJ/3+pD9FYQvevHnbYHdu264aF07Eo9d8Y7VtSgK0x/bkKI5pcV32tOo5E24WRMR3wk b7Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Mb74hShj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e20-20020a170906c01400b007891fd9179bsi9803884ejz.150.2022.11.08.00.44.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 00:44:42 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Mb74hShj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 133973857341 for ; Tue, 8 Nov 2022 08:43:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 133973857341 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667897014; bh=l8AIHiYXjag3o6oAE56yDNQvnwjgeZlgrCwISHYDEqw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Mb74hShjk1ClO7O71Yhyu9sxo6mJDoPqQodLsJ8QCVQvaHPtBSs7e3J6ZZiqdO2Ix Dbec9UacexUjKzir3xIV/viBjGc6Lyzodybqsbnr2/GLMhHlgoB5pPLjKQ2U5Wle3J BGkCnQrLEC7HFUOu+hdQWZWiBTmPBnIb9Z9v9rSQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 Received: by mail-wr1-x42e.google.com with SMTP id l14so19818364wrw.2 for ; Tue, 08 Nov 2022 00:41:44 -0800 (PST) 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-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) 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748916851516495045?= X-GMAIL-MSGID: =?utf-8?q?1748916851516495045?= 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;