public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-7906] ada: Fix late finalization for function call in delta aggregate
@ 2023-09-27  8:28 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2023-09-27  8:28 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:90f7f814920c48a7c90d98ad5b6bb1cb9851e9d2

commit r13-7906-g90f7f814920c48a7c90d98ad5b6bb1cb9851e9d2
Author: Eric Botcazou <ebotcazou@adacore.com>
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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-27  8:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27  8:28 [gcc r13-7906] ada: Fix late finalization for function call in delta aggregate Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).