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
|
-- C43004A.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 CONSTRAINT_ERROR IS RAISED IF A VALUE FOR A
-- NON-DISCRIMINANT SCALAR COMPONENT OF AN AGGREGATE IS NOT
-- WITHIN THE RANGE OF THE COMPONENT'S SUBTYPE.
-- HISTORY:
-- BCB 01/22/88 CREATED ORIGINAL TEST.
-- RJW 06/27/90 CORRECTED CONSTRAINTS OF TYPE DFIX.
-- LDC 09/25/90 ADDED A BLOCK IN THE EXCEPTION HANDLER SO IT CAN
-- NOT OPTIMIZE IT AWAY, ALSO INITIALIZED EACH
-- OBJECT TO VALID DATA BEFORE DOING THE INVALID,
-- MADE 'IDENT_XXX' FUNCTIONS SO THE COMPILER CAN
-- NOT JUST EVALUATE THE ASSIGNMENT AND PUT IN CODE
-- FOR A CONSTRAINT ERROR IN IS PLACE.
-- JRL 06/07/96 Changed value in aggregate in subtest 4 to value
-- guaranteed to be in the base range of the type FIX.
-- Corrected typo.
WITH REPORT; USE REPORT;
PROCEDURE C43004A IS
TYPE INT IS RANGE 1 .. 8;
SUBTYPE SINT IS INT RANGE 2 .. 7;
TYPE ENUM IS (VINCE, JOHN, TOM, PHIL, ROSA, JODIE, BRIAN, DAVE);
SUBTYPE SENUM IS ENUM RANGE JOHN .. BRIAN;
TYPE FL IS DIGITS 5 RANGE 0.0 .. 10.0;
SUBTYPE SFL IS FL RANGE 1.0 .. 9.0;
TYPE FIX IS DELTA 0.25 RANGE 0.0 .. 8.0;
SUBTYPE SFIX IS FIX RANGE 1.0 .. 7.0;
TYPE DINT IS NEW INTEGER RANGE 1 .. 8;
SUBTYPE SDINT IS DINT RANGE 2 .. 7;
TYPE DENUM IS NEW ENUM RANGE VINCE .. DAVE;
SUBTYPE SDENUM IS DENUM RANGE JOHN .. BRIAN;
TYPE DFL IS NEW FLOAT RANGE 0.0 .. 10.0;
SUBTYPE SDFL IS DFL RANGE 1.0 .. 9.0;
TYPE DFIX IS NEW FIX RANGE 0.5 .. 7.5;
SUBTYPE SDFIX IS DFIX RANGE 1.0 .. 7.0;
TYPE REC1 IS RECORD
E1, E2, E3, E4, E5 : SENUM;
END RECORD;
TYPE REC2 IS RECORD
E1, E2, E3, E4, E5 : SFIX;
END RECORD;
TYPE REC3 IS RECORD
E1, E2, E3, E4, E5 : SDENUM;
END RECORD;
TYPE REC4 IS RECORD
E1, E2, E3, E4, E5 : SDFIX;
END RECORD;
ARRAY_OBJ : ARRAY(1..2) OF INTEGER;
A : ARRAY(1..5) OF SINT;
B : REC1;
C : ARRAY(1..5) OF SFL;
D : REC2;
E : ARRAY(1..5) OF SDINT;
F : REC3;
G : ARRAY(1..5) OF SDFL;
H : REC4;
GENERIC
TYPE GENERAL_PURPOSE IS PRIVATE;
FUNCTION GENEQUAL(ONE, TWO : GENERAL_PURPOSE) RETURN BOOLEAN;
FUNCTION GENEQUAL(ONE, TWO : GENERAL_PURPOSE) RETURN BOOLEAN IS
BEGIN
IF EQUAL(3,3) THEN
RETURN ONE = TWO;
ELSE
RETURN ONE /= TWO;
END IF;
END GENEQUAL;
FUNCTION EQUAL IS NEW GENEQUAL(SENUM);
FUNCTION EQUAL IS NEW GENEQUAL(SFL);
FUNCTION EQUAL IS NEW GENEQUAL(SFIX);
FUNCTION EQUAL IS NEW GENEQUAL(SDENUM);
FUNCTION EQUAL IS NEW GENEQUAL(SDFL);
FUNCTION EQUAL IS NEW GENEQUAL(SDFIX);
GENERIC
TYPE GENERAL_PURPOSE IS PRIVATE;
WITH FUNCTION EQUAL_GENERAL(ONE, TWO : GENERAL_PURPOSE)
RETURN BOOLEAN;
FUNCTION GEN_IDENT (X : GENERAL_PURPOSE) RETURN GENERAL_PURPOSE;
FUNCTION GEN_IDENT (X : GENERAL_PURPOSE) RETURN GENERAL_PURPOSE IS
BEGIN
IF EQUAL_GENERAL (X, X) THEN -- ALWAYS EQUAL.
RETURN X; -- ALWAYS EXECUTED.
END IF;
-- NEVER EXECUTED.
RETURN X;
END GEN_IDENT;
FUNCTION IDENT_FL IS NEW GEN_IDENT(FL, EQUAL);
FUNCTION IDENT_FIX IS NEW GEN_IDENT(FIX, EQUAL);
FUNCTION IDENT_DFL IS NEW GEN_IDENT(DFL, EQUAL);
FUNCTION IDENT_DFIX IS NEW GEN_IDENT(DFIX, EQUAL);
BEGIN
TEST ("C43004A", "CHECK THAT CONSTRAINT_ERROR IS RAISED IF A " &
"VALUE FOR A NON-DISCRIMINANT SCALAR COMPONENT " &
"OF AN AGGREGATE IS NOT WITHIN THE RANGE OF " &
"THE COMPONENT'S SUBTYPE");
ARRAY_OBJ := (1, 2);
BEGIN
A := (2,3,4,5,6); -- OK
IF EQUAL (INTEGER (A(IDENT_INT(1))),
INTEGER (A(IDENT_INT(2)))) THEN
COMMENT ("DON'T OPTIMIZE A");
END IF;
A := (SINT(IDENT_INT(1)),2,3,4,7);
-- CONSTRAINT_ERROR BY AGGREGATE
-- WITH INTEGER COMPONENTS.
FAILED ("CONSTRAINT_ERROR WAS NOT RAISED - 1");
IF EQUAL (INTEGER (A(IDENT_INT(1))),
INTEGER (A(IDENT_INT(1)))) THEN
COMMENT ("DON'T OPTIMIZE A");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF EQUAL (ARRAY_OBJ(IDENT_INT(1)),
ARRAY_OBJ(IDENT_INT(2))) THEN
COMMENT ("DON'T OPTIMIZE EXCEPTION HANDLER");
END IF;
WHEN OTHERS =>
FAILED ("AN EXCEPTION OTHER THAN CONSTRAINT_ERROR " &
"WAS RAISED - 1");
END;
BEGIN
B := (JOHN,TOM,PHIL,ROSA,JOHN); -- OK
IF EQUAL (B.E1, B.E2) THEN
COMMENT ("DON'T OPTIMIZE B");
END IF;
B := (ENUM'VAL(IDENT_INT(ENUM'POS(DAVE))), TOM, PHIL,
ROSA, JODIE);
-- CONSTRAINT_ERROR BY AGGREGATE
-- WITH COMPONENTS OF AN
-- ENUMERATION TYPE.
FAILED ("CONSTRAINT_ERROR WAS NOT RAISED - 2");
IF NOT EQUAL (B.E1, B.E1) THEN
COMMENT ("DON'T OPTIMIZE B");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF EQUAL (ARRAY_OBJ(IDENT_INT(1)),
ARRAY_OBJ(IDENT_INT(2))) THEN
COMMENT ("DON'T OPTIMIZE EXCEPTION HANDLER");
END IF;
WHEN OTHERS =>
FAILED ("AN EXCEPTION OTHER THAN CONSTRAINT_ERROR " &
"WAS RAISED - 2");
END;
BEGIN
C := (2.0,3.0,4.0,5.0,6.0); -- OK
IF EQUAL (C(IDENT_INT(1)), C(IDENT_INT(2))) THEN
COMMENT ("DON'T OPTIMIZE C");
END IF;
C := (IDENT_FL(1.0),2.0,3.0,4.0,IDENT_FL(10.0));
-- CONSTRAINT_ERROR BY AGGREGATE
-- WITH FLOATING POINT COMPONENTS.
FAILED ("CONSTRAINT_ERROR WAS NOT RAISED - 3");
IF NOT EQUAL (C(IDENT_INT(1)), C(IDENT_INT(1))) THEN
COMMENT ("DON'T OPTIMIZE C");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF EQUAL (ARRAY_OBJ(IDENT_INT(1)),
ARRAY_OBJ(IDENT_INT(2))) THEN
COMMENT ("DON'T OPTIMIZE EXCEPTION HANDLER");
END IF;
WHEN OTHERS =>
FAILED ("AN EXCEPTION OTHER THAN CONSTRAINT_ERROR " &
"WAS RAISED - 3");
END;
BEGIN
D := (2.2,3.3,4.4,5.5,6.6); -- OK
IF EQUAL (D.E1, D.E5) THEN
COMMENT ("DON'T OPTIMIZE D");
END IF;
D := (IDENT_FIX(1.0),2.1,3.3,4.4,IDENT_FIX(7.75));
-- CONSTRAINT_ERROR BY AGGREGATE
-- WITH FIXED POINT COMPONENTS.
FAILED ("CONSTRAINT_ERROR WAS NOT RAISED - 4");
IF NOT EQUAL (D.E5, D.E5) THEN
COMMENT ("DON'T OPTIMIZE D");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF EQUAL (ARRAY_OBJ(IDENT_INT(1)),
ARRAY_OBJ(IDENT_INT(2))) THEN
COMMENT ("DON'T OPTIMIZE EXCEPTION HANDLER");
END IF;
WHEN OTHERS =>
FAILED ("AN EXCEPTION OTHER THAN CONSTRAINT_ERROR " &
"WAS RAISED - 4");
END;
BEGIN
E := (2,3,4,5,6); -- OK
IF EQUAL (INTEGER (E(IDENT_INT(1))),
INTEGER (E(IDENT_INT(2)))) THEN
COMMENT ("DON'T OPTIMIZE E");
END IF;
E := (SDINT(IDENT_INT(1)),2,3,4,7);
-- CONSTRAINT_ERROR BY AGGREGATE
-- WITH DERIVED INTEGER COMPONENTS.
FAILED ("CONSTRAINT_ERROR WAS NOT RAISED - 5");
IF NOT EQUAL (INTEGER (E(IDENT_INT(1))),
INTEGER (E(IDENT_INT(1)))) THEN
COMMENT ("DON'T OPTIMIZE E");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF EQUAL (ARRAY_OBJ(IDENT_INT(1)),
ARRAY_OBJ(IDENT_INT(2))) THEN
COMMENT ("DON'T OPTIMIZE EXCEPTION HANDLER");
END IF;
WHEN OTHERS =>
FAILED ("AN EXCEPTION OTHER THAN CONSTRAINT_ERROR " &
"WAS RAISED - 5");
END;
BEGIN
F := (JOHN,TOM,PHIL,ROSA,JOHN); -- OK
IF EQUAL (F.E1, F.E2) THEN
COMMENT ("DON'T OPTIMIZE F");
END IF;
F := (DENUM'VAL(IDENT_INT(DENUM'POS(VINCE))), TOM, PHIL,
ROSA, JODIE);
-- CONSTRAINT_ERROR BY AGGREGATE
-- WITH COMPONENTS OF A DERIVED
-- ENUMERATION TYPE.
FAILED ("CONSTRAINT_ERROR WAS NOT RAISED - 6");
IF NOT EQUAL (F.E1, F.E1) THEN
COMMENT ("DON'T OPTIMIZE F");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF EQUAL (ARRAY_OBJ(IDENT_INT(1)),
ARRAY_OBJ(IDENT_INT(2))) THEN
COMMENT ("DON'T OPTIMIZE EXCEPTION HANDLER");
END IF;
WHEN OTHERS =>
FAILED ("AN EXCEPTION OTHER THAN CONSTRAINT_ERROR " &
"WAS RAISED - 6");
END;
BEGIN
G := (2.0,3.0,4.0,5.0,6.0); -- OK
IF EQUAL (G(IDENT_INT(1)), G(IDENT_INT(2))) THEN
COMMENT ("DON'T OPTIMIZE G");
END IF;
G := (IDENT_DFL(1.0),2.0,3.0,4.0,IDENT_DFL(10.0));
-- CONSTRAINT_ERROR BY AGGREGATE
-- WITH DERIVED FLOATING POINT
-- COMPONENTS.
FAILED ("CONSTRAINT_ERROR WAS NOT RAISED - 7");
IF NOT EQUAL (G(IDENT_INT(1)), G(IDENT_INT(1))) THEN
COMMENT ("DON'T OPTIMIZE G");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF EQUAL (ARRAY_OBJ(IDENT_INT(1)),
ARRAY_OBJ(IDENT_INT(2))) THEN
COMMENT ("DON'T OPTIMIZE EXCEPTION HANDLER");
END IF;
WHEN OTHERS =>
FAILED ("AN EXCEPTION OTHER THAN CONSTRAINT_ERROR " &
"WAS RAISED - 7");
END;
BEGIN
H := (2.2,3.3,4.4,5.5,6.6); -- OK
IF EQUAL (H.E1, H.E2) THEN
COMMENT ("DON'T OPTIMIZE H");
END IF;
H := (IDENT_DFIX(2.0),2.5,3.5,4.3,IDENT_DFIX(7.4));
-- CONSTRAINT_ERROR BY AGGREGATE
-- WITH DERIVED FIXED POINT
-- COMPONENTS.
FAILED ("CONSTRAINT_ERROR WAS NOT RAISED - 8");
IF EQUAL (H.E1, H.E5) THEN
COMMENT ("DON'T OPTIMIZE H");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF EQUAL (ARRAY_OBJ(IDENT_INT(1)),
ARRAY_OBJ(IDENT_INT(2))) THEN
COMMENT ("DON'T OPTIMIZE EXCEPTION HANDLER");
END IF;
WHEN OTHERS =>
FAILED ("AN EXCEPTION OTHER THAN CONSTRAINT_ERROR " &
"WAS RAISED - 8");
END;
RESULT;
END C43004A;
|