From ec1cdad89afed4d5fc8617c3de3c1950ca55ba7e Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Thu, 4 Jan 2024 17:37:06 +0100 Subject: [PATCH] ada: Allow use of writable parameters inside function with side-effects 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 25a98cb414e..5764992237b 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -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);