aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_util.ads
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-05-15 23:56:44 +0200
committerMarc Poulhiès <poulhies@adacore.com>2024-06-20 10:50:53 +0200
commit4f6ee98c27cf0219779a2ccd6ef5d0e67b75580f (patch)
tree3f9c0e28de77fa11b25b83d05b109b8ae1c65fb4 /gcc/ada/sem_util.ads
parent09ed91df30102e17ac5c59bab314b8b37606c710 (diff)
ada: Streamline propagation of controlled flags on types
The front-end maintains a set of 4 flags on (base) types that are used to parameterize the implementation of controlled operations, and these flags need to be propagated through composition and derivation. This is done on a per-flag basis in the current implementation with a few loopholes. This introduces a Propagate_Controlled_Flags routine to that effect, which is modeled on the existing Propagate_Concurrent_Flags routine, and is used in most cases to do the propagation. This also removes the handling of the Finalize_Storage_Only flag from Inherit_Aspects_At_Freeze_Point, since the associated aspect does not exist (only the pragma does). gcc/ada/ * freeze.adb (Freeze_Array_Type): Call Propagate_Controlled_Flags to propagate the controlled flags from the component to the array. (Freeze_Record_Type): Propagate the Finalize_Storage_Only flag from the components to the record. * sem_ch3.adb (Analyze_Private_Extension_Declaration): Do not call Propagate_Concurrent_Flags here but... (Array_Type_Declaration): Tidy and call Propagate_Controlled_Flags to propagate the controlled flags from the component to the array. (Build_Derived_Private_Type): Do not propagate the controlled flags manually here but... (Build_Derived_Record_Type): ...call Propagate_Controlled_Flags to propagate the controlled flags from parent to derived type. (Build_Derived_Type): Likewise. (Copy_Array_Base_Type_Attributes): Call Propagate_Controlled_Flags to copy the controlled flags. (Record_Type_Definition): Streamline the propagation of the Finalize_Storage_Only flag from the components to the record. * sem_ch7.adb (Preserve_Full_Attributes): Use Full_Base and call Propagate_Controlled_Flags to copy the controlled flags. * sem_ch9.adb (Analyze_Protected_Definition): Use canonical idiom to compute Has_Controlled_Component. (Analyze_Protected_Type_Declaration): Minor tweak. * sem_ch13.adb (Inherit_Aspects_At_Freeze_Point): Do not deal with Finalize_Storage_Only here. * sem_util.ads (Propagate_Controlled_Flags): New declaration. * sem_util.adb (Propagate_Controlled_Flags): New procedure.
Diffstat (limited to 'gcc/ada/sem_util.ads')
-rw-r--r--gcc/ada/sem_util.ads11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index bda295f0a7f..7363ad96bd8 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -2914,6 +2914,17 @@ package Sem_Util is
-- by one of these flags. This procedure can only set flags for Typ, and
-- never clear them. Comp_Typ is the type of a component or a parent.
+ procedure Propagate_Controlled_Flags
+ (Typ : Entity_Id;
+ From_Typ : Entity_Id;
+ Comp : Boolean := False;
+ Deriv : Boolean := False);
+ -- Set Disable_Controlled, Finalize_Storage_Only, Has_Controlled_Component,
+ -- and Is_Controlled_Active on Typ when the flags are set on From_Typ. If
+ -- Comp is True, From_Typ is the type of a component of Typ while, if Deriv
+ -- is True, From_Typ is the parent type of Typ. This procedure can only set
+ -- flags for Typ, and never clear them.
+
procedure Propagate_DIC_Attributes
(Typ : Entity_Id;
From_Typ : Entity_Id);