From: Ronan Desplanques Date: Mon, 17 Jun 2024 15:55:51 +0000 (+0200) Subject: ada: Fix test for wrapping loop parameter spec X-Git-Tag: basepoints/gcc-16~6942 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45174a8adf000406a42d877c132afcbaad83f3b4;p=thirdparty%2Fgcc.git ada: Fix test for wrapping loop parameter spec This patches fixes a problem where cleanup statements would be missing for some cases of loop parameter specifications that allocate on the secondary stack. gcc/ada/ * sem_ch5.adb (Prepare_Param_Spec_Loop): Fix criterion for wrapping loop statements into blocks. --- diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 5739fe06ea2..ac8cd0821ff 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -3806,20 +3806,16 @@ package body Sem_Ch5 is Rng_Typ := Etype (Rng_Copy); -- Wrap the loop statement within a block in order to manage - -- the secondary stack when the discrete range is + -- the secondary stack when the discrete range: -- - -- * Either a Forward_Iterator or a Reverse_Iterator + -- * is either a Forward_Iterator or a Reverse_Iterator + -- or -- - -- * Function call whose return type requires finalization - -- actions. - - -- ??? it is unclear why using Has_Sec_Stack_Call directly on - -- the discrete range causes the freeze node of an itype to be - -- in the wrong scope in complex assertion expressions. + -- * contains a function call that returns on the secondary + -- stack. if Is_Iterator (Rng_Typ) - or else (Nkind (Rng_Copy) = N_Function_Call - and then Needs_Finalization (Rng_Typ)) + or else Has_Sec_Stack_Call (Rng_Copy) then Wrap_Loop_Statement (Manage_Sec_Stack => True); Stop_Processing := True;