aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gnat.dg/loop_unchecked_conversion.adb
blob: e87c415c5480efa8c367befbf4b4343a90e67419 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- { dg-do compile }
-- { dg-options "-gnatws -O" }

with Unchecked_Conversion;

package body loop_unchecked_conversion is

   type Byte is mod 2**8;

   type List is array (Natural range <>) of Byte;

   subtype Integer_List is List (1 .. 4);

   function Integer_Down is new
     Unchecked_Conversion (Source => Integer, Target => Integer_List);

   type Storage (Size : Integer) is
      record
         Data : List (1 .. Size);
      end record;

   type Storage_Pointer is access Storage;

   The_Data_Storage : Storage_Pointer;

   procedure slice is
   begin
      for I in 0 .. 1 loop
         The_Data_Storage.Data (I+1 .. I+4) := Integer_Down (I);
      end loop;
   end;

end loop_unchecked_conversion;