| 1 |
-- { dg-do compile } |
| 2 |
|
| 3 |
with Ada.Text_IO; use Ada.Text_IO; |
| 4 |
|
| 5 |
procedure Rep_Clause1 is |
| 6 |
|
| 7 |
type Int_16 is range 0 .. 65535; |
| 8 |
for Int_16'Size use 16; |
| 9 |
|
| 10 |
---------------------------------------------- |
| 11 |
|
| 12 |
type Rec_A is |
| 13 |
record |
| 14 |
Int_1 : Int_16; |
| 15 |
Int_2 : Int_16; |
| 16 |
Int_3 : Int_16; |
| 17 |
Int_4 : Int_16; |
| 18 |
end record; |
| 19 |
|
| 20 |
|
| 21 |
for Rec_A use record |
| 22 |
Int_1 at 0 range 0 .. 15; |
| 23 |
Int_2 at 2 range 0 .. 15; |
| 24 |
Int_3 at 4 range 0 .. 15; |
| 25 |
Int_4 at 6 range 0 .. 15; |
| 26 |
end record; |
| 27 |
|
| 28 |
Rec_A_Size : constant := 4 * 16; |
| 29 |
|
| 30 |
for Rec_A'Size use Rec_A_Size; |
| 31 |
|
| 32 |
---------------------------------------------- |
| 33 |
|
| 34 |
type Rec_B_Version_1 is |
| 35 |
record |
| 36 |
Rec_1 : Rec_A; |
| 37 |
Rec_2 : Rec_A; |
| 38 |
Int_1 : Int_16; |
| 39 |
end record; |
| 40 |
|
| 41 |
for Rec_B_Version_1 use record |
| 42 |
Rec_1 at 0 range 0 .. 63; |
| 43 |
Rec_2 at 8 range 0 .. 63; |
| 44 |
Int_1 at 16 range 0 .. 15; |
| 45 |
end record; |
| 46 |
|
| 47 |
Rec_B_Size : constant := 2 * Rec_A_Size + 16; |
| 48 |
|
| 49 |
for Rec_B_Version_1'Size use Rec_B_Size; |
| 50 |
for Rec_B_Version_1'Alignment use 2; |
| 51 |
|
| 52 |
---------------------------------------------- |
| 53 |
|
| 54 |
type Rec_B_Version_2 is |
| 55 |
record |
| 56 |
Int_1 : Int_16; |
| 57 |
Rec_1 : Rec_A; |
| 58 |
Rec_2 : Rec_A; |
| 59 |
end record; |
| 60 |
|
| 61 |
for Rec_B_Version_2 use record |
| 62 |
Int_1 at 0 range 0 .. 15; |
| 63 |
Rec_1 at 2 range 0 .. 63; |
| 64 |
Rec_2 at 10 range 0 .. 63; |
| 65 |
end record; |
| 66 |
|
| 67 |
for Rec_B_Version_2'Size use Rec_B_Size; |
| 68 |
|
| 69 |
---------------------------------------------- |
| 70 |
|
| 71 |
Arr_A_Length : constant := 2; |
| 72 |
Arr_A_Size : constant := Arr_A_Length * Rec_B_Size; |
| 73 |
|
| 74 |
type Arr_A_Version_1 is array (1 .. Arr_A_Length) of Rec_B_Version_1; |
| 75 |
type Arr_A_Version_2 is array (1 .. Arr_A_Length) of Rec_B_Version_2; |
| 76 |
|
| 77 |
pragma Pack (Arr_A_Version_1); |
| 78 |
pragma Pack (Arr_A_Version_2); |
| 79 |
|
| 80 |
for Arr_A_Version_1'Size use Arr_A_Size; |
| 81 |
for Arr_A_Version_2'Size use Arr_A_Size; |
| 82 |
|
| 83 |
---------------------------------------------- |
| 84 |
|
| 85 |
begin |
| 86 |
-- Put_Line ("Arr_A_Size =" & Arr_A_Size'Img); |
| 87 |
|
| 88 |
if Arr_A_Version_1'Size /= Arr_A_Size then |
| 89 |
Ada.Text_IO.Put_Line |
| 90 |
("Version 1 Size mismatch! " & |
| 91 |
"Arr_A_Version_1'Size =" & Arr_A_Version_1'Size'Img); |
| 92 |
end if; |
| 93 |
|
| 94 |
if Arr_A_Version_2'Size /= Arr_A_Size then |
| 95 |
Ada.Text_IO.Put_Line |
| 96 |
("Version 2 Size mismatch! " & |
| 97 |
"Arr_A_Version_2'Size =" & Arr_A_Version_2'Size'Img); |
| 98 |
|
| 99 |
end if; |
| 100 |
|
| 101 |
end; |