@@ -3835,13 +3835,7 @@ package body Exp_Ch9 is
Expression => New_Occurrence_Of (R, Loc));
end if;
- if Has_Aspect (Pid, Aspect_Exclusive_Functions)
- and then
- (No (Find_Value_Of_Aspect (Pid, Aspect_Exclusive_Functions))
- or else
- Is_True (Static_Boolean (Find_Value_Of_Aspect
- (Pid, Aspect_Exclusive_Functions))))
- then
+ if Has_Enabled_Aspect (Pid, Aspect_Exclusive_Functions) then
Lock_Kind := RE_Lock;
else
Lock_Kind := RE_Lock_Read_Only;
@@ -4041,16 +4035,9 @@ package body Exp_Ch9 is
if (Nkind (Op_Spec) = N_Procedure_Specification
or else
(Nkind (Op_Spec) = N_Function_Specification
- and then Has_Aspect (Conc_Typ, Aspect_Exclusive_Functions)
and then
- (No
- (Find_Value_Of_Aspect (Conc_Typ,
- Aspect_Exclusive_Functions))
- or else
- Is_True
- (Static_Boolean
- (Find_Value_Of_Aspect
- (Conc_Typ, Aspect_Exclusive_Functions))))))
+ Has_Enabled_Aspect
+ (Conc_Typ, Aspect_Exclusive_Functions)))
and then Has_Entries (Conc_Typ)
then
case Corresponding_Runtime_Package (Conc_Typ) is
@@ -13484,6 +13484,28 @@ package body Sem_Util is
return False;
end Has_Effectively_Volatile_Component;
+ ------------------------
+ -- Has_Enabled_Aspect --
+ ------------------------
+
+ function Has_Enabled_Aspect
+ (Id : Entity_Id;
+ A : Aspect_Id)
+ return Boolean
+ is
+ Asp : constant Node_Id := Find_Aspect (Id, A);
+ begin
+ if Present (Asp) then
+ if Present (Expression (Asp)) then
+ return Is_True (Static_Boolean (Expression (Asp)));
+ else
+ return True;
+ end if;
+ else
+ return False;
+ end if;
+ end Has_Enabled_Aspect;
+
----------------------------
-- Has_Volatile_Component --
----------------------------
@@ -20356,11 +20378,7 @@ package body Sem_Util is
-- for efficiency.
return Ada_Version >= Ada_2022
- and then Has_Aspect (Subp, Aspect_Static)
- and then
- (No (Find_Value_Of_Aspect (Subp, Aspect_Static))
- or else Is_True (Static_Boolean
- (Find_Value_Of_Aspect (Subp, Aspect_Static))));
+ and then Has_Enabled_Aspect (Subp, Aspect_Static);
end Is_Static_Function;
-----------------------------
@@ -1559,6 +1559,12 @@ package Sem_Util is
-- Given arbitrary type Typ, determine whether it contains at least one
-- effectively volatile component.
+ function Has_Enabled_Aspect (Id : Entity_Id; A : Aspect_Id) return Boolean
+ with Pre => A in Boolean_Aspects;
+ -- Returns True if a Boolean-valued aspect is enabled on entity Id; i.e. it
+ -- is present and either has no aspect definition or its aspect definition
+ -- statically evaluates to True.
+
function Has_Volatile_Component (Typ : Entity_Id) return Boolean;
-- Given arbitrary type Typ, determine whether it contains at least one
-- volatile component.
From: Piotr Trojanek <trojanek@adacore.com> Code cleanup following a fix for aspect Exclusive_Functions; semantics is unaffected. gcc/ada/ * exp_ch9.adb (Build_Protected_Subprogram_Body, Build_Protected_Subprogram_Call_Cleanup): Reuse refactored routine. * sem_util.adb (Has_Enabled_Aspect): Refactored repeated code. (Is_Static_Function): Reuse refactored routine. * sem_util.ads (Has_Enabled_Aspect): New query routine refactored from repeated code. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch9.adb | 19 +++---------------- gcc/ada/sem_util.adb | 28 +++++++++++++++++++++++----- gcc/ada/sem_util.ads | 6 ++++++ 3 files changed, 32 insertions(+), 21 deletions(-)