return Ekind (Id) in Modular_Integer_Kind;
end Is_Modular_Integer_Type;
+ function Is_Named_Access_Type (Id : E) return B is
+ begin
+ return Ekind (Id) in E_Access_Type ..
+ E_Access_Protected_Subprogram_Type;
+ end Is_Named_Access_Type;
+
function Is_Named_Number (Id : E) return B is
begin
return Ekind (Id) in Named_Kind;
function Is_Integer_Type (Id : E) return B;
function Is_Limited_Record (Id : E) return B;
function Is_Modular_Integer_Type (Id : E) return B;
+ function Is_Named_Access_Type (Id : E) return B;
function Is_Named_Number (Id : E) return B;
function Is_Numeric_Type (Id : E) return B;
function Is_Object (Id : E) return B;
-- named access types and renamed objects within the
-- expression.
+ -- Note, this loop duplicates some of the logic in
+ -- Object_Access_Level since we have to check special rules
+ -- based on the context we are in (a return aggregate)
+ -- relating to formals of the current function.
+
Obj := Original_Node (Prefix (Expr));
loop
while Nkind_In (Obj, N_Explicit_Dereference,
end if;
end loop;
- -- Do not check aliased formals or function calls. A
- -- run-time check may still be needed ???
+ -- Do not check aliased formals statically
if Is_Formal (Entity (Obj))
- and then Is_Aliased (Entity (Obj))
+ and then (Is_Aliased (Entity (Obj))
+ or else Ekind (Etype (Entity (Obj))) =
+ E_Anonymous_Access_Type)
then
null;
- elsif Object_Access_Level (Obj) >
+ -- Otherwise, handle the expression normally, avoiding the
+ -- special logic above, and call Object_Access_Level with
+ -- the original expression.
+
+ elsif Object_Access_Level (Expr) >
Scope_Depth (Scope (Scope_Id))
then
Error_Msg_N
-- than the level of any visible named access type (see 3.10.2(21)).
if Is_Type (E) then
- return Type_Access_Level (E) + 1;
+ return Type_Access_Level (E) + 1;
elsif Present (Renamed_Object (E)) then
return Object_Access_Level (Renamed_Object (E));
then
return Type_Access_Level (Scope (E)) + 1;
+ -- An object of a named access type gets its level from its
+ -- associated type.
+
+ elsif Is_Named_Access_Type (Etype (E)) then
+ return Type_Access_Level (Etype (E));
+
else
return Scope_Depth (Enclosing_Dynamic_Scope (E));
end if;
then
return Object_Access_Level (Current_Scope);
+ -- Move up the attribute reference when we encounter a 'Access variation
+
+ elsif Nkind (Orig_Obj) = N_Attribute_Reference
+ and then Nam_In (Attribute_Name (Orig_Obj), Name_Access,
+ Name_Unchecked_Access,
+ Name_Unrestricted_Access)
+ then
+ return Object_Access_Level (Prefix (Orig_Obj));
+
-- Otherwise return the scope level of Standard. (If there are cases
-- that fall through to this point they will be treated as having
-- global accessibility for now. ???)