PR ipa/83051
[official-gcc.git] / gcc / testsuite / gnat.dg / biased_uc.adb
blobaf90f420ae9819a9d2f7e879701e6446fd2b933d
1 -- { dg-do run }
2 -- { dg-options "-gnatws" }
4 with Unchecked_Conversion;
5 procedure biased_uc is
6 begin
7 -- Case (f) target type is biased, source is unbiased
9 declare
10 type a is new integer range 0 .. 255;
11 for a'size use 8;
13 type b is new integer range 200 .. 455;
14 for b'size use 8;
16 av : a;
17 bv : b;
19 for av'size use 8;
20 for bv'size use 8;
22 function a2b is new Unchecked_Conversion (a,b);
24 begin
25 bv := a2b (200);
26 if bv = 200 then
27 raise Program_Error;
28 end if;
29 end;
31 -- Case (g) target type is biased, source object is biased
33 declare
34 type a is new integer range 1 .. 256;
35 for a'size use 16;
37 type b is new integer range 1 .. 65536;
38 for b'size use 16;
40 av : a;
41 bv : b;
43 for av'size use 8;
44 for bv'size use 16;
46 function a2b is new Unchecked_Conversion (a,b);
48 begin
49 bv := a2b (1);
50 if bv /= 2 then
51 raise Program_Error;
52 end if;
53 end;
54 end;