]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix late finalization for function call in delta aggregate
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 27 Aug 2023 07:34:59 +0000 (09:34 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 27 Sep 2023 08:16:29 +0000 (10:16 +0200)
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.

gcc/ada/exp_ch6.adb

index 81362ad571c1a48f563c947b332e56c01e49c583..c6e9ae3cfb4626bc8a5b2608cfcdeb0defa346ee 100644 (file)
@@ -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;