* snames.ads-tmpl (Name_Ivdep): New pragma-related name.
[official-gcc.git] / gcc / testsuite / gnat.dg / unchecked_convert1.adb
blobeb63d59a884d47e5ab3c5061ff0ca0eb67be8f4b
1 -- { dg-do run }
2 -- { dg-options "-gnatws" }
4 with Ada.Unchecked_Conversion;
6 procedure Unchecked_Convert1 is
7 type Byte is mod 2**8;
9 type Stream is array (Natural range <>) of Byte;
11 type Rec is record
12 I1, I2 : Integer;
13 end record;
15 function Do_Sum (R : Rec) return Integer is
16 begin
17 return R.I1 + R.I2;
18 end;
20 function Sum (S : Stream) return Integer is
21 subtype Chunk is Stream (1 .. Rec'Size / 8);
22 function To_Chunk is new Ada.Unchecked_Conversion (Chunk, Rec);
23 begin
24 return Do_Sum (To_Chunk (S(S'First .. S'First + Rec'Size / 8 - 1)));
25 end;
27 A : Stream (1..9);
28 I : Integer;
30 begin
31 I := Sum (A(1..8));
32 end;