]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Plug small loophole in finalization machinery
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 22 Nov 2023 22:04:33 +0000 (23:04 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 19 Dec 2023 14:27:48 +0000 (15:27 +0100)
The path in Expand_N_If_Expression implementing the special optimization for
an unidimensional array type and dependent expressions with static bounds
fails to call Process_Transients_In_Expression on their list of actions.

gcc/ada/

* exp_ch4.adb (Expand_N_If_Expression): Also add missing calls to
Process_Transients_In_Expression on the code path implementing the
special optimization for an unidimensional array type and
dependent expressions with static bounds.

gcc/ada/exp_ch4.adb

index 8f4cf0808dcf9b82c097f5ab48643fc8c73594dd..527ca16aac4bef97e3c325cc12e339654731ead2 100644 (file)
@@ -5912,6 +5912,14 @@ package body Exp_Ch4 is
         and then not Generate_C_Code
         and then not Unnest_Subprogram_Mode
       then
+         --  When the "then" or "else" expressions involve controlled function
+         --  calls, generated temporaries are chained on the corresponding list
+         --  of actions. These temporaries need to be finalized after the if
+         --  expression is evaluated.
+
+         Process_Transients_In_Expression (N, Then_Actions (N));
+         Process_Transients_In_Expression (N, Else_Actions (N));
+
          declare
             Ityp : constant Entity_Id := Base_Type (Etype (First_Index (Typ)));