From patchwork Thu Aug 29 13:07:44 2024 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: 1978431 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=CJS2d2O3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WvhWF5QcMz1yfn for ; Thu, 29 Aug 2024 23:11:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 910043861016 for ; Thu, 29 Aug 2024 13:11:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id B6DF43861032 for ; Thu, 29 Aug 2024 13:08:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B6DF43861032 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B6DF43861032 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::331 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724936900; cv=none; b=kj2OtM2Vi4jq7+rlPG3kvwNaj8fLZNu3PKXF6tA01NFU8HWT4iYxx7yK70R4s4999LJL/81hJffdEeDm1mg3yjgOLgsyWKDAilnY7E0QMb9EjoL9DaoX05FVJ01g11sJ7pnevBeCSaebYLhwNMS0mASfgZdkUn1Zn5hx1JlXOM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724936900; c=relaxed/simple; bh=rlxxa4JFhel+JHQdMfbkGGapWsMcZcwiKXAy4YLcxCw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=P7tTnSQemDVb118G/0BuD3LPrt/YwSvPGNwuHabb18pZv8Q9CiCPOAIxM0SPzNcNMRy+AE2+nXrCDadax9hoAjAb1q3ocEPskmaOwWqLdT8Y3xJqeOoeaWSnTfDYnSNXAuTimZdW6SEWOiW38qj9sYOTWS7H+7gPmi98aLVdA9g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42bb8cf8abeso2405135e9.2 for ; Thu, 29 Aug 2024 06:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1724936897; x=1725541697; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MtlrOdNuxMGmUPBp+E0jwxW1qKlfZ8NpmySR2yQp6gE=; b=CJS2d2O3CLd1EqqTbZBBsyEOuqU81TS9NXRqbEpiisUQ40fnB0ebAcbuqW2FEyMWFT AgYdXt5peuBkRjhk7GDRmhMseBf9RlWayfqnvpOunzi/J6KRaSY5r6CtzhYO0dtTcKiY ip2UVO4vRM+sMun5/TfnHsfz9tU3kJKg81pZacvMrdd9ZrHAvJi1Hf6zhAeP1OoWHhJt WaTomc5+x/Sab5rydo8X2tvqQlth+wsgAHDWr4+M8bebc4RytXH0N2W47d06Dcfav0NG leUdOefgq35ogDvtL16df7OSgjc5q13/wxKHAaQyMo2PfR3xhSwc2zq9Ng2wqBX638ki 3TdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724936897; x=1725541697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MtlrOdNuxMGmUPBp+E0jwxW1qKlfZ8NpmySR2yQp6gE=; b=bQ8XlM6MSkraWqFc0FgQtxxMtT/2BuinqhYZQE/gIg3iJ6eFmLcFn7394m2fD8w/7C /YQy7wNDKmFgJVaUUGJhsX/LZF4pnk0lY7BpGIelb4HwZam5h2W1rfwpBUiEwxZDgs4P 1tvmZBzldag6T/byuUauD9ZLX9Wdwl5Z2KLlkG2NGDhx6jOdXwUdCj60uO565RvJ+Y/K SZyAIQQgjloYcWIOV8SX6syN/nJXnOYrsyRjyVAAc4LfkIUV37Qn2ogoNGWkScxHWvlV 8kH6SwLkc4s1nfMhD/FL3iJHgq1RDOGN0hqE3xdylNU05UK2JvD4dVthgCY+AGOPR/BT UqrA== X-Gm-Message-State: AOJu0YyDgYQpewu6RBeh9Hm2cgmnZHiW9n4nLSZsazpkhMByI0iyGdLy OccFhEBwu9Obn10LBJLd2OpQnARx66M/mhjiRyfplQnbjuMJzOUAb8choSOtklouCywAsVDGZSM = X-Google-Smtp-Source: AGHT+IFGXxWTOjM9dboaIZTNDfC7bXRa9qRTrgwddd0ndQsqMqOGRXLAjMgUQUJtni50NBWWoBmP3A== X-Received: by 2002:a05:600c:4586:b0:427:9922:4526 with SMTP id 5b1f17b1804b1-42bb01ae423mr20431225e9.7.1724936896583; Thu, 29 Aug 2024 06:08:16 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:5e2c:51b0:ac4a:92ca]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6deb2f5sm17074605e9.2.2024.08.29.06.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 06:08:16 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 14/17] ada: Fix missing finalization for call to function returning limited view Date: Thu, 29 Aug 2024 15:07:44 +0200 Message-ID: <20240829130750.1651060-14-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240829130750.1651060-1-poulhies@adacore.com> References: <20240829130750.1651060-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Eric Botcazou The call is legal because it is made from the body, which has visibility on the nonlimited view, so this changes the code in Expand_Call_Helper to look at the Etype of the call node instead of the Etype of the function. gcc/ada/ * exp_ch6.adb (Expand_Call_Helper): In the case of a function call, look at the Etype of the call node to determine whether finalization actions need to be performed. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch6.adb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 420d5f44a69..3c87c0e8220 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -5262,7 +5262,9 @@ package body Exp_Ch6 is -- function call is transformed into a reference to the result that has -- been built either on the primary or the secondary stack. - if Needs_Finalization (Etype (Subp)) then + if Nkind (Call_Node) = N_Function_Call + and then Needs_Finalization (Etype (Call_Node)) + then if not Is_Build_In_Place_Function_Call (Call_Node) and then (No (First_Formal (Subp)) @@ -5270,7 +5272,7 @@ package body Exp_Ch6 is not Is_Concurrent_Record_Type (Etype (First_Formal (Subp)))) then Expand_Ctrl_Function_Call - (Call_Node, Needs_Secondary_Stack (Etype (Subp))); + (Call_Node, Needs_Secondary_Stack (Etype (Call_Node))); -- Build-in-place function calls which appear in anonymous contexts -- need a transient scope to ensure the proper finalization of the @@ -5292,7 +5294,7 @@ package body Exp_Ch6 is Is_Build_In_Place_Function_Call (Parent (Call_Node))) then Establish_Transient_Scope - (Call_Node, Needs_Secondary_Stack (Etype (Subp))); + (Call_Node, Needs_Secondary_Stack (Etype (Call_Node))); end if; end if; end Expand_Call_Helper;