From: Ronan Desplanques <desplanq...@adacore.com> 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch5.adb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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; -- 2.45.2