diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2024-01-04 15:01:55 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-06 11:11:32 +0200 |
commit | 0f3324fd8ba91b16905e4b03eaf1e35a728f1027 (patch) | |
tree | 5f2d8aa076833efe7000367211aabd371210138a | |
parent | 911d921759e4a32bac81016b2dda1e26147ba5d8 (diff) | |
download | gcc-0f3324fd8ba91b16905e4b03eaf1e35a728f1027.zip gcc-0f3324fd8ba91b16905e4b03eaf1e35a728f1027.tar.gz gcc-0f3324fd8ba91b16905e4b03eaf1e35a728f1027.tar.bz2 |
ada: Support writable parameters in Depends with side-effects
Functions with side-effects can modify writable parameters of mode IN,
so these parameters must be allowed to appear in their Depends aspects.
gcc/ada/
* sem_prag.adb (Find_Role): Handle functions with side-effects
like procedures.
-rw-r--r-- | gcc/ada/sem_prag.adb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 299e388..ab60a8a 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -1383,10 +1383,11 @@ package body Sem_Prag is (Item_Is_Input : out Boolean; Item_Is_Output : out Boolean) is - -- A constant or an IN parameter of a procedure or a protected - -- entry, if it is of an access-to-variable type, should be - -- handled like a variable, as the underlying memory pointed-to - -- can be modified. Use Adjusted_Kind to do this adjustment. + -- A constant or an IN parameter of a protected entry, procedure, + -- or function with side-effects, if it is of an + -- access-to-variable type, should be handled like a variable, as + -- the underlying memory pointed-to can be modified. Use + -- Adjusted_Kind to do this adjustment. Adjusted_Kind : Entity_Kind := Ekind (Item_Id); @@ -1394,11 +1395,15 @@ package body Sem_Prag is if (Ekind (Item_Id) in E_Constant | E_Generic_In_Parameter or else (Ekind (Item_Id) = E_In_Parameter - and then Ekind (Scope (Item_Id)) - not in E_Function | E_Generic_Function)) + and then + (Ekind (Scope (Item_Id)) not in E_Function + | E_Generic_Function + or else + Is_Function_With_Side_Effects (Scope (Item_Id))))) and then Is_Access_Variable (Etype (Item_Id)) - 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)) then Adjusted_Kind := E_Variable; end if; |