Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / ada / acats / tests / c9 / c94002f.ada
blob47f0b4df216c35458f479236bc077811dbc163f4
1 -- C94002F.ADA
3 -- Grant of Unlimited Rights
4 --
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
14 -- to do so.
16 -- DISCLAIMER
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
24 --*
25 -- CHECK THAT A NON-MASTER UNIT, WHICH ALLOCATES TASKS OF A GLOBAL
26 -- ACCESS TYPE, MUST TERMINATE WITHOUT WAITING FOR THE ALLOCATED TASKS
27 -- TO TERMINATE IF AN EXCEPTION IS RAISED AND HANDLED IN THE
28 -- NON-MASTER UNIT.
30 -- SUBTESTS ARE:
31 -- (A) A SIMPLE TASK ALLOCATOR, IN A BLOCK.
32 -- (B) A RECORD OF TASK ALLOCATOR, IN A SUBPROGRAM.
33 -- (C) A RECORD OF ARRAY OF TASK ALLOCATOR, IN A TASK BODY.
35 -- TBN 1/20/86
36 -- JRK 5/1/86 IMPROVED ERROR RECOVERY. FIXED EXCEPTION HANDLING.
37 -- PWN 09/11/94 REMOVED PRAGMA PRIORITY FOR ADA 9X.
39 with Impdef;
40 WITH REPORT; USE REPORT;
41 WITH SYSTEM; USE SYSTEM;
42 PROCEDURE C94002F IS
44 MY_EXCEPTION : EXCEPTION;
46 TASK TYPE TT IS
47 ENTRY E;
48 END TT;
50 TASK BODY TT IS
51 BEGIN
52 ACCEPT E;
53 ACCEPT E;
54 END TT;
57 BEGIN
58 TEST ("C94002F", "CHECK THAT A NON-MASTER UNIT, WHICH ALLOCATES " &
59 "TASKS OF A GLOBAL ACCESS TYPE, MUST TERMINATE " &
60 "WITHOUT WAITING FOR THE ALLOCATED TASKS TO " &
61 "TERMINATE IF AN EXCEPTION IS RAISED AND " &
62 "HANDLED IN THE NON-MASTER UNIT");
64 --------------------------------------------------
66 DECLARE -- (A)
68 TYPE A_T IS ACCESS TT;
69 A1 : A_T;
71 BEGIN -- (A)
73 DECLARE
74 A2 : A_T;
75 BEGIN
76 A2 := NEW TT;
77 A2.ALL.E;
78 A1 := A2;
79 RAISE MY_EXCEPTION;
80 FAILED ("MY_EXCEPTION WAS NOT RAISED IN (A)");
81 EXCEPTION
82 WHEN MY_EXCEPTION =>
83 NULL;
84 WHEN OTHERS =>
85 FAILED ("UNEXPECTED EXCEPTION IN (A)");
86 END;
88 IF A1.ALL'TERMINATED THEN
89 FAILED ("ALLOCATED TASK PREMATURELY TERMINATED - (A)");
90 ELSE A1.ALL.E;
91 END IF;
93 END; -- (A)
95 --------------------------------------------------
97 DECLARE -- (B)
99 I : INTEGER;
101 FUNCTION F RETURN INTEGER IS
103 TYPE RT IS
104 RECORD
105 T : TT;
106 END RECORD;
107 TYPE ART IS ACCESS RT;
108 AR1 : ART;
110 PROCEDURE P (AR : OUT ART) IS
111 AR2 : ART;
112 BEGIN
113 AR2 := NEW RT;
114 AR2.T.E;
115 AR := AR2;
116 RAISE MY_EXCEPTION;
117 FAILED ("MY_EXCEPTION WAS NOT RAISED IN (B)");
118 EXCEPTION
119 WHEN MY_EXCEPTION =>
120 NULL;
121 WHEN OTHERS =>
122 FAILED ("UNEXPECTED EXCEPTION IN (B)");
123 END P;
125 BEGIN
126 P (AR1);
128 IF AR1.T'TERMINATED THEN
129 FAILED ("ALLOCATED TASK PREMATURELY TERMINATED " &
130 "- (B)");
131 ELSE AR1.T.E;
132 END IF;
134 RETURN 0;
135 END F;
137 BEGIN -- (B)
139 I := F;
141 END; -- (B)
143 --------------------------------------------------
145 DECLARE -- (C)
147 LOOP_COUNT : INTEGER := 0;
148 CUT_OFF : CONSTANT := 60; -- DELAY.
150 TASK TSK IS
151 ENTRY ENT;
152 END TSK;
154 TASK BODY TSK IS
156 LOOP_COUNT1 : INTEGER := 0;
157 CUT_OFF1 : CONSTANT := 60; -- DELAY.
159 TYPE RAT;
160 TYPE ARAT IS ACCESS RAT;
161 TYPE ARR IS ARRAY (1..1) OF TT;
162 TYPE RAT IS
163 RECORD
164 A : ARAT;
165 T : ARR;
166 END RECORD;
167 ARA1 : ARAT;
169 TASK TSK1 IS
170 ENTRY ENT1 (ARA : OUT ARAT);
171 END TSK1;
173 TASK BODY TSK1 IS
174 ARA2 : ARAT;
175 BEGIN
176 ARA2 := NEW RAT; -- INITIATE TASK ARA2.T(1).
177 ARA2.T(1).E;
178 ACCEPT ENT1 (ARA : OUT ARAT) DO
179 ARA := ARA2;
180 END ENT1;
181 RAISE MY_EXCEPTION;
182 FAILED ("MY_EXCEPTION WAS NOT RAISED IN (C)");
183 EXCEPTION
184 WHEN MY_EXCEPTION =>
185 NULL;
186 WHEN OTHERS =>
187 FAILED ("UNEXPECTED EXCEPTION IN (C)");
188 END TSK1;
190 BEGIN
191 TSK1.ENT1 (ARA1); -- ARA1.T BECOMES ALIAS FOR ARA2.T.
193 WHILE NOT TSK1'TERMINATED AND LOOP_COUNT1 < CUT_OFF1 LOOP
194 DELAY 1.0 * Impdef.One_Second;
195 LOOP_COUNT1 := LOOP_COUNT1 + 1;
196 END LOOP;
198 IF LOOP_COUNT1 >= CUT_OFF1 THEN
199 FAILED ("DEPENDENT TASK TSK1 NOT TERMINATED " &
200 "WITHIN ONE MINUTE - (C)");
201 END IF;
203 IF ARA1.T(1)'TERMINATED THEN
204 FAILED ("ALLOCATED TASK PREMATURELY TERMINATED " &
205 "- (C)");
206 ELSE ARA1.T(1).E;
207 END IF;
208 END TSK;
210 BEGIN -- (C)
212 WHILE NOT TSK'TERMINATED AND LOOP_COUNT < CUT_OFF LOOP
213 DELAY 2.0 * Impdef.One_Second;
214 LOOP_COUNT := LOOP_COUNT + 1;
215 END LOOP;
217 IF LOOP_COUNT >= CUT_OFF THEN
218 FAILED ("DEPENDENT TASK TSK NOT TERMINATED WITHIN " &
219 "TWO MINUTES - (C)");
220 END IF;
222 END; -- (C)
224 ---------------------------------------------------------------
226 RESULT;
227 END C94002F;