8.5.1 Object Renaming Declarations
Syntax
Name Resolution Rules
In the case where the type is defined by an
access_definition,
the type of the
object_name
shall resolve to an anonymous access type. If the anonymous access type
is an access-to-object type, the type of the
object_name
shall have the same designated type as that of the
access_definition.
If the anonymous access type is an access-to-subprogram type, the type
of the
object_name
shall have a designated profile that is type conformant with that of
the
access_definition.
Legality Rules
The renamed entity shall be an object.
shall both be access-to-object types with statically
matching designated subtypes and with both or neither being access-to-constant
types; or
shall both be access-to-subprogram types with subtype
conformant designated profiles.
if the
object_name
statically denotes a generic formal object of mode
in out of
G,
then the declaration of that object shall have a
null_exclusion;
if the
object_name
statically denotes a call of a generic formal function of
G, then
the declaration of the result of that function shall have a
null_exclusion.
In addition to the places where
Legality Rules normally apply (see
12.3),
this rule applies also in the private part of an instance of a generic
unit.
The renamed entity shall not be a subcomponent that
depends on discriminants of an object whose nominal subtype is unconstrained
unless the object is known to be constrained. A
slice
of an array shall not be renamed if this restriction disallows renaming
of the array.
In addition to the places where Legality
Rules normally apply, these rules apply also in the private part of an
instance of a generic unit.
Static Semantics
Examples
Example of renaming
an object:
declare
L : Person
renames Leftmost_Person; --
see 3.10.1
begin
L.Age := L.Age + 1;
end;
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe