From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id B6B45386545A; Wed, 27 Sep 2023 08:28:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6B45386545A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695803311; bh=PeGFiA3xw2zoB0jhEhc9jLhr/AGuaX9voMMZmK70Zcg=; h=From:To:Subject:Date:From; b=k/nVSwEnU7d1Voa8CLqN6Kf9LraZ/S4cYvzONmZ3ZE4DEwWymO209cULYd4mb/QCl Efvyfs5u+IB5eQcHWJLFJvO8ik/HkssK8Ov4MJ4Yc6nAvC3WO5OVomNwuCKnwwV7zP O2k1BhenMtkG4hfHrYTnwYYgClMqwRC3eQTTjK8w= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-7906] ada: Fix late finalization for function call in delta aggregate X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: dfbca296ef561124d9931d6ceeaca5b21ab1d17e X-Git-Newrev: 90f7f814920c48a7c90d98ad5b6bb1cb9851e9d2 Message-Id: <20230927082831.B6B45386545A@sourceware.org> Date: Wed, 27 Sep 2023 08:28:31 +0000 (GMT) List-Id: https://gcc.gnu.org/g:90f7f814920c48a7c90d98ad5b6bb1cb9851e9d2 commit r13-7906-g90f7f814920c48a7c90d98ad5b6bb1cb9851e9d2 Author: Eric Botcazou Date: Sun Aug 27 09:34:59 2023 +0200 ada: Fix late finalization for function call in delta aggregate The problem occurs at library level because the temporary created for the function call lives in the elaboration routine but is finalized only when the package itself is. It turns out that there is no need for this temporary, since the expansion of delta aggregates already creates a (properly finalized) temporary. gcc/ada/ * exp_ch6.adb (Expand_Ctrl_Function_Call): Also do nothing for the expression of a delta aggregate. Diff: --- gcc/ada/exp_ch6.adb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 81362ad571c..c6e9ae3cfb4 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -5143,9 +5143,13 @@ package body Exp_Ch6 is -- object, then no need to copy/readjust/finalize, we can initialize it -- in place. However, if the call returns on the secondary stack, then -- we need the expansion because we'll be renaming the temporary as the - -- (permanent) object. + -- (permanent) object. We also apply it in the case of the expression of + -- a delta aggregate, since it is used only to initialize a temporary. - if Nkind (Par) = N_Object_Declaration and then not Use_Sec_Stack then + if Nkind (Par) in N_Object_Declaration | N_Delta_Aggregate + and then Expression (Par) = N + and then not Use_Sec_Stack + then return; end if;