]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Missing finalization on nested expression with action
authorArnaud Charlet <charlet@adacore.com>
Thu, 11 Mar 2021 16:00:04 +0000 (11:00 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 17 Jun 2021 14:32:15 +0000 (10:32 -0400)
gcc/ada/

* exp_ch4.adb (Expand_N_Expression_With_Actions.Process_Action):
Do not abandon processing on a nested N_Expression_With_Actions
or N_Loop_Statement, otherwise we may miss some transient
declarations.

gcc/ada/exp_ch4.adb

index 5b3a11677db684fd8d25f51d3057baede7a785dd..4436557b354c78fdeda03b9d78164884ef966fc1 100644 (file)
@@ -5780,15 +5780,14 @@ package body Exp_Ch4 is
 
          --  Avoid processing temporary function results multiple times when
          --  dealing with nested expression_with_actions.
+         --  Similarly, do not process temporary function results in loops.
+         --  This is done by Expand_N_Loop_Statement and Build_Finalizer.
+         --  Note that we used to wrongly return Abandon instead of Skip here:
+         --  this is wrong since it means that we were ignoring lots of
+         --  relevant subsequent statements.
 
-         elsif Nkind (Act) = N_Expression_With_Actions then
-            return Abandon;
-
-         --  Do not process temporary function results in loops. This is done
-         --  by Expand_N_Loop_Statement and Build_Finalizer.
-
-         elsif Nkind (Act) = N_Loop_Statement then
-            return Abandon;
+         elsif Nkind (Act) in N_Expression_With_Actions | N_Loop_Statement then
+            return Skip;
          end if;
 
          return OK;