access_to_object_definition
| access_to_subprogram_definition
access [general_access_modifier] subtype_indication
access [protected] procedure parameter_profile
| access [protected] function parameter_and_result_profile
procedure P(X : access T1);
procedure P(X : access T2) is
begin
P(T1(X.all)'Access); -- hand off to T1's P
. . . -- now do extra T2-specific processing
end P;
type Binop_Ptr is access all Binary_Operation'Class;
-- general access-to-class-wide, see 3.9.1
procedure Default_Message_Procedure(M : in String);
Give_Message : Message_Procedure := Default_Message_Procedure'Access;
...
procedure Other_Procedure(M : in String);
...
Give_Message := Other_Procedure'Access;
...
Give_Message("File not found."); --call with parameter (.all is optional)
Give_Message.all; --call with no parameters
type Link is access Cell;
record
Value : Integer;
Succ : Link;
Pred : Link;
end record;
Next : Link := Head.Succ;
type Car; -- incomplete type declaration
type Car_Name is access all Car;
record
Number : Integer;
Owner : Person_Name;
end record;
record
Name : String(1 .. 20);
Birth : Date;
Age : Integer range 0 .. 130;
Vehicle : Car_Name;
case Sex is
when M => Wife : Person_Name(Sex => F);
when F => Husband : Person_Name(Sex => M);
end case;
end record;
George : Person_Name := new Person(M);
...
George.Vehicle := Your_Car;
type Pri is private;
private
type Sep;
type Pri is access Sep;
X : Pri;
end Pack;
type Sep is ...;
X := new Sep;
end Pack;
private package Pack.Child is
I : Integer := X.all'Size; --Legal, by AI-00039.
end Pack.Child;
type T is tagged ...;
type A0 is access all T;
Global: A0 := ...;
procedure P(X: T) is
Y: aliased T;
type A1 is access all T;
Ptr0: A0 := Global; --OK.
Ptr1: A1 := X'Access; --OK.
begin
Ptr1 := Y'Access; --OK;
Ptr0 := A0(Ptr1); --Illegal type conversion!
Ptr0 := X'Access; --Illegal reference to Access attribute!
Ptr0 := Y'Access; --Illegal reference to Access attribute!
Global := Ptr0; --OK.
end P;
end Lib_Unit;
type Level_1_Type is access all Integer;
type Nested_Type is access all Integer;
begin
... Nested_Type(X) ... --(1)
... Level_1_Type(X) ... --(2)
end P;
procedure Nested(X: access Integer) is
begin
P(X);
end Nested;
begin
Nested(X);
end Q;
Level_2: aliased Integer;
begin
Q(Level_2'Access); --(3)
end R;
begin
Q(Level_1'Access); --(4)
R;
end Main;
type Int_Ptr is access all Integer;
type Rec(D: access Integer) is limited private;
private
type Rec_Ptr is access all Rec;
function F(X: Rec_Ptr) return Boolean;
function G(X: access Rec) return Boolean;
type Rec(D: access Integer) is
record
C1: Int_Ptr := Int_Ptr(D); --Illegal!
C2: Rec_Ptr := Rec'Access; --Illegal!
C3: Boolean := F(Rec'Access); --Illegal!
C4: Boolean := G(Rec'Access);
end record;
end P;
Cars : array (1..2) of aliased Car;
...
Martha.Vehicle := Cars(1)'Access;
George.Vehicle := Cars(2)'Access;