| 1 |
-- { dg-do compile } |
| 2 |
-- { dg-options "-gnatws" } |
| 3 |
|
| 4 |
with System.Storage_Elements; use System.Storage_Elements; |
| 5 |
with Unchecked_Conversion; |
| 6 |
with Slice7_Pkg; use Slice7_Pkg; |
| 7 |
|
| 8 |
procedure Slice7 is |
| 9 |
|
| 10 |
type Discrete_Type is range 1 .. 32; |
| 11 |
|
| 12 |
Max_Byte_Count : constant := 4; |
| 13 |
subtype Byte_Count_Type is Storage_Offset range 1..Max_Byte_Count; |
| 14 |
|
| 15 |
subtype Buffer_Type is Storage_Array (Byte_Count_Type); |
| 16 |
function Convert_Put is new Unchecked_Conversion (Integer, Buffer_Type); |
| 17 |
|
| 18 |
function Set_Buffer_Size return Byte_Count_Type is |
| 19 |
begin |
| 20 |
return 4; |
| 21 |
end; |
| 22 |
|
| 23 |
Buffer_Size : constant Byte_Count_Type := Set_Buffer_Size; |
| 24 |
Buffer_End : constant Byte_Count_Type := Max_Byte_Count; |
| 25 |
Buffer_Start : constant Byte_Count_Type := Buffer_End - Buffer_Size + 1; |
| 26 |
|
| 27 |
Obj : Discrete_Type; |
| 28 |
|
| 29 |
begin |
| 30 |
Put (Convert_Put(Discrete_Type'Pos (Obj))); |
| 31 |
|
| 32 |
Put (Convert_Put(Discrete_Type'Pos (Obj)) |
| 33 |
(Buffer_Start..Buffer_End)); |
| 34 |
|
| 35 |
Put (Convert_Put(Discrete_Type'Pos (Obj) - |
| 36 |
Discrete_Type'Pos (Discrete_Type'First)) |
| 37 |
(Buffer_Start..Buffer_End)); |
| 38 |
end; |