summaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats/tests/cc/cc1225a.tst
blob: dfad3b0eda569d1fb7dffef3b426007f9eaad828 (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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
-- CC1225A.TST

--                             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, FOR A FORMAL ACCESS TYPE, THAT ALL ALLOWABLE OPERATIONS
--     ARE IMPLICITLY DECLARED.

-- MACRO SUBSTITUTION:
--     $TASK_STORAGE_SIZE IS THE NUMBER OF STORAGE_UNITS REQUIRED FOR
--     THE ACTIVATION OF A TASK.

-- HISTORY:
--     BCB 03/29/88  CREATED ORIGINAL TEST.
--     RDH 04/09/90  ADDED 'STORAGE_SIZE CLAUSES.  CHANGED EXTENSION TO
--                   'TST'.
--     LDC 09/26/90  REMOVED 'USE PACK' AFTER THE WITH SINCE IT ISN'T 
--                   NEEDED, ADDED CHECK FOR NULL AFTER ASSIGMENT TO
--                   NULL, ADDED CHECKS FOR OTHER RELATION OPERATORS,
--                   CHANGED CHECK FOR 'ADDRESS TO A PROCEDURE CALL.
--     LDC 10/13/90  CHANGED CHECK FOR 'SIZE TO ONLY CHECK FOR 
--                   AVAILABILITY.  CHANGED CHECK FOR 'ADDRESS TO A 
--                   MEMBERSHIP TEST.
--     PWN 01/31/95  REMOVED INCONSISTENCIES WITH ADA 9X.

WITH REPORT; USE REPORT;
WITH SYSTEM; USE SYSTEM;

PROCEDURE CC1225A IS

     TASK_STORAGE_SIZE : CONSTANT := $TASK_STORAGE_SIZE;

     TYPE AI IS ACCESS INTEGER;

     TYPE ACCINTEGER IS ACCESS INTEGER;

     TYPE REC IS RECORD
          COMP : INTEGER;
     END RECORD;

     TYPE DISCREC (DISC : INTEGER := 1) IS RECORD
          COMPD : INTEGER;
     END RECORD;

     TYPE AREC IS ACCESS REC;

     TYPE ADISCREC IS ACCESS DISCREC;

     TYPE ARR IS ARRAY(1..2,1..2) OF INTEGER;

     TYPE ONEDIM IS ARRAY(1..10) OF INTEGER;

     TYPE AA IS ACCESS ARR;

     TYPE AONEDIM IS ACCESS ONEDIM;

     TYPE ENUM IS (ONE, TWO, THREE);

     TASK TYPE T IS
          ENTRY HERE(VAL : IN OUT INTEGER);
     END T;

     TYPE ATASK IS ACCESS T;

     TYPE ANOTHERTASK IS ACCESS T;
     FOR ANOTHERTASK'STORAGE_SIZE USE 2 * TASK_STORAGE_SIZE;

     TASK TYPE T1 IS
          ENTRY HERE1(ENUM)(VAL1 : IN OUT INTEGER);
     END T1;

     TYPE ATASK1 IS ACCESS T1;

     TASK BODY T IS
     BEGIN
          ACCEPT HERE(VAL : IN OUT INTEGER) DO
               VAL := VAL * 2;
          END HERE;
     END T;

     TASK BODY T1 IS
     BEGIN
          SELECT
               ACCEPT HERE1(ONE)(VAL1 : IN OUT INTEGER) DO
                    VAL1 := VAL1 * 1;
               END HERE1;
          OR
               ACCEPT HERE1(TWO)(VAL1 : IN OUT INTEGER) DO
                    VAL1 := VAL1 * 2;
               END HERE1;
          OR
               ACCEPT HERE1(THREE)(VAL1 : IN OUT INTEGER) DO
                    VAL1 := VAL1 * 3;
               END HERE1;
          END SELECT;
     END T1;

     GENERIC
          TYPE FORM IS (<>);
          TYPE ACCFORM IS ACCESS FORM;
          TYPE ACC IS ACCESS INTEGER;
          TYPE ACCREC IS ACCESS REC;
          TYPE ACCDISCREC IS ACCESS DISCREC;
          TYPE ACCARR IS ACCESS ARR;
          TYPE ACCONE IS ACCESS ONEDIM;
          TYPE ACCTASK IS ACCESS T;
          TYPE ACCTASK1 IS ACCESS T1;
          TYPE ANOTHERTASK1 IS ACCESS T;
     PACKAGE P IS
     END P;

     PACKAGE BODY P IS
          AF : ACCFORM;
          TYPE DER_ACC IS NEW ACC;
          A, B : ACC;
          DERA : DER_ACC;
          R : ACCREC;
          DR : ACCDISCREC;
          C : ACCARR;
          D, E : ACCONE;
          F : ACCTASK;
          G : ACCTASK1;
          INT : INTEGER := 5;

     BEGIN
          TEST ("CC1225A", "CHECK, FOR A FORMAL ACCESS TYPE, THAT " &
                           "ALL ALLOWABLE OPERATIONS ARE IMPLICITLY " &
                           "DECLARED");

          IF AF'ADDRESS NOT IN ADDRESS THEN
               FAILED ("IMPROPER RESULT FROM AF'ADDRESS TEST");
          END IF;

          DECLARE
               AF_SIZE : INTEGER := ACCFORM'SIZE;
          BEGIN
               IF AF_SIZE NOT IN INTEGER THEN
                    FAILED ("IMPROPER RESULT FROM AF'SIZE");
               END IF;
          END;

          IF ANOTHERTASK1'STORAGE_SIZE < TASK_STORAGE_SIZE THEN
               FAILED ("IMPROPER VALUE FOR ANOTHERTASK1'STORAGE_SIZE");
          END IF;

          B := NEW INTEGER'(25);

          A := B;

          IF A.ALL /= 25 THEN
               FAILED ("IMPROPER VALUE FOR ASSIGNMENT OF VARIABLE " &
                       "OF A FORMAL ACCESS TYPE FROM ANOTHER " &
                       "VARIABLE OF A FORMAL ACCESS TYPE");
          END IF;

          A := NEW INTEGER'(10);

          IF A.ALL /= 10 THEN
               FAILED ("IMPROPER VALUE FOR VARIABLE OF FORMAL ACCESS " &
                       "TYPE");
          END IF;

          IF A NOT IN ACC THEN
               FAILED ("IMPROPER RESULT FROM MEMBERSHIP TEST");
          END IF;

          B := ACC'(A);

          IF B.ALL /= 10 THEN
               FAILED ("IMPROPER VALUE FROM QUALIFICATION");
          END IF;

          DERA := NEW INTEGER'(10);
          A := ACC(DERA);

          IF A.ALL /= IDENT_INT(10) THEN
               FAILED ("IMPROPER VALUE FROM EXPLICIT CONVERSION");
          END IF;

          IF A.ALL > IDENT_INT(10) THEN
               FAILED ("IMPROPER VALUE USED IN LESS THAN");
          END IF;

          IF A.ALL < IDENT_INT(10) THEN
               FAILED ("IMPROPER VALUE USED IN GREATER THAN");
          END IF;

          IF A.ALL >= IDENT_INT(11) THEN
               FAILED ("IMPROPER VALUE USED IN LESS THAN OR EQUAL");
          END IF;

          IF A.ALL <= IDENT_INT(9) THEN
               FAILED ("IMPROPER VALUE USED IN GREATER THAN OR EQUAL");
          END IF;

          IF NOT (A.ALL + A.ALL = IDENT_INT(20)) THEN
               FAILED ("IMPROPER VALUE FROM ADDITION");
          END IF;

          IF NOT (A.ALL - IDENT_INT(2) = IDENT_INT(8)) THEN
               FAILED ("IMPROPER VALUE FROM SUBTRACTION");
          END IF;

          IF NOT (A.ALL * IDENT_INT(3) = IDENT_INT(30)) THEN
               FAILED ("IMPROPER VALUE FROM MULTIPLICATION");
          END IF;

          IF NOT (A.ALL / IDENT_INT(3) = IDENT_INT(3)) THEN
               FAILED ("IMPROPER VALUE FROM DIVISION");
          END IF;

          IF NOT (A.ALL MOD IDENT_INT(3) = IDENT_INT(1)) THEN
               FAILED ("IMPROPER VALUE FROM MODULO");
          END IF;

          IF NOT (A.ALL REM IDENT_INT(7) = IDENT_INT(3)) THEN
               FAILED ("IMPROPER VALUE FROM REMAINDER");
          END IF;

          IF NOT (A.ALL ** IDENT_INT(2) = IDENT_INT(100)) THEN
               FAILED ("IMPROPER VALUE FROM EXPONENTIATION");
          END IF;

          IF NOT (+A.ALL = IDENT_INT(10)) THEN
               FAILED ("IMPROPER VALUE FROM IDENTITY");
          END IF;

          IF NOT (-A.ALL = IDENT_INT(-10)) THEN
               FAILED ("IMPROPER VALUE FROM NEGATION");
          END IF;

          A := NULL;

          IF A /= NULL THEN
               FAILED ("IMPROPER VALUE FROM ACCESS SET TO NULL");
          END IF;

          IF A'ADDRESS NOT IN ADDRESS THEN
               FAILED ("IMPROPER RESULT FROM A'ADDRESS TEST");
          END IF;


          DECLARE
               ACC_SIZE : INTEGER := ACC'SIZE;
          BEGIN
               IF ACC_SIZE NOT IN INTEGER THEN
                    FAILED ("IMPROPER RESULT FROM ACC'SIZE");
               END IF;
          END;

          R := NEW REC'(COMP => 5);

          IF NOT EQUAL(R.COMP,5) THEN
               FAILED ("IMPROPER VALUE FOR RECORD COMPONENT");
          END IF;

          DR := NEW DISCREC'(DISC => 1, COMPD => 5);

          IF NOT EQUAL(DR.DISC,1) OR NOT EQUAL(DR.COMPD,5) THEN
               FAILED ("IMPROPER VALUES FOR DISCRIMINATED RECORD " &
                       "COMPONENTS");
          END IF;

          C := NEW ARR'(1 => (1,2), 2 => (3,4));

          IF C(1,1) /= 1 OR C(1,2) /= 2 OR C(2,1) /= 3 OR C(2,2) /= 4
               THEN FAILED ("IMPROPER ARRAY COMPONENT VALUES");
          END IF;

          D := NEW ONEDIM'(1,2,3,4,5,6,7,8,9,10);
          E := NEW ONEDIM'(10,9,8,7,6,5,4,3,2,1);

          D(1..5) := E(1..5);

          IF D(1) /= 10 OR D(2) /= 9 OR D(3) /= 8
               OR D(4) /= 7 OR D(5) /= 6 THEN
               FAILED ("IMPROPER RESULTS FROM SLICE ASSIGNMENT");
          END IF;

          IF C'FIRST /= 1 OR C'FIRST(2) /= 1 THEN
               FAILED ("IMPROPER LOWER BOUNDS FOR CONSTRAINED ARRAY");
          END IF;

          IF C'LAST /= 2 OR C'LAST(2) /= 2 THEN
               FAILED ("IMPROPER UPPER BOUNDS FOR CONSTRAINED ARRAY");
          END IF;

          IF 1 NOT IN C'RANGE THEN
               FAILED ("IMPROPER RANGE FOR CONSTRAINED ARRAY - 1");
          END IF;

          IF 1 NOT IN C'RANGE(2) THEN
               FAILED ("IMPROPER RANGE FOR CONSTRAINED ARRAY - 2");
          END IF;

          IF C'LENGTH /= 2 THEN
               FAILED ("IMPROPER NUMBER OF VALUES FOR CONSTRAINED " &
                       "ARRAY - 1");
          END IF;

          IF C'LENGTH(2) /= 2 THEN
               FAILED ("IMPROPER NUMBER OF VALUES FOR CONSTRAINED " &
                       "ARRAY - 2");
          END IF;

          F := NEW T;

          F.HERE(INT);

          IF NOT EQUAL(INT,IDENT_INT(10)) THEN
               FAILED ("IMPROPER RESULTS FROM ENTRY SELECTION");
          END IF;

          G := NEW T1;

          G.HERE1(TWO)(INT);

          IF NOT EQUAL(INT,IDENT_INT(20)) THEN
               FAILED ("IMPROPER RESULTS FROM FAMILY ENTRY SELECTION");
          END IF;

          RESULT;
     END P;

     PACKAGE PACK IS NEW P(INTEGER,ACCINTEGER,AI,AREC,ADISCREC,
                           AA,AONEDIM,ATASK,ATASK1,ANOTHERTASK);

BEGIN
     NULL;
END CC1225A;