summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/controlled8.adb
blob: d75bba66536aab7d25eeb0303da1028260bdceb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--  { dg-do compile }

with Ada.Finalization; use Ada.Finalization;

procedure Controlled8
  (Int_Input : Integer;
   Str_Input : String)
is
   type Ctrl is new Controlled with null record;
   type Integer_Ptr is access all Integer;
   type String_Ptr  is access all String;

   function Func (Val : Integer) return Ctrl is
   begin return Result : Ctrl; end Func;

   function Func (Val : String) return Ctrl is
   begin return Result : Ctrl; end Func;

   type Rec_1 (Val : Integer) is record
      Comp : Ctrl := Func (Val);
   end record;

   type Rec_2 (Val : access Integer) is record
      Comp : Ctrl := Func (Val.all);
   end record;

   type Rec_3 (Val : Integer_Ptr) is record
      Comp : Ctrl := Func (Val.all);
   end record;

   type Rec_4 (Val : access String) is record
      Comp : Ctrl := Func (Val.all);
   end record;

   type Rec_5 (Val : String_Ptr) is record
      Comp : Ctrl := Func (Val.all);
   end record;

   Int_Heap  : constant Integer_Ptr := new Integer'(Int_Input);
   Int_Stack : aliased  Integer     := Int_Input;
   Str_Heap  : constant String_Ptr  := new String'(Str_Input);
   Str_Stack : aliased  String      := Str_Input;

   Obj_1  : constant Rec_1 := (Val => Int_Input, others => <>);

   Obj_2  : constant Rec_2 := (Val => Int_Heap, others => <>);
   Obj_3  : constant Rec_2 := (Val => Int_Stack'Access, others => <>);
   Obj_4  : constant Rec_2 := (Val => new Integer'(Int_Input), others => <>);

   Obj_5  : constant Rec_3 := (Val => Int_Heap, others => <>);
   Obj_6  : constant Rec_3 := (Val => Int_Stack'Access, others => <>);
   Obj_7  : constant Rec_3 := (Val => new Integer'(Int_Input), others => <>);

   Obj_8  : constant Rec_4 := (Val => Str_Heap, others => <>);
   Obj_9  : constant Rec_4 := (Val => Str_Stack'Access, others => <>);
   Obj_10 : constant Rec_4 := (Val => new String'(Str_Input), others => <>);

   Obj_11 : constant Rec_5 := (Val => Str_Heap, others => <>);
   Obj_12 : constant Rec_5 := (Val => Str_Stack'Access, others => <>);
   Obj_13 : constant Rec_5 := (Val => new String'(Str_Input), others => <>);
begin
   null;
end Controlled8;