RISC-V: Add support for riscv-*-*.
[official-gcc.git] / gcc / testsuite / gnat.dg / unchecked_convert2.adb
blobf542af7c343e0c391f83658cbc7dd602557da4b1
1 -- { dg-do run }
3 with Ada.Unchecked_Conversion;
4 with Ada.Streams; use Ada.Streams;
5 with Ada.Text_IO; use Ada.Text_IO;
7 procedure Unchecked_Convert2 is
9 subtype Day_Number is Integer range 0 .. 31;
11 subtype Byte_Array_Of_Integer is Stream_Element_Array
12 (1 .. Integer'Size / Stream_Element_Array'Component_Size);
14 function To_Byte_Array is
15 new Ada.Unchecked_Conversion (Integer, Byte_Array_Of_Integer);
17 Day_Now : Day_Number;
18 Pragma Volatile (Day_Now);
20 Arr : Stream_Element_Array (1 .. 12) := (others => 16#ff#);
22 procedure Test (Arr : Stream_Element_Array) is
23 begin
24 if Arr(5) /= 0 or Arr(6) /= 0 or Arr(7) /= 0 or Arr(8) /= 0 then
25 raise Program_Error;
26 end if;
27 end;
29 begin
30 Day_Now := 0;
31 Arr (5 .. 8) := To_Byte_Array (Day_Now);
32 Test (Arr);
33 Arr (1) := 16#ff#;
34 end Unchecked_Convert2;