Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gnat.dg / unchecked_convert12.adb
blob6a7ad22cd0c849b94dbdd0cd679d3a833da8a966
1 -- { dg-do run }
3 with Unchecked_Conversion;
5 procedure Unchecked_Convert12 is
7 subtype Unsigned_Type is Integer range 2_034 .. 2_164;
9 subtype Signed_Type is Integer range -2048 .. 2047;
11 type Rec is record
12 S : Unsigned_Type;
13 end record;
14 pragma Pack (Rec);
16 function To_Signed_Type is
17 new Unchecked_Conversion (Source => Rec, Target => Signed_Type);
19 function To_Unsigned_Type is
20 new Unchecked_Conversion (Source => Signed_Type, Target => Rec);
22 Data : Signed_Type;
23 Temp : Rec;
25 begin
27 Data := -1996;
28 Temp := To_Unsigned_Type (Data);
29 if Temp.S /= 2100 then
30 raise Program_Error;
31 end if;
32 Data := To_Signed_Type (Temp);
33 if Data /= -1996 then
34 raise Program_Error;
35 end if;
37 Data := 2047;
38 Temp := To_Unsigned_Type (Data);
39 if Temp.S /= 2047 then
40 raise Program_Error;
41 end if;
42 Data := To_Signed_Type (Temp);
43 if Data /= 2047 then
44 raise Program_Error;
45 end if;
47 end;