2016-01-15 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gnat.dg / specs / size_clause3.ads
blobb7602d9527db636b50bb4b331b20c1bb2a719b91
1 -- { dg-do compile }
3 package Size_Clause3 is
5 -- The record inherits the alignment of Integer, which is 4, so
6 -- the real size is 64 instead of 40.
7 type R1 is record
8 I : Integer;
9 B : aliased Boolean;
10 end record;
12 -- That's not OK, the size of a component of type R1 cannot be 40.
13 type S1 is record
14 rr : R1; -- size must be 40
15 end record;
16 for S1 use record
17 rr at 0 range 0 .. 39; -- { dg-error "size of .rr. with aliased or tagged" }
18 end record;
20 -- The record is explicitly given alignment 1 so its real type is 40.
21 type R2 is record
22 I : Integer;
23 B : aliased Boolean;
24 end record;
25 for R2'Alignment use 1;
27 -- That's OK, the size of a component of type R2 can be 40.
28 type S2 is record
29 rr : R2; -- size must be 40
30 end record;
31 for S2 use record
32 rr at 0 range 0 .. 39;
33 end record;
35 -- The record is explicitly given alignment 4 so its real type is 64.
36 type R3 is record
37 I : Integer;
38 B : aliased Boolean;
39 end record;
40 for R3'Alignment use 4;
42 -- That's not OK, the size of a component of type R3 cannot be 40.
43 type S3 is record
44 rr : R3; -- size must be 40
45 end record;
46 for S3 use record
47 rr at 0 range 0 .. 39; -- { dg-error "size of .rr. with aliased or tagged" }
48 end record;
50 end Size_Clause3;