annotate gcc/testsuite/ada/acats/tests/cb/cb41004.a @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- CB41004.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that Raise_Exception and Reraise_Occurrence have no effect in
kono
parents:
diff changeset
28 -- the case of Null_Id or Null_Occurrence. Check that Exception_Message,
kono
parents:
diff changeset
29 -- Exception_Identity, Exception_Name, and Exception_Information raise
kono
parents:
diff changeset
30 -- Constraint_Error for a Null_Occurrence input parameter.
kono
parents:
diff changeset
31 -- Check that calling the Save_Occurrence subprograms with the
kono
parents:
diff changeset
32 -- Null_Occurrence input parameter saves the Null_Occurrence to the
kono
parents:
diff changeset
33 -- appropriate target object, and does not raise Constraint_Error.
kono
parents:
diff changeset
34 -- Check that Null_Id is the default initial value of type Exception_Id.
kono
parents:
diff changeset
35 --
kono
parents:
diff changeset
36 -- TEST DESCRIPTION:
kono
parents:
diff changeset
37 -- This test performs a series of calls to many of the subprograms
kono
parents:
diff changeset
38 -- defined in package Ada.Exceptions, using either Null_Id or
kono
parents:
diff changeset
39 -- Null_Occurrence (based on their parameter profile). In the cases of
kono
parents:
diff changeset
40 -- Raise_Exception and Reraise_Occurrence, these null input values
kono
parents:
diff changeset
41 -- should result in no exceptions being raised, and Constraint_Error
kono
parents:
diff changeset
42 -- should not be raised in response to these calls. Test failure will
kono
parents:
diff changeset
43 -- result if any exception is raised in these cases.
kono
parents:
diff changeset
44 -- For the Save_Occurrence subprograms, calling them with the
kono
parents:
diff changeset
45 -- Null_Occurrence input parameter does not raise Constraint_Error, but
kono
parents:
diff changeset
46 -- simply results in the Null_Occurrence being saved into the appropriate
kono
parents:
diff changeset
47 -- target (either a Exception_Occurrence out parameter, or as an
kono
parents:
diff changeset
48 -- Exception_Occurrence_Access value).
kono
parents:
diff changeset
49 -- In the cases of the other mentioned subprograms, calls performed with
kono
parents:
diff changeset
50 -- a Null_Occurrence input parameter must result in Constraint_Error
kono
parents:
diff changeset
51 -- being raised. This exception will be handled, with test failure the
kono
parents:
diff changeset
52 -- result if the exception is not raised.
kono
parents:
diff changeset
53 --
kono
parents:
diff changeset
54 --
kono
parents:
diff changeset
55 -- CHANGE HISTORY:
kono
parents:
diff changeset
56 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
57 -- 08 Dec 00 RLB Removed Exception_Identity subtest, pending
kono
parents:
diff changeset
58 -- resolution of AI95-00241.
kono
parents:
diff changeset
59 -- Notes for future: Replace Exception_Identity
kono
parents:
diff changeset
60 -- subtest with whatever the resolution is.
kono
parents:
diff changeset
61 -- Add a subtest for Exception_Name(Null_Id), which
kono
parents:
diff changeset
62 -- is missing from this test.
kono
parents:
diff changeset
63 --!
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 with Report;
kono
parents:
diff changeset
66 with Ada.Exceptions;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 procedure CB41004 is
kono
parents:
diff changeset
69 begin
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 Report.Test ("CB41004", "Check that Null_Id and Null_Occurrence input " &
kono
parents:
diff changeset
72 "parameters have the appropriate effect when " &
kono
parents:
diff changeset
73 "used in calls of the subprograms found in " &
kono
parents:
diff changeset
74 "package Ada.Exceptions");
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 Test_Block:
kono
parents:
diff changeset
77 declare
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 use Ada.Exceptions;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 -- No initial values given for these two declarations; they default
kono
parents:
diff changeset
82 -- to Null_Id and Null_Occurrence respectively.
kono
parents:
diff changeset
83 A_Null_Exception_Id : Ada.Exceptions.Exception_Id;
kono
parents:
diff changeset
84 A_Null_Exception_Occurrence : Ada.Exceptions.Exception_Occurrence;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 TC_Flag : Boolean := False;
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 begin
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 -- Verify that Null_Id is the default initial value of type
kono
parents:
diff changeset
91 -- Exception_Id.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 if not (A_Null_Exception_Id = Ada.Exceptions.Null_Id) then
kono
parents:
diff changeset
94 Report.Failed("The default initial value of an object of type " &
kono
parents:
diff changeset
95 "Exception_Id was not Null_Id");
kono
parents:
diff changeset
96 end if;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 -- Verify that Reraise_Occurrence has no effect in the case of
kono
parents:
diff changeset
100 -- Null_Occurrence.
kono
parents:
diff changeset
101 begin
kono
parents:
diff changeset
102 Ada.Exceptions.Reraise_Occurrence(A_Null_Exception_Occurrence);
kono
parents:
diff changeset
103 TC_Flag := True;
kono
parents:
diff changeset
104 exception
kono
parents:
diff changeset
105 when others =>
kono
parents:
diff changeset
106 Report.Failed
kono
parents:
diff changeset
107 ("Exception raised by procedure Reraise_Occurrence " &
kono
parents:
diff changeset
108 "when called with a Null_Occurrence input parameter");
kono
parents:
diff changeset
109 end;
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 if not TC_Flag then
kono
parents:
diff changeset
112 Report.Failed("Incorrect processing following the call to " &
kono
parents:
diff changeset
113 "Reraise_Occurrence with a Null_Occurrence " &
kono
parents:
diff changeset
114 "input parameter");
kono
parents:
diff changeset
115 end if;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 -- Verify that function Exception_Message raises Constraint_Error for
kono
parents:
diff changeset
119 -- a Null_Occurrence input parameter.
kono
parents:
diff changeset
120 begin
kono
parents:
diff changeset
121 declare
kono
parents:
diff changeset
122 Msg : constant String :=
kono
parents:
diff changeset
123 Ada.Exceptions.Exception_Message(A_Null_Exception_Occurrence);
kono
parents:
diff changeset
124 begin
kono
parents:
diff changeset
125 Report.Failed
kono
parents:
diff changeset
126 ("Constraint_Error not raised by Function Exception_Message " &
kono
parents:
diff changeset
127 "when called with a Null_Occurrence input parameter");
kono
parents:
diff changeset
128 end;
kono
parents:
diff changeset
129 exception
kono
parents:
diff changeset
130 when Constraint_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
131 when others =>
kono
parents:
diff changeset
132 Report.Failed
kono
parents:
diff changeset
133 ("Unexpected exception raised by Function Exception_Message " &
kono
parents:
diff changeset
134 "when called with a Null_Occurrence input parameter");
kono
parents:
diff changeset
135 end;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 -- -- Verify that function Exception_Identity raises Constraint_Error for
kono
parents:
diff changeset
139 -- -- a Null_Occurrence input parameter.
kono
parents:
diff changeset
140 -- -- Note: (RLB, 2000/12/08) This behavior may be modified by AI-00241.
kono
parents:
diff changeset
141 -- -- As such, this test case has been removed pending a resolution.
kono
parents:
diff changeset
142 -- begin
kono
parents:
diff changeset
143 -- declare
kono
parents:
diff changeset
144 -- Id : Ada.Exceptions.Exception_Id :=
kono
parents:
diff changeset
145 -- Ada.Exceptions.Exception_Identity(A_Null_Exception_Occurrence);
kono
parents:
diff changeset
146 -- begin
kono
parents:
diff changeset
147 -- Report.Failed
kono
parents:
diff changeset
148 -- ("Constraint_Error not raised by Function Exception_Identity " &
kono
parents:
diff changeset
149 -- "when called with a Null_Occurrence input parameter");
kono
parents:
diff changeset
150 -- end;
kono
parents:
diff changeset
151 -- exception
kono
parents:
diff changeset
152 -- when Constraint_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
153 -- when others =>
kono
parents:
diff changeset
154 -- Report.Failed
kono
parents:
diff changeset
155 -- ("Unexpected exception raised by Function Exception_Identity " &
kono
parents:
diff changeset
156 -- "when called with a Null_Occurrence input parameter");
kono
parents:
diff changeset
157 -- end;
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 -- Verify that function Exception_Name raises Constraint_Error for
kono
parents:
diff changeset
161 -- a Null_Occurrence input parameter.
kono
parents:
diff changeset
162 begin
kono
parents:
diff changeset
163 declare
kono
parents:
diff changeset
164 Name : constant String :=
kono
parents:
diff changeset
165 Ada.Exceptions.Exception_Name(A_Null_Exception_Occurrence);
kono
parents:
diff changeset
166 begin
kono
parents:
diff changeset
167 Report.Failed
kono
parents:
diff changeset
168 ("Constraint_Error not raised by Function Exception_Name " &
kono
parents:
diff changeset
169 "when called with a Null_Occurrence input parameter");
kono
parents:
diff changeset
170 end;
kono
parents:
diff changeset
171 exception
kono
parents:
diff changeset
172 when Constraint_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
173 when others =>
kono
parents:
diff changeset
174 Report.Failed
kono
parents:
diff changeset
175 ("Unexpected exception raised by Function Exception_Null " &
kono
parents:
diff changeset
176 "when called with a Null_Occurrence input parameter");
kono
parents:
diff changeset
177 end;
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 -- Verify that function Exception_Information raises Constraint_Error
kono
parents:
diff changeset
181 -- for a Null_Occurrence input parameter.
kono
parents:
diff changeset
182 begin
kono
parents:
diff changeset
183 declare
kono
parents:
diff changeset
184 Info : constant String :=
kono
parents:
diff changeset
185 Ada.Exceptions.Exception_Information
kono
parents:
diff changeset
186 (A_Null_Exception_Occurrence);
kono
parents:
diff changeset
187 begin
kono
parents:
diff changeset
188 Report.Failed
kono
parents:
diff changeset
189 ("Constraint_Error not raised by Function " &
kono
parents:
diff changeset
190 "Exception_Information when called with a " &
kono
parents:
diff changeset
191 "Null_Occurrence input parameter");
kono
parents:
diff changeset
192 end;
kono
parents:
diff changeset
193 exception
kono
parents:
diff changeset
194 when Constraint_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
195 when others =>
kono
parents:
diff changeset
196 Report.Failed
kono
parents:
diff changeset
197 ("Unexpected exception raised by Function Exception_Null " &
kono
parents:
diff changeset
198 "when called with a Null_Occurrence input parameter");
kono
parents:
diff changeset
199 end;
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 -- Verify that calling the Save_Occurrence procedure with a
kono
parents:
diff changeset
203 -- Null_Occurrence input parameter saves the Null_Occurrence to the
kono
parents:
diff changeset
204 -- target object, and does not raise Constraint_Error.
kono
parents:
diff changeset
205 declare
kono
parents:
diff changeset
206 use Ada.Exceptions;
kono
parents:
diff changeset
207 Saved_Occurrence : Exception_Occurrence;
kono
parents:
diff changeset
208 begin
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 -- Initialize the Saved_Occurrence variable with a value other than
kono
parents:
diff changeset
211 -- Null_Occurrence (default).
kono
parents:
diff changeset
212 begin
kono
parents:
diff changeset
213 raise Program_Error;
kono
parents:
diff changeset
214 exception
kono
parents:
diff changeset
215 when Exc : others => Save_Occurrence(Saved_Occurrence, Exc);
kono
parents:
diff changeset
216 end;
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 -- Save a Null_Occurrence input parameter.
kono
parents:
diff changeset
219 begin
kono
parents:
diff changeset
220 Save_Occurrence(Target => Saved_Occurrence,
kono
parents:
diff changeset
221 Source => Ada.Exceptions.Null_Occurrence);
kono
parents:
diff changeset
222 exception
kono
parents:
diff changeset
223 when others =>
kono
parents:
diff changeset
224 Report.Failed
kono
parents:
diff changeset
225 ("Unexpected exception raised by procedure " &
kono
parents:
diff changeset
226 "Save_Occurrence when called with a Null_Occurrence " &
kono
parents:
diff changeset
227 "input parameter");
kono
parents:
diff changeset
228 end;
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 -- Verify that the occurrence that was saved above is a
kono
parents:
diff changeset
231 -- Null_Occurrence value.
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 begin
kono
parents:
diff changeset
234 Reraise_Occurrence(Saved_Occurrence);
kono
parents:
diff changeset
235 exception
kono
parents:
diff changeset
236 when others =>
kono
parents:
diff changeset
237 Report.Failed("Value saved from Procedure Save_Occurrence " &
kono
parents:
diff changeset
238 "resulted in an exception, i.e., was not a " &
kono
parents:
diff changeset
239 "value of Null_Occurrence");
kono
parents:
diff changeset
240 end;
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 exception
kono
parents:
diff changeset
243 when others =>
kono
parents:
diff changeset
244 Report.Failed("Unexpected exception raised during evaluation " &
kono
parents:
diff changeset
245 "of Procedure Save_Occurrence");
kono
parents:
diff changeset
246 end;
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 -- Verify that calling the Save_Occurrence function with a
kono
parents:
diff changeset
250 -- Null_Occurrence input parameter returns the Null_Occurrence as the
kono
parents:
diff changeset
251 -- function result, and does not raise Constraint_Error.
kono
parents:
diff changeset
252 declare
kono
parents:
diff changeset
253 Occurrence_Ptr : Ada.Exceptions.Exception_Occurrence_Access;
kono
parents:
diff changeset
254 begin
kono
parents:
diff changeset
255 -- Save a Null_Occurrence input parameter.
kono
parents:
diff changeset
256 begin
kono
parents:
diff changeset
257 Occurrence_Ptr :=
kono
parents:
diff changeset
258 Ada.Exceptions.Save_Occurrence(Ada.Exceptions.Null_Occurrence);
kono
parents:
diff changeset
259 exception
kono
parents:
diff changeset
260 when others =>
kono
parents:
diff changeset
261 Report.Failed
kono
parents:
diff changeset
262 ("Unexpected exception raised by function " &
kono
parents:
diff changeset
263 "Save_Occurrence when called with a Null_Occurrence " &
kono
parents:
diff changeset
264 "input parameter");
kono
parents:
diff changeset
265 end;
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 -- Verify that the occurrence that was saved above is a
kono
parents:
diff changeset
268 -- Null_Occurrence value.
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 begin
kono
parents:
diff changeset
271 -- Dereferenced value of type Exception_Occurrence_Access
kono
parents:
diff changeset
272 -- should be a Null_Occurrence value, based on the action
kono
parents:
diff changeset
273 -- of Function Save_Occurrence above. Providing this as an
kono
parents:
diff changeset
274 -- input parameter to Reraise_Exception should not result in
kono
parents:
diff changeset
275 -- any exception being raised.
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 Ada.Exceptions.Reraise_Occurrence(Occurrence_Ptr.all);
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 exception
kono
parents:
diff changeset
280 when others =>
kono
parents:
diff changeset
281 Report.Failed("Value saved from Function Save_Occurrence " &
kono
parents:
diff changeset
282 "resulted in an exception, i.e., was not a " &
kono
parents:
diff changeset
283 "value of Null_Occurrence");
kono
parents:
diff changeset
284 end;
kono
parents:
diff changeset
285 exception
kono
parents:
diff changeset
286 when others =>
kono
parents:
diff changeset
287 Report.Failed("Unexpected exception raised during evaluation " &
kono
parents:
diff changeset
288 "of Function Save_Occurrence");
kono
parents:
diff changeset
289 end;
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 exception
kono
parents:
diff changeset
294 when others => Report.Failed ("Exception raised in Test_Block");
kono
parents:
diff changeset
295 end Test_Block;
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 Report.Result;
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 end CB41004;