The following test illustrates the exemple of an aspect Atomic that applies to a component of a record type.
------------ -- Source -- ------------ procedure Cutdown is type Rec is record Comp : aliased Integer; Acomp : aliased Integer with Atomic => Atom; end record; Atomic_Int : aliased Integer with Atomic => True; Atom : constant Boolean := True; Rec_Var : Rec; type Ref is access all Integer; Comp_Ptr : Ref := Rec_Var.Comp'Access; -- legal Acomp_Ptr : Ref := Rec_Var.Acomp'Access; -- illegal Obj_Ptr : Ref := Atomic_Int'Access; -- illegal begin null; end Cutdown; ----------------- -- Compilation -- ----------------- gnatmake -q -gnat12 cutdown.adb ------------ -- Output -- ------------ cutdown.adb:14:23: access to atomic object cannot yield access-to-non-atomic type cutdown.adb:15:23: access to atomic object cannot yield access-to-non-atomic type gnatmake: "cutdown.adb" compilation error Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-09 Vincent Pucci <pu...@adacore.com> * freeze.adb (Freeze_Record_Type): Analyze the delayed aspects of the components in a record type.
Index: freeze.adb =================================================================== --- freeze.adb (revision 189367) +++ freeze.adb (working copy) @@ -1906,9 +1906,35 @@ Comp := First_Entity (Rec); Prev := Empty; while Present (Comp) loop + -- Deal with delayed aspect specifications for components. The + -- analysis of the aspect is required to be delayed to the freeze + -- point, thus we analyze the pragma or attribute definition + -- clause in the tree at this point. We also analyze the aspect + -- specification node at the freeze point when the aspect doesn't + -- correspond to pragma/attribute definition clause. - -- First handle the component case + if Ekind (Comp) = E_Component + and then Has_Delayed_Aspects (Comp) + then + Push_Scope (Rec); + -- The visibility to the discriminants must be restored in + -- order to properly analyze the aspects. + + if Has_Discriminants (Rec) then + Install_Discriminants (Rec); + Analyze_Aspects_At_Freeze_Point (Comp); + Uninstall_Discriminants (Rec); + + else + Analyze_Aspects_At_Freeze_Point (Comp); + end if; + + Pop_Scope; + end if; + + -- Handle the component and discriminant case + if Ekind (Comp) = E_Component or else Ekind (Comp) = E_Discriminant then