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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [gnat.dg/] [unchecked_convert1.adb] - Blame information for rev 779

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

Line No. Rev Author Line
1 304 jeremybenn
-- { dg-do run }
2
-- { dg-options "-gnatws" }
3
 
4
with Ada.Unchecked_Conversion;
5
 
6
procedure Unchecked_Convert1 is
7
  type Byte is mod 2**8;
8
 
9
  type Stream is array (Natural range <>) of Byte;
10
 
11
  type Rec is record
12
    I1, I2 : Integer;
13
  end record;
14
 
15
  function Do_Sum (R : Rec) return Integer is
16
  begin
17
    return R.I1 + R.I2;
18
  end;
19
 
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;
26
 
27
  A : Stream (1..9);
28
  I : Integer;
29
 
30
begin
31
  I := Sum (A(1..8));
32
end;

powered by: WebSVN 2.1.0

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