(Is_Itype (Btyp)
and then Nkind (Associated_Node_For_Itype (Btyp)) =
N_Object_Declaration
- and then Is_Return_Object
- (Defining_Identifier
- (Associated_Node_For_Itype (Btyp))))
+ and then
+ Is_Return_Object
+ (Defining_Identifier (Associated_Node_For_Itype (Btyp))))
then
- declare
- Scop : Entity_Id;
-
- begin
- Scop := Scope (Scope (Btyp));
- while Present (Scop) loop
- exit when Ekind (Scop) = E_Function;
- Scop := Scope (Scop);
- end loop;
-
- -- Treat the return object's type as having the level of the
- -- function's result subtype (as per RM05-6.5(5.3/2)).
-
- return Type_Access_Level (Etype (Scop), Allow_Alt_Model);
- end;
+ return
+ Type_Access_Level
+ (Etype (Enclosing_Subprogram (Btyp)), Allow_Alt_Model);
end if;
end if;
-- Is_Local_Anonymous_Access
-- Defined in access types. Set for an anonymous access type to indicate
-- that the type is created for an array or record component with access
--- definition, an access result, or (pre-Ada 2012) a standalone object.
--- Such anonymous types have an accessibility level equal to that of the
--- declaration in which they appear, unlike the anonymous access types
--- that are created for access parameters, access discriminants, and
--- (as of Ada 2012) stand-alone objects.
+-- definition, an access result, a return object, or (before Ada 2012) a
+-- stand-alone object. Such anonymous types have an accessibility level
+-- equal to that of the declaration in which they appear (or something
+-- equivalent), unlike the anonymous access types that are created for
+-- access parameters, access discriminants, and (in Ada 2012 and later
+-- versions of the language) stand-alone objects.
-- Is_Loop_Parameter
-- Applies to all entities. Certain loops, in particular "for ... of"
Set_Is_Local_Anonymous_Access
(T, Ada_Version < Ada_2012
- or else Nkind (P) /= N_Object_Declaration
- or else Is_Library_Level_Entity (Defining_Identifier (P)));
+ or else Nkind (P) /= N_Object_Declaration
+ or else Is_Return_Object (Defining_Identifier (P))
+ or else Is_Library_Level_Entity (Defining_Identifier (P)));
-- Otherwise, either the object definition is just a subtype_mark or we
-- are analyzing a component declaration.