]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Allow use of writable parameters inside function with side-effects
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 4 Jan 2024 16:37:06 +0000 (17:37 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 6 May 2024 09:11:32 +0000 (11:11 +0200)
Writable parameters can be used as global outputs inside functions with
side-effects.

gcc/ada/

* sem_prag.adb (Collect_Global_Item): Handle functions with
side-effects.

gcc/ada/sem_prag.adb

index 25a98cb414e7914fbf9a7474d2c03a38816f0f7b..5764992237b4901fa9090518a7ea6eb36a8db326 100644 (file)
@@ -31656,8 +31656,9 @@ package body Sem_Prag is
                --  outputs when the related type is access-to-variable.
 
                if Ekind (Formal) = E_In_Parameter
-                 and then Ekind (Spec_Id) not in E_Function
-                                               | E_Generic_Function
+                 and then (Ekind (Spec_Id) not in E_Function
+                                                | E_Generic_Function
+                             or else Is_Function_With_Side_Effects (Spec_Id))
                  and then Is_Access_Variable (Etype (Formal))
                then
                   Append_New_Elmt (Formal, Subp_Outputs);