PR ipa/83051
[official-gcc.git] / gcc / testsuite / gnat.dg / unchecked_convert10.adb
blob13b24c1e6ac5830827211b93ca79900016592380
1 -- { dg-do run }
3 with Unchecked_Conversion;
5 procedure Unchecked_Convert10 is
7 subtype Unsigned_Type is Integer range 2_034 .. 2_164;
9 subtype Signed_Type is Integer range -2048 .. 2047;
11 function To_Signed_Type is
12 new Unchecked_Conversion (Source => Unsigned_Type, Target => Signed_Type);
14 function To_Unsigned_Type is
15 new Unchecked_Conversion (Source => Signed_Type, Target => Unsigned_Type);
17 Data : Unsigned_Type;
18 Temp : Signed_Type;
20 begin
22 Data := 2100;
23 Temp := To_Signed_Type (Data);
24 if Temp /= -1996 then
25 raise Program_Error;
26 end if;
27 Data := To_Unsigned_Type (Temp);
28 if Data /= 2100 then
29 raise Program_Error;
30 end if;
32 Data := 2047;
33 Temp := To_Signed_Type (Data);
34 if Temp /= 2047 then
35 raise Program_Error;
36 end if;
37 Data := To_Unsigned_Type (Temp);
38 if Data /= 2047 then
39 raise Program_Error;
40 end if;
42 end;