Debian Codegraph @

gcc/testsuite/gnat.dg/specs/size_clause1.ads

raw
1 -- { dg-do compile }
2 -- { dg-options "-gnatws" }
3
4 package Size_Clause1 is
5
6 -- The record inherits the alignment of Integer, which is 4, so
7 -- the real size is 64 instead of 40. That's OK, as long as the
8 -- size of a component of type R1 in a packed record is 40.
9 type R1 is record
10 I : Integer;
11 B : Boolean;
12 end record;
13 for R1'Size use 40;
14
15 type S1 is record
16 rr : R1; -- size must be 40
17 end record;
18 pragma Pack(S1);
19
20 -- The record is explicitly given alignment 1 so its real type is 40 too.
21 -- The size of a component of type R2 in a packed record is naturally 40.
22 type R2 is record
23 I : Integer;
24 B : Boolean;
25 end record;
26 for R2'Size use 40;
27 for R2'Alignment use 1;
28
29 type S2 is record
30 rr : R2; -- size must be 40
31 end record;
32 pragma Pack(S2);
33
34 -- The record is explicitly given alignment 4 so its real type is 64.
35 -- That's OK, as long as the size of a component of type R3 in a packed
36 -- record is 40.
37 type R3 is record
38 I : Integer;
39 B : Boolean;
40 end record;
41 for R3'Size use 40;
42 for R3'Alignment use 4;
43
44 type S3 is record
45 rr : R3; -- size must be 40
46 end record;
47 pragma Pack(S3);
48
49 end Size_Clause1;