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
|
-- CC3017C.ADA
-- 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 AN INSTANCE OF A GENERIC PROCEDURE MUST DECLARE A
-- PROCEDURE AND THAT AN INSTANCE OF A GENERIC FUNCTION MUST
-- DECLARE A FUNCTION. CHECK THAT SCALAR AND ACCESS PARAMETERS
-- ARE COPIED.
--
-- SUBTESTS ARE:
-- (A) SCALAR PARAMETERS TO PROCEDURES.
-- (B) SCALAR PARAMETERS TO FUNCTIONS.
-- (C) ACCESS PARAMETERS TO PROCEDURES.
-- (D) ACCESS PARAMETERS TO FUNCTIONS.
-- HISTORY:
-- EDWARD V. BERARD, 7 AUGUST 1990
-- CJJ 10/16/90 ADJUSTED LINES THAT WERE TOO LONG; REFORMATTED
-- HEADER TO CONFORM TO ACVC STANDARDS.
--
WITH REPORT;
PROCEDURE CC3017C IS
BEGIN
REPORT.TEST ("CC3017C", "CHECK THAT AN INSTANCE OF A GENERIC " &
"PROCEDURE MUST DECLARE A PROCEDURE AND THAT AN " &
"INSTANCE OF A GENERIC FUNCTION MUST DECLARE A " &
"FUNCTION. CHECK THAT SCALAR AND ACCESS PARAMETERS " &
"ARE COPIED");
--------------------------------------------------
SCALAR_TO_PROCS:
DECLARE
-- (A) SCALAR PARAMETERS TO PROCEDURES.
TYPE NUMBER IS RANGE 0 .. 120 ;
VALUE : NUMBER ;
E : EXCEPTION ;
GENERIC
TYPE SCALAR_ITEM IS RANGE <> ;
PROCEDURE P (P_IN : IN SCALAR_ITEM ;
P_OUT : OUT SCALAR_ITEM ;
P_IN_OUT : IN OUT SCALAR_ITEM) ;
PROCEDURE P (P_IN : IN SCALAR_ITEM ;
P_OUT : OUT SCALAR_ITEM ;
P_IN_OUT : IN OUT SCALAR_ITEM) IS
STORE : SCALAR_ITEM ;
BEGIN -- P
STORE := P_IN; -- SAVE VALUE OF P_IN AT PROC ENTRY.
P_OUT := 10;
IF (P_IN /= STORE) THEN
REPORT.FAILED ("ASSIGNMENT TO SCALAR OUT " &
"PARAMETER CHANGES THE VALUE OF " &
"INPUT PARAMETER");
STORE := P_IN; -- RESET STORE FOR NEXT CASE.
END IF;
P_IN_OUT := P_IN_OUT + 100;
IF (P_IN /= STORE) THEN
REPORT.FAILED ("ASSIGNMENT TO SCALAR IN OUT " &
"PARAMETER CHANGES THE VALUE OF " &
"INPUT PARAMETER");
STORE := P_IN; -- RESET STORE FOR NEXT CASE.
END IF;
VALUE := VALUE + 1;
IF (P_IN /= STORE) THEN
REPORT.FAILED ("ASSIGNMENT TO SCALAR GLOBAL " &
"PARAMETER CHANGES THE VALUE OF " &
"INPUT PARAMETER");
END IF;
RAISE E; -- CHECK EXCEPTION HANDLING.
END P;
PROCEDURE NEW_P IS NEW P (SCALAR_ITEM => NUMBER) ;
BEGIN -- SCALAR_TO_PROCS
VALUE := 0; -- INITIALIZE VALUE SO VARIOUS CASES CAN BE DETECTED.
NEW_P (P_IN => VALUE,
P_OUT => VALUE,
P_IN_OUT => VALUE);
REPORT.FAILED ("EXCEPTION NOT RAISED - SCALARS TO PROCEDURES");
EXCEPTION
WHEN E =>
IF (VALUE /= 1) THEN
CASE VALUE IS
WHEN 11 =>
REPORT.FAILED ("OUT ACTUAL SCALAR " &
"PARAMETER CHANGED GLOBAL VALUE");
WHEN 101 =>
REPORT.FAILED ("IN OUT ACTUAL SCALAR " &
"PARAMETER CHANGED GLOBAL VALUE");
WHEN 111 =>
REPORT.FAILED ("OUT AND IN OUT ACTUAL " &
"SCALAR PARAMETERS CHANGED " &
"GLOBAL VALUE");
WHEN OTHERS =>
REPORT.FAILED ("UNDETERMINED CHANGE TO " &
"GLOBAL VALUE");
END CASE;
END IF;
WHEN OTHERS =>
REPORT.FAILED ("WRONG EXCEPTION RAISED - SCALARS TO PROCEDURES");
END SCALAR_TO_PROCS ;
--------------------------------------------------
SCALAR_TO_FUNCS:
DECLARE
-- (B) SCALAR PARAMETERS TO FUNCTIONS.
TYPE NUMBER IS RANGE 0 .. 101 ;
FIRST : NUMBER ;
SECOND : NUMBER ;
GENERIC
TYPE ITEM IS RANGE <> ;
FUNCTION F (F_IN : IN ITEM) RETURN ITEM ;
FUNCTION F (F_IN : IN ITEM) RETURN ITEM IS
STORE : ITEM := F_IN;
BEGIN -- F
FIRST := FIRST + 1;
IF (F_IN /= STORE) THEN
REPORT.FAILED ("ASSIGNMENT TO SCALAR GLOBAL FUNCTION " &
"PARAMETER CHANGES THE VALUE OF " &
"INPUT PARAMETER");
END IF;
RETURN (100);
END F;
FUNCTION NEW_F IS NEW F (ITEM => NUMBER) ;
BEGIN -- SCALAR_TO_FUNCS
FIRST := 100 ;
SECOND := NEW_F (FIRST) ;
END SCALAR_TO_FUNCS ;
--------------------------------------------------
ACCESS_TO_PROCS:
DECLARE
-- (C) ACCESS PARAMETERS TO PROCEDURES.
TYPE MONTH_TYPE IS (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG,
SEP, OCT, NOV, DEC) ;
TYPE DAY_TYPE IS RANGE 1 .. 31 ;
TYPE YEAR_TYPE IS RANGE 1904 .. 2050 ;
TYPE DATE IS RECORD
MONTH : MONTH_TYPE ;
DAY : DAY_TYPE ;
YEAR : YEAR_TYPE ;
END RECORD ;
TYPE DATE_ACCESS IS ACCESS DATE ;
DATE_POINTER : DATE_ACCESS ;
E : EXCEPTION;
GENERIC
TYPE ITEM IS PRIVATE ;
TYPE ACCESS_ITEM IS ACCESS ITEM ;
PROCEDURE P (P_IN : IN ACCESS_ITEM ;
P_OUT : OUT ACCESS_ITEM ;
P_IN_OUT : IN OUT ACCESS_ITEM) ;
PROCEDURE P (P_IN : IN ACCESS_ITEM ;
P_OUT : OUT ACCESS_ITEM ;
P_IN_OUT : IN OUT ACCESS_ITEM) IS
STORE : ACCESS_ITEM ;
BEGIN -- P
STORE := P_IN ; -- SAVE VALUE OF P_IN AT PROC ENTRY.
DATE_POINTER := NEW DATE'(YEAR => 1990,
DAY => 7,
MONTH => AUG) ;
IF (P_IN /= STORE) THEN
REPORT.FAILED ("ASSIGNMENT TO ACCESS GLOBAL " &
"PARAMETER CHANGES THE VALUE OF " &
"INPUT PARAMETER");
STORE := P_IN; -- RESET STORE FOR NEXT CASE.
END IF;
P_OUT := NEW ITEM ;
IF (P_IN /= STORE) THEN
REPORT.FAILED ("ASSIGNMENT TO ACCESS OUT " &
"PARAMETER CHANGES THE VALUE OF " &
"INPUT PARAMETER");
STORE := P_IN; -- RESET STORE FOR NEXT CASE.
END IF;
P_IN_OUT := NEW ITEM ;
IF (P_IN /= STORE) THEN
REPORT.FAILED ("ASSIGNMENT TO ACCESS IN OUT " &
"PARAMETER CHANGES THE VALUE OF " &
"INPUT PARAMETER");
END IF;
RAISE E; -- CHECK EXCEPTION HANDLING.
END P ;
PROCEDURE NEW_P IS NEW P (ITEM => DATE,
ACCESS_ITEM => DATE_ACCESS) ;
BEGIN -- ACCESS_TO_PROCS
DATE_POINTER := NEW DATE'(MONTH => DEC,
DAY => 25,
YEAR => 2000) ;
NEW_P (P_IN => DATE_POINTER,
P_OUT => DATE_POINTER,
P_IN_OUT => DATE_POINTER) ;
REPORT.FAILED ("EXCEPTION NOT RAISED - ACCESS TO PROCEDURES");
EXCEPTION
WHEN E =>
IF (DATE_POINTER.ALL /= (AUG, 7, 1990)) THEN
REPORT.FAILED ("OUT OR IN OUT ACTUAL PROCEDURE " &
"PARAMETER VALUE CHANGED DESPITE " &
"RAISED EXCEPTION");
END IF;
WHEN OTHERS =>
REPORT.FAILED ("WRONG EXCEPTION RAISED - ACCESS TO PROCEDURES");
END ACCESS_TO_PROCS ;
--------------------------------------------------
ACCESS_TO_FUNCS:
DECLARE
-- (D) ACCESS PARAMETERS TO FUNCTIONS.
TYPE MONTH_TYPE IS (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG,
SEP, OCT, NOV, DEC) ;
TYPE DAY_TYPE IS RANGE 1 .. 31 ;
TYPE YEAR_TYPE IS RANGE 1904 .. 2050 ;
TYPE DATE IS RECORD
MONTH : MONTH_TYPE ;
DAY : DAY_TYPE ;
YEAR : YEAR_TYPE ;
END RECORD ;
TYPE DATE_ACCESS IS ACCESS DATE ;
DATE_POINTER : DATE_ACCESS ;
NEXT_DATE : DATE_ACCESS ;
GENERIC
TYPE ITEM IS PRIVATE ;
TYPE ACCESS_ITEM IS ACCESS ITEM ;
FUNCTION F (F_IN : IN ACCESS_ITEM) RETURN ACCESS_ITEM ;
FUNCTION F (F_IN : IN ACCESS_ITEM) RETURN ACCESS_ITEM IS
STORE : ACCESS_ITEM := F_IN ;
BEGIN -- F
DATE_POINTER := NEW DATE'(YEAR => 1990,
DAY => 7,
MONTH => AUG) ;
IF (F_IN /= STORE) THEN
REPORT.FAILED ("ASSIGNMENT TO ACCESS GLOBAL FUNCTION " &
"PARAMETER CHANGES THE VALUE OF " &
"INPUT PARAMETER");
END IF;
RETURN (NULL);
END F ;
FUNCTION NEW_F IS NEW F (ITEM => DATE,
ACCESS_ITEM => DATE_ACCESS) ;
BEGIN -- ACCESS_TO_FUNCS
DATE_POINTER := NULL ;
NEXT_DATE := NEW_F(F_IN => DATE_POINTER) ;
END ACCESS_TO_FUNCS ;
--------------------------------------------------
REPORT.RESULT;
END CC3017C;
|