diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2023-04-04 09:49:26 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-29 10:23:19 +0200 |
commit | f8bf6ae4cf087a9947c431a06f77104fa20ae36f (patch) | |
tree | 770726f11adb03d1991d35df54ee1bd9d2678ce5 /gcc/ada/sem_res.adb | |
parent | 1f0d389488382d51a2e0ef38c2761a074e9bd2d3 (diff) | |
download | gcc-f8bf6ae4cf087a9947c431a06f77104fa20ae36f.zip gcc-f8bf6ae4cf087a9947c431a06f77104fa20ae36f.tar.gz gcc-f8bf6ae4cf087a9947c431a06f77104fa20ae36f.tar.bz2 |
ada: Allow attributes like First and Last to be read in Exceptional_Cases
Attributes that do not read data from the object can be safely used in
consequences of Exceptional_Cases regardless of the parameter passing
mode.
gcc/ada/
* sem_res.adb (Resolve_Entity_Name): Relax rules for Exceptional_Cases.
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r-- | gcc/ada/sem_res.adb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index a31077a..6d4bef8 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -8117,11 +8117,19 @@ package body Sem_Res is -- Parameters of modes OUT or IN OUT of the subprogram shall not -- occur in the consequences of an exceptional contract unless -- they are either passed by reference or occur in the prefix - -- of a reference to the 'Old attribute. + -- of a reference to the 'Old attribute. For convenience, we also + -- allow them as prefixes of attributes that do not actually read + -- data from the object. if Ekind (E) in E_Out_Parameter | E_In_Out_Parameter and then Within_Exceptional_Cases_Consequence (N) and then not In_Attribute_Old (N) + and then not (Nkind (Parent (N)) = N_Attribute_Reference + and then + Attribute_Name (Parent (N)) in Name_Constrained + | Name_First + | Name_Last + | Name_Length) and then not Is_By_Reference_Type (Etype (E)) and then not Is_Aliased (E) then |