Debian Codegraph @

gcc/testsuite/gnat.dg/loop_unchecked_conversion.adb

raw
1 -- { dg-do compile }
2 -- { dg-options "-gnatws -O" }
3
4 with Unchecked_Conversion;
5
6 package body loop_unchecked_conversion is
7
8 type Byte is mod 2**8;
9
10 type List is array (Natural range <>) of Byte;
11
12 subtype Integer_List is List (1 .. 4);
13
14 function Integer_Down is new
15 Unchecked_Conversion (Source => Integer, Target => Integer_List);
16
17 type Storage (Size : Integer) is
18 record
19 Data : List (1 .. Size);
20 end record;
21
22 type Storage_Pointer is access Storage;
23
24 The_Data_Storage : Storage_Pointer;
25
26 procedure slice is
27 begin
28 for I in 0 .. 1 loop
29 The_Data_Storage.Data (I+1 .. I+4) := Integer_Down (I);
30 end loop;
31 end;
32
33 end loop_unchecked_conversion;