Debian Codegraph @

gcc/testsuite/gnat.dg/controlled8.adb

raw
1 -- { dg-do compile }
2
3 with Ada.Finalization; use Ada.Finalization;
4
5 procedure Controlled8
6 (Int_Input : Integer;
7 Str_Input : String)
8 is
9 type Ctrl is new Controlled with null record;
10 type Integer_Ptr is access all Integer;
11 type String_Ptr is access all String;
12
13 function Func (Val : Integer) return Ctrl is
14 begin return Result : Ctrl; end Func;
15
16 function Func (Val : String) return Ctrl is
17 begin return Result : Ctrl; end Func;
18
19 type Rec_1 (Val : Integer) is record
20 Comp : Ctrl := Func (Val);
21 end record;
22
23 type Rec_2 (Val : access Integer) is record
24 Comp : Ctrl := Func (Val.all);
25 end record;
26
27 type Rec_3 (Val : Integer_Ptr) is record
28 Comp : Ctrl := Func (Val.all);
29 end record;
30
31 type Rec_4 (Val : access String) is record
32 Comp : Ctrl := Func (Val.all);
33 end record;
34
35 type Rec_5 (Val : String_Ptr) is record
36 Comp : Ctrl := Func (Val.all);
37 end record;
38
39 Int_Heap : constant Integer_Ptr := new Integer'(Int_Input);
40 Int_Stack : aliased Integer := Int_Input;
41 Str_Heap : constant String_Ptr := new String'(Str_Input);
42 Str_Stack : aliased String := Str_Input;
43
44 Obj_1 : constant Rec_1 := (Val => Int_Input, others => <>);
45
46 Obj_2 : constant Rec_2 := (Val => Int_Heap, others => <>);
47 Obj_3 : constant Rec_2 := (Val => Int_Stack'Access, others => <>);
48 Obj_4 : constant Rec_2 := (Val => new Integer'(Int_Input), others => <>);
49
50 Obj_5 : constant Rec_3 := (Val => Int_Heap, others => <>);
51 Obj_6 : constant Rec_3 := (Val => Int_Stack'Access, others => <>);
52 Obj_7 : constant Rec_3 := (Val => new Integer'(Int_Input), others => <>);
53
54 Obj_8 : constant Rec_4 := (Val => Str_Heap, others => <>);
55 Obj_9 : constant Rec_4 := (Val => Str_Stack'Access, others => <>);
56 Obj_10 : constant Rec_4 := (Val => new String'(Str_Input), others => <>);
57
58 Obj_11 : constant Rec_5 := (Val => Str_Heap, others => <>);
59 Obj_12 : constant Rec_5 := (Val => Str_Stack'Access, others => <>);
60 Obj_13 : constant Rec_5 := (Val => new String'(Str_Input), others => <>);
61 begin
62 null;
63 end Controlled8;