aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/opt84.adb
blob: 45bce7eb6256aa86575755303141a78bb50f8bef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
--  { dg-do compile }
--  { dg-options "-O2" }

with Ada.Text_IO;
with Interfaces;

procedure Opt84 is

   type Integer_8  is new Interfaces.Integer_8;
   type Integer_16 is new Interfaces.Integer_16;
   type Integer_32 is new Interfaces.Integer_32;

   type Float_32 is new Interfaces.IEEE_Float_32;

   type Natural_4 is range 0 .. 2 ** 4 - 1;
   for Natural_4'Size use 4;

   type Rec_Type is
      record
         Field_A_Int_8    : Integer_8;
         Field_B_Nat_4    : Natural_4;
         Field_C_Nat_4    : Natural_4;
         Field_D_Int_32   : Integer_32;
         Field_E_Int_32   : Integer_32;
         Field_F_Float_32 : Float_32;
         Field_G_Float_32 : Float_32;
         Field_H_Float_32 : Float_32;
         Field_I_Float_32 : Float_32;
         Field_J_Int_16   : Integer_16;
         Field_K_Int_16   : Integer_16;
         Field_L_Int_16   : Integer_16;
         Field_M_Int_16   : Integer_16;
         Field_N_Float_32 : Float_32;
         Field_O_Float_32 : Float_32;
      end record;
   pragma Pack (Rec_Type);
   for Rec_Type'Alignment use 1;

   procedure Print
     (Item : in Rec_Type) is
   begin
      Ada.Text_IO.Put_Line (Item.Field_F_Float_32'Image);
      Ada.Text_IO.Put_Line (Item.Field_G_Float_32'Image);
      Ada.Text_IO.Put_Line (Item.Field_H_Float_32'Image);
      Ada.Text_IO.Put_Line (Item.Field_I_Float_32'Image);
   end Print;

   procedure Test_Foo is
      Source : Rec_Type;
      Dest   : Rec_Type;
   begin
      Source.Field_A_Int_8 := 0;
      Dest.Field_A_Int_8    := 1;
      Dest.Field_B_Nat_4    := Source.Field_B_Nat_4;
      Dest.Field_C_Nat_4    := Source.Field_C_Nat_4;
      Dest.Field_D_Int_32   := Source.Field_D_Int_32;
      Dest.Field_E_Int_32   := Source.Field_E_Int_32;
      Dest.Field_F_Float_32 := Source.Field_F_Float_32;
      Dest.Field_G_Float_32 := Source.Field_G_Float_32;
      Dest.Field_H_Float_32 := Source.Field_H_Float_32;
      Dest.Field_I_Float_32 := Source.Field_I_Float_32;
      Dest.Field_J_Int_16   := Source.Field_J_Int_16;
      Dest.Field_K_Int_16   := Source.Field_K_Int_16;
      Dest.Field_L_Int_16   := Source.Field_L_Int_16;
      Dest.Field_M_Int_16   := Source.Field_M_Int_16;
      Dest.Field_N_Float_32 := Source.Field_N_Float_32;
      Dest.Field_O_Float_32 := Source.Field_O_Float_32;
      Print (Source);
      Print (Dest);
   end Test_Foo;

begin
   Test_Foo;
end;