OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gnat.dg/] [unchecked_convert2.adb] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 696 jeremybenn
-- { dg-do run }
2
 
3
with Ada.Unchecked_Conversion;
4
with Ada.Streams; use Ada.Streams;
5
with Ada.Text_IO; use Ada.Text_IO;
6
 
7
procedure Unchecked_Convert2 is
8
 
9
   subtype Day_Number is Integer range 0 .. 31;
10
 
11
   subtype Byte_Array_Of_Integer is Stream_Element_Array
12
     (1 .. Integer'Size / Stream_Element_Array'Component_Size);
13
 
14
   function To_Byte_Array is
15
      new Ada.Unchecked_Conversion (Integer, Byte_Array_Of_Integer);
16
 
17
   Day_Now : Day_Number;
18
   Pragma Volatile (Day_Now);
19
 
20
   Arr : Stream_Element_Array (1 .. 12) := (others => 16#ff#);
21
 
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;
28
 
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;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.