From: Arnaud Charlet Date: Thu, 11 Mar 2021 16:00:04 +0000 (-0500) Subject: [Ada] Missing finalization on nested expression with action X-Git-Tag: basepoints/gcc-13~6720 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f900b589c83b789329a0e99ddbe627507703e5e;p=thirdparty%2Fgcc.git [Ada] Missing finalization on nested expression with action 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. --- diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 5b3a11677db6..4436557b354c 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -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;