]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix test for wrapping loop parameter spec
authorRonan Desplanques <desplanques@adacore.com>
Mon, 17 Jun 2024 15:55:51 +0000 (17:55 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 1 Aug 2024 15:14:34 +0000 (17:14 +0200)
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.

gcc/ada/sem_ch5.adb

index 5739fe06ea21c4371ce8127eae7e0f097057d8f7..ac8cd0821ffb8ef4f08991f14abefe789017bef4 100644 (file)
@@ -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;