Debian Codegraph @

gcc/testsuite/gnat.dg/unchecked_union2.adb

raw
1 -- { dg-do compile }
2
3 procedure Unchecked_Union2 is
4 type small_array is array (0 .. 2) of Integer;
5 type big_array is array (0 .. 3) of Integer;
6
7 type small_record is record
8 field1 : aliased Integer := 0;
9 field2 : aliased small_array := (0, 0, 0);
10 end record;
11
12 type big_record is record
13 field1 : aliased Integer := 0;
14 field2 : aliased big_array := (0, 0, 0, 0);
15 end record;
16
17 type myUnion (discr : Integer := 0) is record
18 case discr is
19 when 0 =>
20 record1 : aliased small_record;
21 when others =>
22 record2 : aliased big_record;
23 end case;
24 end record;
25
26 type UU_myUnion3 (discr : Integer := 0) is new myUnion (discr); -- Test
27 pragma Unchecked_Union (UU_myUnion3);
28 pragma Convention (C, UU_myUnion3);
29
30 procedure Convert (A : in UU_myUnion3; B : out UU_myUnion3);
31 pragma Import (C, Convert);
32
33 begin
34 null;
35 end Unchecked_Union2;