]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix double finalization in conditional exit statement
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 31 Jan 2023 15:04:01 +0000 (16:04 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 27 Sep 2023 08:16:24 +0000 (10:16 +0200)
The temporary is first finalized through its enclosing block.

gcc/ada/

* exp_ch4.adb (Expand_N_Expression_With_Actions.Process_Action): Do
not look into nested blocks.

gcc/ada/exp_ch4.adb

index 31823eaeca7e0b8d394abd8a6b4baecc61a8d6e0..924452c4fb51ef9cacd9e1e3541c5e9c97c21652 100644 (file)
@@ -5651,14 +5651,17 @@ package body Exp_Ch4 is
             return Skip;
 
          --  Avoid processing temporary function results multiple times when
-         --  dealing with nested expression_with_actions.
+         --  dealing with nested expression_with_actions or nested blocks.
          --  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) in N_Expression_With_Actions | N_Loop_Statement then
+         elsif Nkind (Act) in N_Expression_With_Actions
+                            | N_Block_Statement
+                            | N_Loop_Statement
+         then
             return Skip;
          end if;