1-- { dg-do compile }
2
3package Size_Clause3 is
4
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;
11
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 for .rr. with aliased part too small" }
18  end record;
19
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;
26
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;
34
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;
41
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 for .rr. with aliased part too small" }
48  end record;
49
50end Size_Clause3;
51