2016-11-21 Thomas Preud'homme <thomas.preudhomme@arm.com>
[official-gcc.git] / gcc / testsuite / gnat.dg / sso1.adb
blob1b2cd5f17073a59a9ef71213678dc17cd515faa1
1 -- { dg-do run }
3 with System;
4 with Ada.Unchecked_Conversion;
5 with Ada.Streams; use Ada.Streams;
6 with Ada.Text_IO;
8 procedure SSO1 is
10 type Unsigned_Integer_4 is mod 2 ** 32;
11 for Unsigned_Integer_4'Size use 32;
13 Default_Bit_Order_Pos : constant Natural := System.Bit_Order'Pos (System.Default_Bit_Order);
15 Opposite_Bit_Order_Pos : constant Natural := 1 - Default_Bit_Order_Pos;
17 Opposite_Bit_Order : constant System.Bit_Order := System.Bit_Order'Val (Opposite_Bit_Order_Pos);
19 type Rec is
20 record
21 X, Y : Unsigned_Integer_4;
22 end record;
23 for Rec'Bit_Order use System.Default_Bit_Order;
24 for Rec'Scalar_Storage_Order use System.Default_Bit_Order;
26 for Rec use
27 record
28 X at 0 * 4 range 0 .. 31;
29 Y at 1 * 4 range 0 .. 31;
30 end record;
32 type Nested_Rec is
33 record
34 I : Unsigned_Integer_4;
35 R : Rec;
36 J : Unsigned_Integer_4;
37 end record;
38 for Nested_Rec use
39 record
40 I at 0 * 4 range 0 .. 31;
41 R at 1 * 4 range 0 .. 63;
42 J at 3 * 4 range 0 .. 31;
43 end record;
45 for Nested_Rec'Bit_Order use Opposite_Bit_Order;
46 for Nested_Rec'Scalar_Storage_Order use Opposite_Bit_Order;
48 Nr : Nested_Rec
49 := (I => 1,
50 R => (X => 1,
51 Y => 1),
52 J => 1);
54 subtype Nested_Rec_As_Stream is Ada.Streams.Stream_Element_Array (1 ..16);
56 function To_Stream is
57 new Ada.Unchecked_Conversion (Nested_Rec, Nested_Rec_As_Stream);
59 Nr_Stream : constant Nested_Rec_As_Stream := To_Stream (Nr);
61 Expected : constant array (System.Bit_Order) of Nested_Rec_As_Stream :=
62 (System.Low_Order_First =>
63 (0, 0, 0, 1,
64 1, 0, 0, 0,
65 1, 0, 0, 0,
66 0, 0, 0, 1),
67 System.High_Order_First =>
68 (1, 0, 0, 0,
69 0, 0, 0, 1,
70 0, 0, 0, 1,
71 1, 0, 0, 0));
73 begin
74 if Nr_Stream /= Expected (System.Default_Bit_Order) then
75 raise Program_Error;
76 end if;
77 end;