summaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats/tests/c6/c64103b.ada
blob: 3af6c6191d799bc791d134b227a5bb4f496170f5 (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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
-- C64103B.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, FOR IN-OUT PARAMETERS OF A SCALAR TYPE,
--     CONSTRAINT_ERROR IS RAISED:
--          BEFORE A SUBPROGRAM CALL WHEN THE CONVERTED ACTUAL
--          PARAMETER IS OUTSIDE THE RANGE OF THE FORMAL PARAMETER'S
--          SUBTYPE;
--          AFTER A SUBPROGRAM CALL WHEN THE CONVERTED FORMAL PARAMETER
--          IS OUTSIDE THE RANGE OF THE ACTUAL PARAMETER'S SUBTYPE.

-- HISTORY:
--     CPP  07/18/84  CREATED ORIGINAL TEST.
--     VCL  10/27/87  MODIFIED THIS HEADER; ADDED STATEMENTS WHICH
--                    REFERENCED THE ACTUAL PARAMETERS IN THE SECOND
--                    SUBTEST.

WITH REPORT;  USE REPORT;
PROCEDURE C64103B IS
BEGIN
     TEST ("C64103B", "FOR IN-OUT PARAMETERS OF A SCALAR TYPE, " &
                      "CONSTRAINT_ERROR IS RAISED:  BEFORE A " &
                      "SUBPROGRAM CALL WHEN THE CONVERTED ACTUAL " &
                      "PARAMETER IS OUTSIDE THE RANGE OF THE FORMAL " &
                      "PARAMETER'S SUBTYPE;  AFTER A SUBPROGRAM " &
                      "CALL WHEN THE CONVERTED FORMAL PARAMETER IS " &
                      "OUTSIDE THE RANGE OF THE ACTUAL PARAMETER'S " &
                      "SUBTYPE");


     DECLARE
          A0 : INTEGER := -9;
          A1 : INTEGER := IDENT_INT(-1);
          TYPE SUBINT IS RANGE -8 .. -2;

          TYPE FLOAT_TYPE IS DIGITS 3 RANGE 0.0 .. 3.0;
          A2 : FLOAT_TYPE := 0.12;
          A3 : FLOAT_TYPE := 2.5;
          TYPE NEW_FLOAT IS DIGITS 3 RANGE 1.0 .. 2.0;

          TYPE FIXED_TYPE IS DELTA 1.0 RANGE -2.0 .. 5.0;
          A4 : FIXED_TYPE := -2.0;
          A5 : FIXED_TYPE := 4.0;
          TYPE NEW_FIXED IS DELTA 1.0 RANGE -1.0 .. 3.0;

          A6 : CHARACTER := 'A';
          SUBTYPE SUPER_CHAR IS CHARACTER RANGE 'B'..'Q';

          TYPE COLOR IS (RED, BURGUNDY, LILAC, MAROON, MAGENTA);
          SUBTYPE A_COLOR IS COLOR RANGE RED..LILAC;
          SUBTYPE B_COLOR IS COLOR RANGE MAROON..MAGENTA;
          A7 : B_COLOR := MAROON;

          PROCEDURE P1 (X : IN OUT SUBINT;
                        S :        STRING) IS
          BEGIN
               FAILED ("EXCEPTION NOT RAISED BEFORE CALL -P1 (A" &
                       S & ")");
          END P1;

          PROCEDURE P2 (X : IN OUT NEW_FLOAT;
                        S :        STRING)     IS
          BEGIN
               FAILED ("EXCEPTION NOT RAISED BEFORE CALL -P2 (A" &
                       S & ")");
          END P2;

          PROCEDURE P3 (X : IN OUT NEW_FIXED;
                        S :        STRING)     IS
          BEGIN
               FAILED ("EXCEPTION NOT RAISED BEFORE CALL -P3 (A" &
                       S & ")");
          END P3;

          PROCEDURE P4 (X : IN OUT SUPER_CHAR;
                        S :        STRING)     IS
          BEGIN
               FAILED ("EXCEPTION NOT RAISED BEFORE CALL -P4 (A" &
                        S & ")");
          END P4;

          PROCEDURE P5 (X : IN OUT A_COLOR;
                        S :        STRING) IS
          BEGIN
               FAILED ("EXCEPTION NOT RAISED BEFORE CALL -P5 (A" &
                       S & ")");
          END P5;
     BEGIN
          BEGIN
               P1 (SUBINT (A0), "1");
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    NULL;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P1 (A1)");
          END;

          BEGIN
               P1 (SUBINT (A1), "2");
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    NULL;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P1 (A2)");
          END;

          BEGIN
               P2 (NEW_FLOAT (A2), "1");
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    NULL;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P2 (A1)");
          END;

          BEGIN
               P2 (NEW_FLOAT (A3), "2");
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    NULL;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P2 (A2)");
          END;

          BEGIN
               P3 (NEW_FIXED (A4), "1");
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    NULL;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P3 (A1)");
          END;

          BEGIN
               P3 (NEW_FIXED (A5), "2");
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    NULL;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P3 (A2)");
          END;

          BEGIN
               P4 (SUPER_CHAR (A6),"1");
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    NULL;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P4 (A1)");
          END;

          BEGIN
               P5 (A_COLOR (A7), "1");
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    NULL;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P5 (A1)");
          END;
     END;


     DECLARE
          CALLED : BOOLEAN;
          TYPE SUBINT IS RANGE -8 .. -2;
          A0 : SUBINT := -3;
          A1 : INTEGER := -9;
          A2 : INTEGER := -1;

          TYPE FLOAT IS DIGITS 3 RANGE -1.0 .. 2.0;
          TYPE A_FLOAT IS DIGITS 3 RANGE 0.0 .. 1.0;
          A3 : A_FLOAT := 1.0;
          A4 : FLOAT := -0.5;
          A5 : FLOAT := 1.5;

          TYPE NEW_FIXED IS DELTA 1.0 RANGE -1.0 .. 3.0;
          A6 : NEW_FIXED := 0.0;
          TYPE FIXED_TYPE IS DELTA 1.0 RANGE -2.0 .. 5.0;
          A7 : FIXED_TYPE := -2.0;
          A8 : FIXED_TYPE := 4.0;

          SUBTYPE SUPER_CHAR IS CHARACTER RANGE 'B'..'Q';
          A9  : SUPER_CHAR := 'C';
          A10 : CHARACTER := 'A';
          A11 : CHARACTER := 'R';

          PROCEDURE P1 (X : IN OUT INTEGER; Y : INTEGER) IS
          BEGIN
               CALLED := TRUE;
               X := IDENT_INT (Y);
          END P1;

          PROCEDURE P2 (X : IN OUT FLOAT; Y : FLOAT) IS
          BEGIN
               CALLED := TRUE;
               X := Y;
          END P2;

          PROCEDURE P3 ( X : IN OUT FIXED_TYPE; Y : FIXED_TYPE) IS
          BEGIN
               CALLED := TRUE;
               X := Y;
          END P3;

          PROCEDURE P4 (X : IN OUT CHARACTER; Y : CHARACTER) IS
          BEGIN
               CALLED := TRUE;
               X := IDENT_CHAR(Y);
          END P4;
     BEGIN
          BEGIN
               CALLED := FALSE;
               P1 (INTEGER(A0), A1);
               IF A0 = -3 THEN
                    FAILED ("EXCEPTION NOT RAISED AFTER CALL -P1 (B1)");
               ELSE
                    FAILED ("EXCEPTION NOT RAISED AFTER CALL -P1 (B2)");
               END IF;
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    IF NOT CALLED THEN
                         FAILED ("EXCEPTION RAISED BEFORE CALL " &
                                 "-P1 (B1)");
                    END IF;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P1 (B1)");
          END;

          BEGIN
               CALLED := FALSE;
               P1 (INTEGER(A0), A2);
               IF A0 = -3 THEN
                    FAILED ("EXCEPTION NOT RAISED AFTER CALL -P1 (B3)");
               ELSE
                    FAILED ("EXCEPTION NOT RAISED AFTER CALL -P1 (B4)");
               END IF;
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    IF NOT CALLED THEN
                         FAILED ("EXCEPTION RAISED BEFORE CALL " &
                                 "-P1 (B2)");
                    END IF;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P1 (B2)");
          END;

          BEGIN
               CALLED := FALSE;
               P2 (FLOAT (A3), A4);
               IF A3 = 1.0 THEN
                    FAILED ("EXCEPTION NOT RAISED AFTER CALL -P2 (B1)");
               ELSE
                    FAILED ("EXCEPTION NOT RAISED AFTER CALL -P2 (B2)");
               END IF;
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    IF NOT CALLED THEN
                         FAILED ("EXCEPTION RAISED BEFORE CALL " &
                                 "-P2 (B1)");
                    END IF;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P2 (B1)");
          END;

          BEGIN
               CALLED := FALSE;
               P2 (FLOAT (A3), A5);
               IF A3 = 1.0 THEN
                    FAILED ("EXCEPTION NOT RAISED -P2 (B3)");
               ELSE
                    FAILED ("EXCEPTION NOT RAISED -P2 (B4)");
               END IF;
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    IF NOT CALLED THEN
                         FAILED ("EXCEPTION RAISED BEFORE CALL " &
                                 "-P2 (B2)");
                    END IF;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P2 (B2)");
          END;

          BEGIN
               CALLED := FALSE;
               P3 (FIXED_TYPE (A6), A7);
               IF A6 = 0.0 THEN
                    FAILED ("EXCEPTION NOT RAISED -P3 (B1)");
               ELSE
                    FAILED ("EXCEPTION NOT RAISED -P3 (B2)");
               END IF;
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    IF NOT CALLED THEN
                         FAILED ("EXCEPTION RAISED BEFORE CALL " &
                                 "-P3 (B1)");
                    END IF;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P3 (B1)");
          END;

          BEGIN
               CALLED := FALSE;
               P3 (FIXED_TYPE (A6), A8);
               IF A6 = 0.0 THEN
                    FAILED ("EXCEPTION NOT RAISED -P3 (B3)");
               ELSE
                    FAILED ("EXCEPTION NOT RAISED -P3 (B4)");
               END IF;
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    IF NOT CALLED THEN
                         FAILED ("EXCEPTION RAISED BEFORE CALL " &
                                 "-P3 (B2)");
                    END IF;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P3 (B2)");
          END;

          BEGIN
               CALLED := FALSE;
               P4 (CHARACTER (A9), A10);
               IF A9 = 'C' THEN
                    FAILED ("EXCEPTION NOT RAISED AFTER CALL -P4 (B1)");
               ELSE
                    FAILED ("EXCEPTION NOT RAISED AFTER CALL -P4 (B2)");
               END IF;
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    IF NOT CALLED THEN
                         FAILED ("EXCEPTION RAISED BEFORE CALL " &
                                 "-P4 (B1)");
                    END IF;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P4 (B1)");
          END;

          BEGIN
               CALLED := FALSE;
               P4 (CHARACTER (A9), A11);
               IF A9 = 'C' THEN
                    FAILED ("EXCEPTION NOT RAISED AFTER CALL -P4 (B3)");
               ELSE
                    FAILED ("EXCEPTION NOT RAISED AFTER CALL -P4 (B4)");
               END IF;
          EXCEPTION
               WHEN CONSTRAINT_ERROR =>
                    IF NOT CALLED THEN
                         FAILED ("EXCEPTION RAISED BEFORE CALL " &
                                 "-P4 (B2)");
                    END IF;
               WHEN OTHERS =>
                    FAILED ("WRONG EXCEPTION RAISED -P4 (B2)");
          END;
     END;

     RESULT;
END C64103B;