diff mbox series

[COMMITTED,4/6] ada: Run-time error with GNAT-LLVM on container aggregate with finalization

Message ID 20240808142948.807190-4-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,1/6] ada: Finalization_Size raises Constraint_Error | expand

Commit Message

Marc Poulhiès Aug. 8, 2024, 2:29 p.m. UTC
From: Gary Dismukes <dismukes@adacore.com>

When unnesting is enabled, the compiler was failing to copy the At_End_Proc
field from a block statement to the procedure created to replace it when
unnesting of top-level blocks is done.  At run time this could lead to
exceptions due to missing finalization calls.

gcc/ada/

	* exp_ch7.adb (Unnest_Block): Copy the At_End_Proc from the block
	statement to the newly created subprogram body.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_ch7.adb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 72f0b539c2e..640ad5c60b8 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -8932,7 +8932,8 @@  package body Exp_Ch7 is
               Defining_Unit_Name => Local_Proc),
               Declarations       => Declarations (Decl),
           Handled_Statement_Sequence =>
-            Handled_Statement_Sequence (Decl));
+            Handled_Statement_Sequence (Decl),
+          At_End_Proc                => New_Copy_Tree (At_End_Proc (Decl)));
 
       --  Handlers in the block may contain nested subprograms that require
       --  unnesting.