annotate gcc/testsuite/ada/acats/tests/c3/c371002.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- C371002.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 if a discriminant constraint depends on a discriminant,
kono
parents:
diff changeset
28 -- the evaluation of the expressions in the constraint is deferred until
kono
parents:
diff changeset
29 -- an object of the subtype is created. Check for cases of records.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- TEST DESCRIPTION:
kono
parents:
diff changeset
32 -- This transition test defines record types with discriminant components
kono
parents:
diff changeset
33 -- which depend on the discriminants. The discriminants are calculated
kono
parents:
diff changeset
34 -- by function calls. The test verifies that Constraint_Error is raised
kono
parents:
diff changeset
35 -- during the object creations when values of discriminants are
kono
parents:
diff changeset
36 -- incompatible with the subtypes.
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- Inspired by C37213A.ADA, C37213C.ADA, C37215A.ADA and C37215C.ADA.
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- CHANGE HISTORY:
kono
parents:
diff changeset
42 -- 05 Apr 96 SAIC Initial version for ACVC 2.1.
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 --!
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 with Report;
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 procedure C371002 is
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 subtype Small_Int is Integer range 1..10;
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 type Rec_W_Disc (Disc1, Disc2 : Small_Int) is
kono
parents:
diff changeset
53 record
kono
parents:
diff changeset
54 Str1 : String (1 .. Disc1) := (others => '*');
kono
parents:
diff changeset
55 Str2 : String (1 .. Disc2) := (others => '*');
kono
parents:
diff changeset
56 end record;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 type My_Array is array (Small_Int range <>) of Integer;
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 Func1_Cons : Integer := 0;
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 ---------------------------------------------------------
kono
parents:
diff changeset
63 function Chk (Cons : Integer;
kono
parents:
diff changeset
64 Value : Integer;
kono
parents:
diff changeset
65 Message : String) return Boolean is
kono
parents:
diff changeset
66 begin
kono
parents:
diff changeset
67 if Cons /= Value then
kono
parents:
diff changeset
68 Report.Failed (Message & ": Func1_Cons is " &
kono
parents:
diff changeset
69 Integer'Image(Func1_Cons));
kono
parents:
diff changeset
70 end if;
kono
parents:
diff changeset
71 return True;
kono
parents:
diff changeset
72 end Chk;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 ---------------------------------------------------------
kono
parents:
diff changeset
75 function Func1 return Integer is
kono
parents:
diff changeset
76 begin
kono
parents:
diff changeset
77 Func1_Cons := Func1_Cons + Report.Ident_Int(1);
kono
parents:
diff changeset
78 return Func1_Cons;
kono
parents:
diff changeset
79 end Func1;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 begin
kono
parents:
diff changeset
82 Report.Test ("C371002", "Check that if a discriminant constraint " &
kono
parents:
diff changeset
83 "depends on a discriminant, the evaluation of the " &
kono
parents:
diff changeset
84 "expressions in the constraint is deferred until " &
kono
parents:
diff changeset
85 "object declarations");
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 ---------------------------------------------------------
kono
parents:
diff changeset
88 declare
kono
parents:
diff changeset
89 type Rec1 (D3 : Integer) is
kono
parents:
diff changeset
90 record
kono
parents:
diff changeset
91 C1 : Rec_W_Disc (D3, Func1); -- Func1 evaluated, value 1.
kono
parents:
diff changeset
92 end record;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 Chk1 : Boolean := Chk (Func1_Cons, 1,
kono
parents:
diff changeset
95 "Func1 not evaluated for Rec1");
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 Obj1 : Rec1 (1); -- Func1 not evaluated again.
kono
parents:
diff changeset
98 Obj2 : Rec1 (2); -- Func1 not evaluated again.
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 Chk2 : Boolean := Chk (Func1_Cons, 1,
kono
parents:
diff changeset
101 "Func1 evaluated too many times");
kono
parents:
diff changeset
102 begin
kono
parents:
diff changeset
103 if Obj1 /= (D3 => 1,
kono
parents:
diff changeset
104 C1 => (Disc1 => 1,
kono
parents:
diff changeset
105 Disc2 => 1,
kono
parents:
diff changeset
106 Str1 => (others => '*'),
kono
parents:
diff changeset
107 Str2 => (others => '*'))) or
kono
parents:
diff changeset
108 Obj2 /= (D3 => 2,
kono
parents:
diff changeset
109 C1 => (Disc1 => 2,
kono
parents:
diff changeset
110 Disc2 => 1,
kono
parents:
diff changeset
111 Str1 => (others => '*'),
kono
parents:
diff changeset
112 Str2 => (others => '*'))) then
kono
parents:
diff changeset
113 Report.Failed ("Obj1 & Obj2 - Discriminant values not correct");
kono
parents:
diff changeset
114 end if;
kono
parents:
diff changeset
115 end;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 ---------------------------------------------------------
kono
parents:
diff changeset
118 Func1_Cons := -11;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 declare
kono
parents:
diff changeset
121 type Rec_Of_Rec_01 (D3 : Integer) is
kono
parents:
diff changeset
122 record
kono
parents:
diff changeset
123 C1 : Rec_W_Disc (D3, Func1); -- Func1 evaluated, value -10.
kono
parents:
diff changeset
124 end record; -- Constraint_Error not raised.
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 type Rec_Of_MyArr_01 (D3 : Integer) is
kono
parents:
diff changeset
127 record
kono
parents:
diff changeset
128 C1 : My_Array (Func1 .. D3); -- Func1 evaluated, value -9.
kono
parents:
diff changeset
129 end record; -- Constraint_Error not raised.
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 type Rec_Of_Rec_02 (D3 : Integer) is
kono
parents:
diff changeset
132 record
kono
parents:
diff changeset
133 C1 : Rec_W_Disc (D3, 1);
kono
parents:
diff changeset
134 end record;
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 type Rec_Of_MyArr_02 (D3 : Integer) is
kono
parents:
diff changeset
137 record
kono
parents:
diff changeset
138 C1 : My_Array (D3 .. 1);
kono
parents:
diff changeset
139 end record;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 begin
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 ---------------------------------------------------------
kono
parents:
diff changeset
144 begin
kono
parents:
diff changeset
145 declare
kono
parents:
diff changeset
146 Obj3 : Rec_Of_Rec_01(1); -- Constraint_Error raised.
kono
parents:
diff changeset
147 begin
kono
parents:
diff changeset
148 Report.Failed ("Obj3 - Constraint_Error should be raised");
kono
parents:
diff changeset
149 if Obj3 /= (1, (1, 1, others => (others => '*'))) then
kono
parents:
diff changeset
150 Report.Comment ("Obj3 - Shouldn't get here");
kono
parents:
diff changeset
151 end if;
kono
parents:
diff changeset
152 end;
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 exception
kono
parents:
diff changeset
155 when Constraint_Error => -- Exception expected.
kono
parents:
diff changeset
156 null;
kono
parents:
diff changeset
157 when others =>
kono
parents:
diff changeset
158 Report.Failed ("Obj3 - others exception raised");
kono
parents:
diff changeset
159 end;
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 ---------------------------------------------------------
kono
parents:
diff changeset
162 begin
kono
parents:
diff changeset
163 declare
kono
parents:
diff changeset
164 subtype Subtype_Rec is Rec_Of_Rec_01(1);
kono
parents:
diff changeset
165 -- No Constraint_Error raised.
kono
parents:
diff changeset
166 begin
kono
parents:
diff changeset
167 declare
kono
parents:
diff changeset
168 Obj4 : Subtype_Rec; -- Constraint_Error raised.
kono
parents:
diff changeset
169 begin
kono
parents:
diff changeset
170 Report.Failed ("Obj4 - Constraint_Error should be raised");
kono
parents:
diff changeset
171 if Obj4 /= (D3 => 1,
kono
parents:
diff changeset
172 C1 => (Disc1 => 1,
kono
parents:
diff changeset
173 Disc2 => 1,
kono
parents:
diff changeset
174 Str1 => (others => '*'),
kono
parents:
diff changeset
175 Str2 => (others => '*'))) then
kono
parents:
diff changeset
176 Report.Comment ("Obj4 - Shouldn't get here");
kono
parents:
diff changeset
177 end if;
kono
parents:
diff changeset
178 end;
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 exception
kono
parents:
diff changeset
181 when Constraint_Error => -- Exception expected.
kono
parents:
diff changeset
182 null;
kono
parents:
diff changeset
183 when others =>
kono
parents:
diff changeset
184 Report.Failed ("Obj4 - others exception raised");
kono
parents:
diff changeset
185 end;
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 exception
kono
parents:
diff changeset
188 when Constraint_Error =>
kono
parents:
diff changeset
189 Report.Failed ("Subtype_Rec - Constraint_Error raised");
kono
parents:
diff changeset
190 when others =>
kono
parents:
diff changeset
191 Report.Failed ("Subtype_Rec - others exception raised");
kono
parents:
diff changeset
192 end;
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 ---------------------------------------------------------
kono
parents:
diff changeset
195 begin
kono
parents:
diff changeset
196 declare
kono
parents:
diff changeset
197 type Arr is array (1..5) -- No Constraint_Error raised.
kono
parents:
diff changeset
198 of Rec_Of_Rec_01(1);
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 begin
kono
parents:
diff changeset
201 declare
kono
parents:
diff changeset
202 Obj5 : Arr; -- Constraint_Error raised.
kono
parents:
diff changeset
203 begin
kono
parents:
diff changeset
204 Report.Failed ("Obj5 - Constraint_Error should be raised");
kono
parents:
diff changeset
205 if Obj5 /= (1..5 => (1, (1, 1, others => (others => '*')))) then
kono
parents:
diff changeset
206 Report.Comment ("Obj5 - Shouldn't get here");
kono
parents:
diff changeset
207 end if;
kono
parents:
diff changeset
208 end;
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 exception
kono
parents:
diff changeset
211 when Constraint_Error => -- Exception expected.
kono
parents:
diff changeset
212 null;
kono
parents:
diff changeset
213 when others =>
kono
parents:
diff changeset
214 Report.Failed ("Obj5 - others exception raised");
kono
parents:
diff changeset
215 end;
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 exception
kono
parents:
diff changeset
218 when Constraint_Error =>
kono
parents:
diff changeset
219 Report.Failed ("Arr - Constraint_Error raised");
kono
parents:
diff changeset
220 when others =>
kono
parents:
diff changeset
221 Report.Failed ("Arr - others exception raised");
kono
parents:
diff changeset
222 end;
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 ---------------------------------------------------------
kono
parents:
diff changeset
225 begin
kono
parents:
diff changeset
226 declare
kono
parents:
diff changeset
227 type Rec_Of_Rec_Of_MyArr is
kono
parents:
diff changeset
228 record
kono
parents:
diff changeset
229 C1 : Rec_Of_MyArr_01(1); -- No Constraint_Error raised.
kono
parents:
diff changeset
230 end record;
kono
parents:
diff changeset
231 begin
kono
parents:
diff changeset
232 declare
kono
parents:
diff changeset
233 Obj6 : Rec_Of_Rec_Of_MyArr; -- Constraint_Error raised.
kono
parents:
diff changeset
234 begin
kono
parents:
diff changeset
235 Report.Failed ("Obj6 - Constraint_Error should be raised");
kono
parents:
diff changeset
236 if Obj6 /= (C1 => (1, (1, 1))) then
kono
parents:
diff changeset
237 Report.Comment ("Obj6 - Shouldn't get here");
kono
parents:
diff changeset
238 end if;
kono
parents:
diff changeset
239 end;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 exception
kono
parents:
diff changeset
242 when Constraint_Error => -- Exception expected.
kono
parents:
diff changeset
243 null;
kono
parents:
diff changeset
244 when others =>
kono
parents:
diff changeset
245 Report.Failed ("Obj6 - others exception raised");
kono
parents:
diff changeset
246 end;
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 exception
kono
parents:
diff changeset
249 when Constraint_Error =>
kono
parents:
diff changeset
250 Report.Failed ("Rec_Of_Rec_Of_MyArr - Constraint_Error raised");
kono
parents:
diff changeset
251 when others =>
kono
parents:
diff changeset
252 Report.Failed ("Rec_Of_Rec_Of_MyArr - others exception raised");
kono
parents:
diff changeset
253 end;
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 ---------------------------------------------------------
kono
parents:
diff changeset
256 begin
kono
parents:
diff changeset
257 declare
kono
parents:
diff changeset
258 type New_Rec is
kono
parents:
diff changeset
259 new Rec_Of_MyArr_01(1); -- No Constraint_Error raised.
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 begin
kono
parents:
diff changeset
262 declare
kono
parents:
diff changeset
263 Obj7 : New_Rec; -- Constraint_Error raised.
kono
parents:
diff changeset
264 begin
kono
parents:
diff changeset
265 Report.Failed ("Obj7 - Constraint_Error should be raised");
kono
parents:
diff changeset
266 if Obj7 /= (1, (1, 1)) then
kono
parents:
diff changeset
267 Report.Comment ("Obj7 - Shouldn't get here");
kono
parents:
diff changeset
268 end if;
kono
parents:
diff changeset
269 end;
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 exception
kono
parents:
diff changeset
272 when Constraint_Error => -- Exception expected.
kono
parents:
diff changeset
273 null;
kono
parents:
diff changeset
274 when others =>
kono
parents:
diff changeset
275 Report.Failed ("Obj7 - others exception raised");
kono
parents:
diff changeset
276 end;
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 exception
kono
parents:
diff changeset
279 when Constraint_Error =>
kono
parents:
diff changeset
280 Report.Failed ("New_Rec - Constraint_Error raised");
kono
parents:
diff changeset
281 when others =>
kono
parents:
diff changeset
282 Report.Failed ("New_Rec - others exception raised");
kono
parents:
diff changeset
283 end;
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 ---------------------------------------------------------
kono
parents:
diff changeset
286 begin
kono
parents:
diff changeset
287 declare
kono
parents:
diff changeset
288 type Acc_Rec is
kono
parents:
diff changeset
289 access Rec_Of_Rec_02 (Report.Ident_Int(0));
kono
parents:
diff changeset
290 -- No Constraint_Error raised.
kono
parents:
diff changeset
291 begin
kono
parents:
diff changeset
292 declare
kono
parents:
diff changeset
293 Obj8 : Acc_Rec; -- No Constraint_Error raised.
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 begin
kono
parents:
diff changeset
296 Obj8 := new Rec_Of_Rec_02 (Report.Ident_Int(0));
kono
parents:
diff changeset
297 -- Constraint_Error raised.
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 Report.Failed ("Obj8 - Constraint_Error should be raised");
kono
parents:
diff changeset
300 if Obj8.all /= (D3 => 1,
kono
parents:
diff changeset
301 C1 => (Disc1 => 1,
kono
parents:
diff changeset
302 Disc2 => 1,
kono
parents:
diff changeset
303 Str1 => (others => '*'),
kono
parents:
diff changeset
304 Str2 => (others => '*'))) then
kono
parents:
diff changeset
305 Report.Comment ("Obj8 - Shouldn't get here");
kono
parents:
diff changeset
306 end if;
kono
parents:
diff changeset
307 end;
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 exception
kono
parents:
diff changeset
310 when Constraint_Error => -- Exception expected.
kono
parents:
diff changeset
311 null;
kono
parents:
diff changeset
312 when others =>
kono
parents:
diff changeset
313 Report.Failed ("Obj8 - others exception raised");
kono
parents:
diff changeset
314 end;
kono
parents:
diff changeset
315
kono
parents:
diff changeset
316 exception
kono
parents:
diff changeset
317 when Constraint_Error =>
kono
parents:
diff changeset
318 Report.Failed ("Acc_Rec - Constraint_Error raised");
kono
parents:
diff changeset
319 when others =>
kono
parents:
diff changeset
320 Report.Failed ("Acc_Rec - others exception raised");
kono
parents:
diff changeset
321 end;
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 ---------------------------------------------------------
kono
parents:
diff changeset
324 begin
kono
parents:
diff changeset
325 declare
kono
parents:
diff changeset
326 type Acc_Rec_MyArr is access
kono
parents:
diff changeset
327 Rec_Of_MyArr_02; -- No Constraint_Error
kono
parents:
diff changeset
328 -- raised for either
kono
parents:
diff changeset
329 Obj9 : Acc_Rec_MyArr; -- declaration.
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 begin
kono
parents:
diff changeset
332 Obj9 := new Rec_Of_MyArr_02 (Report.Ident_Int(0));
kono
parents:
diff changeset
333 -- Constraint_Error raised.
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 Report.Failed ("Obj9 - Constraint_Error should be raised");
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 if Obj9.all /= (1, (1, 1)) then
kono
parents:
diff changeset
338 Report.Comment ("Obj9 - Shouldn't get here");
kono
parents:
diff changeset
339 end if;
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 exception
kono
parents:
diff changeset
342 when Constraint_Error => -- Exception expected.
kono
parents:
diff changeset
343 null;
kono
parents:
diff changeset
344 when others =>
kono
parents:
diff changeset
345 Report.Failed ("Obj9 - others exception raised");
kono
parents:
diff changeset
346 end;
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 exception
kono
parents:
diff changeset
349 when Constraint_Error =>
kono
parents:
diff changeset
350 Report.Failed ("Acc_Rec_MyArr - Constraint_Error raised");
kono
parents:
diff changeset
351 when others =>
kono
parents:
diff changeset
352 Report.Failed ("Acc_Rec_MyArr - others exception raised");
kono
parents:
diff changeset
353 end;
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355 end;
kono
parents:
diff changeset
356
kono
parents:
diff changeset
357 Report.Result;
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 exception
kono
parents:
diff changeset
360 when others =>
kono
parents:
diff changeset
361 Report.Failed ("Discriminant value checked too soon");
kono
parents:
diff changeset
362 Report.Result;
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 end C371002;