aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch6.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-08-27 09:34:59 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-09-14 14:42:38 +0200
commitf8f05af400c99cdbdccfc57d536ccf5e1f0bdc47 (patch)
tree37ef4130007ead418c244d391258936857e084ce /gcc/ada/exp_ch6.adb
parentc3e95117406ad0f1dbe038c883122a8824a8105c (diff)
downloadgcc-f8f05af400c99cdbdccfc57d536ccf5e1f0bdc47.zip
gcc-f8f05af400c99cdbdccfc57d536ccf5e1f0bdc47.tar.gz
gcc-f8f05af400c99cdbdccfc57d536ccf5e1f0bdc47.tar.bz2
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.
Diffstat (limited to 'gcc/ada/exp_ch6.adb')
-rw-r--r--gcc/ada/exp_ch6.adb8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 0d1f1fb..da1c9e6 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -5424,9 +5424,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;