From: Eric Botcazou Date: Tue, 31 Jan 2023 15:04:01 +0000 (+0100) Subject: ada: Fix double finalization in conditional exit statement X-Git-Tag: basepoints/gcc-15~9101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60498ae3a06ba9a08cd2bf4a851e01e7e6fb1557;p=thirdparty%2Fgcc.git ada: Fix double finalization in conditional exit statement 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. --- diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 95b81fb8e535..b63e47335be1 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -5653,14 +5653,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;