Debian Codegraph @

gcc/testsuite/gnat.dg/limited4.adb

raw
1 -- { dg-do compile }
2 procedure Limited4 is
3 TBD_Error : exception;
4
5 type Lim_Rec is limited record
6 A : Integer;
7 B : Boolean;
8 end record;
9
10 type Lim_Tagged is tagged limited record
11 R : Lim_Rec;
12 N : Natural;
13 end record;
14
15 type Lim_Ext is new Lim_Tagged with record
16 G : Natural;
17 end record;
18
19 -- a) initialization expression of a CW object_declaration
20
21 Obj1 : Lim_Tagged'Class := (raise TBD_Error);
22 Obj2 : Lim_Tagged'Class := Lim_Tagged'Class'(raise TBD_Error);
23
24 -- b) initialization expression of a CW component_declaration
25 -- ... is illegal: cannot have unconstrained components.
26 --
27 -- type Rec is record
28 -- Comp01 : Lim_Tagged'Class := (raise TBD_Error);
29 -- Comp02 : Lim_Tagged'Class := Lim_Tagged'Class'((raise TBD_Error));
30 -- end record;
31
32 -- c) the expression of a record_component_association
33
34 Obj : Lim_Tagged := (R => raise TBD_Error, N => 4);
35
36 -- d) the expression for an ancestor_part of an extension_aggregate
37
38 Ext1 : Lim_Ext := ((raise TBD_Error) with G => 0);
39 Ext2 : Lim_Ext := (Lim_Tagged'(raise TBD_Error) with G => 0);
40
41 -- e) default_expression or actual parameter for a formal object of
42 -- mode in
43
44 function Do_Test1 (Obj : Lim_Tagged) return Boolean is
45 begin
46 return True;
47 end;
48
49 function Do_Test2
50 (Obj : Lim_Tagged := (raise TBD_Error)) return Boolean is
51 begin
52 return True;
53 end;
54
55 Check : Boolean;
56 begin
57 Check := Do_Test1 (raise TBD_Error);
58 Check := Do_Test2;
59 end;