Debian Codegraph @

gcc/testsuite/gnat.dg/opt84.adb

raw
1 -- { dg-do compile }
2 -- { dg-options "-O2" }
3
4 with Ada.Text_IO;
5 with Interfaces;
6
7 procedure Opt84 is
8
9 type Integer_8 is new Interfaces.Integer_8;
10 type Integer_16 is new Interfaces.Integer_16;
11 type Integer_32 is new Interfaces.Integer_32;
12
13 type Float_32 is new Interfaces.IEEE_Float_32;
14
15 type Natural_4 is range 0 .. 2 ** 4 - 1;
16 for Natural_4'Size use 4;
17
18 type Rec_Type is
19 record
20 Field_A_Int_8 : Integer_8;
21 Field_B_Nat_4 : Natural_4;
22 Field_C_Nat_4 : Natural_4;
23 Field_D_Int_32 : Integer_32;
24 Field_E_Int_32 : Integer_32;
25 Field_F_Float_32 : Float_32;
26 Field_G_Float_32 : Float_32;
27 Field_H_Float_32 : Float_32;
28 Field_I_Float_32 : Float_32;
29 Field_J_Int_16 : Integer_16;
30 Field_K_Int_16 : Integer_16;
31 Field_L_Int_16 : Integer_16;
32 Field_M_Int_16 : Integer_16;
33 Field_N_Float_32 : Float_32;
34 Field_O_Float_32 : Float_32;
35 end record;
36 pragma Pack (Rec_Type);
37 for Rec_Type'Alignment use 1;
38
39 procedure Print
40 (Item : in Rec_Type) is
41 begin
42 Ada.Text_IO.Put_Line (Item.Field_F_Float_32'Image);
43 Ada.Text_IO.Put_Line (Item.Field_G_Float_32'Image);
44 Ada.Text_IO.Put_Line (Item.Field_H_Float_32'Image);
45 Ada.Text_IO.Put_Line (Item.Field_I_Float_32'Image);
46 end Print;
47
48 procedure Test_Foo is
49 Source : Rec_Type;
50 Dest : Rec_Type;
51 begin
52 Source.Field_A_Int_8 := 0;
53 Dest.Field_A_Int_8 := 1;
54 Dest.Field_B_Nat_4 := Source.Field_B_Nat_4;
55 Dest.Field_C_Nat_4 := Source.Field_C_Nat_4;
56 Dest.Field_D_Int_32 := Source.Field_D_Int_32;
57 Dest.Field_E_Int_32 := Source.Field_E_Int_32;
58 Dest.Field_F_Float_32 := Source.Field_F_Float_32;
59 Dest.Field_G_Float_32 := Source.Field_G_Float_32;
60 Dest.Field_H_Float_32 := Source.Field_H_Float_32;
61 Dest.Field_I_Float_32 := Source.Field_I_Float_32;
62 Dest.Field_J_Int_16 := Source.Field_J_Int_16;
63 Dest.Field_K_Int_16 := Source.Field_K_Int_16;
64 Dest.Field_L_Int_16 := Source.Field_L_Int_16;
65 Dest.Field_M_Int_16 := Source.Field_M_Int_16;
66 Dest.Field_N_Float_32 := Source.Field_N_Float_32;
67 Dest.Field_O_Float_32 := Source.Field_O_Float_32;
68 Print (Source);
69 Print (Dest);
70 end Test_Foo;
71
72 begin
73 Test_Foo;
74 end;