summaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats/tests/cd/cd70001.a
blob: 484009588046cd59d9b9b035a10585beef7a7978 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
--
-- CD70001.A
--
--                             Grant of Unlimited Rights
--
--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained 
--     unlimited rights in the software and documentation contained herein.
--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making 
--     this public release, the Government intends to confer upon all 
--     recipients unlimited rights  equal to those held by the Government.  
--     These rights include rights to use, duplicate, release or disclose the 
--     released technical data and computer software in whole or in part, in 
--     any manner and for any purpose whatsoever, and to have or permit others 
--     to do so.
--
--                                    DISCLAIMER
--
--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED 
--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE 
--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
--     PARTICULAR PURPOSE OF SAID MATERIAL.
--*
--
-- OBJECTIVE:
--      Check that package System includes Max_Base_Digits, Address,
--      Null_Address, Word_Size, functions "<", "<=", ">", ">=", "="
--      (with Address parameters and Boolean results), Bit_Order,
--      Default_Bit_Order, Any_Priority, Interrupt_Priority,
--      and Default_Priority.
--
--      Check that package System.Storage_Elements includes all required
--      types and operations.
--
-- TEST DESCRIPTION:
--      The test checks for the existence of the names additional
--      to package system above those names tested for in 9Xbasic.
--
--      This test checks that the semantics provided in Storage_Elements
--      are present and operate marginally within expectations (to the best
--      extent possible in a portable implementation independent fashion).
--
--
-- CHANGE HISTORY:
--      09 MAY 95   SAIC   Initial version
--      27 JAN 96   SAIC   Revised for 2.1; Allow negative address delta
--
--!

with Report;
with Ada.Text_IO;
with System.Storage_Elements;
with System.Address_To_Access_Conversions;
procedure CD70001 is
  use System;

  procedure CD70 is

    type Int_Max is range Min_Int .. Max_Int;

    My_Int : Int_Max := System.Max_Base_Digits + System.Word_Size;

    An_Address : Address;
    An_Other_Address : Address := An_Address'Address;

  begin  -- 7.0


      if Default_Bit_Order not in High_Order_First..Low_Order_First then
         Report.Failed ("Default_Bit_Order invalid");
      end if;

      if Bit_Order'Pos(High_Order_First) /= 0 then
         Report.Failed ("Bit_Order'Pos(High_Order_First) /= 0");
      end if;

      if Bit_Order'Pos(Low_Order_First) /= 1 then
         Report.Failed ("Bit_Order'Pos(Low_Order_First) /= 1");
      end if;

      An_Address := My_Int'Address;

      if An_Address = Null_Address then
        Report.Failed ("Null_Address matched a real address");
      end if;


      if An_Address'Address /= An_Other_Address then
        Report.Failed("Value set at elaboration not equal to itself");
      end if;

      if An_Address'Address > An_Other_Address 
         and An_Address'Address < An_Other_Address then
        Report.Failed("Address is both greater and less!");
      end if;

      if not (An_Address'Address >= An_Other_Address 
         and An_Address'Address <= An_Other_Address) then
        Report.Failed("Address comparisons wrong");
      end if;


      if Priority'First /= Any_Priority'First then
        Report.Failed ("Priority'First /= Any_Priority'First");
      end if;

      if Interrupt_Priority'First /= Priority'Last+1 then
        Report.Failed ("Interrupt_Priority'First /= Priority'Last+1");
      end if;

      if Interrupt_Priority'Last /= Any_Priority'Last then
        Report.Failed ("Interrupt_Priority'Last /= Any_Priority'Last");
      end if;

      if Default_Priority /= ((Priority'First + Priority'Last)/2) then
        Report.Failed ("Default_Priority wrong value");
      end if;

  end CD70;

  procedure CD71 is
    use System.Storage_Elements;

    Storehouse_1 : Storage_Array(0..127);
    Storehouse_2 : Storage_Array(0..127);

    House_Offset : Storage_Offset;

  begin  -- 7.1


      if Storage_Count'First /= 0 then
        Report.Failed ("Storage_Count'First /= 0");
      end if;

      if Storage_Count'Last /= Storage_Offset'Last then
        Report.Failed ("Storage_Count'Last /= Storage_Offset'Last");
      end if;


      if Storage_Element'Size /= Storage_Unit then
        Report.Failed ("Storage_Element'Size /= Storage_Unit");
      end if;

      if Storage_Array'Component_Size /= Storage_Unit then
        Report.Failed ("Storage_Array'Element_Size /= Storage_Unit");
      end if;

      if Storage_Element'Last+1 /= 0 then
        Report.Failed ("Storage_Element not modular");
      end if;


      -- "+", "-"( Address, Storage_Offset) and inverse

      House_Offset := Storehouse_2'Address - Storehouse_1'Address;
      -- Address - Address = Offset
      -- Note that House_Offset may be a negative value

      if House_Offset + Storehouse_1'Address /= Storehouse_2'Address then
      -- Offset + Address = Address
        Report.Failed ("Storage arithmetic non-linear O+A");
      end if;

      if Storehouse_1'Address + House_Offset /= Storehouse_2'Address then
      -- Address + Offset = Address
        Report.Failed ("Storage arithmetic non-linear A+O");
      end if;

      if Storehouse_2'Address - House_Offset /= Storehouse_1'Address then
      -- Address - Offset = Address
        Report.Failed ("Storage arithmetic non-linear A-O");
      end if;

      if (Storehouse_2'Address mod abs(House_Offset) > abs(House_Offset)) then
      -- "mod"( Address, Storage_Offset)
        Report.Failed("Mod arithmetic");
      end if;


      if Storehouse_1'Address
         /= To_Address(To_Integer(Storehouse_1'Address)) then
        Report.Failed("To_Address, To_Integer not symmetric");
      end if;

  end CD71;


begin  -- Main test procedure.

   Report.Test ("CD70001", "Check package System" );

   CD70;

   CD71;

  Report.Result;

end CD70001;