annotate gcc/testsuite/ada/acats/tests/c4/c433001.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 -- C433001.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 -- The Ada Conformity Assessment Authority (ACAA) holds unlimited
kono
parents:
diff changeset
6 -- rights in the software and documentation contained herein. Unlimited
kono
parents:
diff changeset
7 -- rights are the same as those granted by the U.S. Government for older
kono
parents:
diff changeset
8 -- parts of the Ada Conformity Assessment Test Suite, and are defined
kono
parents:
diff changeset
9 -- in DFAR 252.227-7013(a)(19). By making this public release, the ACAA
kono
parents:
diff changeset
10 -- intends to confer upon all recipients unlimited rights equal to those
kono
parents:
diff changeset
11 -- held by the ACAA. These rights include rights to use, duplicate,
kono
parents:
diff changeset
12 -- release or disclose the released technical data and computer software
kono
parents:
diff changeset
13 -- in whole or in part, in any manner and for any purpose whatsoever, and
kono
parents:
diff changeset
14 -- to have or permit others 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 an others choice is allowed in an array aggregate whose
kono
parents:
diff changeset
28 -- applicable index constraint is dynamic. (This was an extension to
kono
parents:
diff changeset
29 -- Ada 83). Check that index choices are within the applicable index
kono
parents:
diff changeset
30 -- constraint for array aggregates with others choices.
kono
parents:
diff changeset
31 --
kono
parents:
diff changeset
32 -- TEST DESCRIPTION
kono
parents:
diff changeset
33 -- In this test, we declare several unconstrained array types, and
kono
parents:
diff changeset
34 -- several dynamic subtypes. We then test a variety of cases of using
kono
parents:
diff changeset
35 -- appropriate aggregates. Some cases expect to raise Constraint_Error.
kono
parents:
diff changeset
36 --
kono
parents:
diff changeset
37 -- HISTORY:
kono
parents:
diff changeset
38 -- 16 DEC 1999 RLB Initial Version.
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 with Report;
kono
parents:
diff changeset
41 procedure C433001 is
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 type Color_Type is (Red, Orange, Yellow, Green, Blue, Indigo, Violet);
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 type Array_1 is array (Positive range <>) of Integer;
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 subtype Sub_1_1 is Array_1 (Report.Ident_Int(1) .. Report.Ident_Int(3));
kono
parents:
diff changeset
48 subtype Sub_1_2 is Array_1 (Report.Ident_Int(3) .. Report.Ident_Int(5));
kono
parents:
diff changeset
49 subtype Sub_1_3 is Array_1 (Report.Ident_Int(5) .. Report.Ident_Int(9));
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 type Array_2 is array (Color_Type range <>) of Integer;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 subtype Sub_2_1 is Array_2 (Color_Type'Val(Report.Ident_Int(0)) ..
kono
parents:
diff changeset
54 Color_Type'Val(Report.Ident_Int(2)));
kono
parents:
diff changeset
55 -- Red .. Yellow
kono
parents:
diff changeset
56 subtype Sub_2_2 is Array_2 (Color_Type'Val(Report.Ident_Int(3)) ..
kono
parents:
diff changeset
57 Color_Type'Val(Report.Ident_Int(6)));
kono
parents:
diff changeset
58 -- Green .. Violet
kono
parents:
diff changeset
59 type Array_3 is array (Color_Type range <>, Positive range <>) of Integer;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 subtype Sub_3_1 is Array_3 (Color_Type'Val(Report.Ident_Int(0)) ..
kono
parents:
diff changeset
62 Color_Type'Val(Report.Ident_Int(2)),
kono
parents:
diff changeset
63 Report.Ident_Int(3) .. Report.Ident_Int(5));
kono
parents:
diff changeset
64 -- Red .. Yellow, 3 .. 5
kono
parents:
diff changeset
65 subtype Sub_3_2 is Array_3 (Color_Type'Val(Report.Ident_Int(1)) ..
kono
parents:
diff changeset
66 Color_Type'Val(Report.Ident_Int(3)),
kono
parents:
diff changeset
67 Report.Ident_Int(6) .. Report.Ident_Int(8));
kono
parents:
diff changeset
68 -- Orange .. Green, 6 .. 8
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 procedure Check_1 (Obj : Array_1; Low, High : Integer;
kono
parents:
diff changeset
71 First_Component, Second_Component,
kono
parents:
diff changeset
72 Last_Component : Integer;
kono
parents:
diff changeset
73 Test_Case : Character) is
kono
parents:
diff changeset
74 begin
kono
parents:
diff changeset
75 if Obj'First /= Low then
kono
parents:
diff changeset
76 Report.Failed ("Low bound incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
77 end if;
kono
parents:
diff changeset
78 if Obj'Last /= High then
kono
parents:
diff changeset
79 Report.Failed ("High bound incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
80 end if;
kono
parents:
diff changeset
81 if Obj(Low) /= First_Component then
kono
parents:
diff changeset
82 Report.Failed ("First Component incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
83 end if;
kono
parents:
diff changeset
84 if Obj(Low+1) /= Second_Component then
kono
parents:
diff changeset
85 Report.Failed ("First Component incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
86 end if;
kono
parents:
diff changeset
87 if Obj(High) /= Last_Component then
kono
parents:
diff changeset
88 Report.Failed ("First Component incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
89 end if;
kono
parents:
diff changeset
90 end Check_1;
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 procedure Check_2 (Obj : Array_2; Low, High : Color_Type;
kono
parents:
diff changeset
93 First_Component, Second_Component,
kono
parents:
diff changeset
94 Last_Component : Integer;
kono
parents:
diff changeset
95 Test_Case : Character) is
kono
parents:
diff changeset
96 begin
kono
parents:
diff changeset
97 if Obj'First /= Low then
kono
parents:
diff changeset
98 Report.Failed ("Low bound incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
99 end if;
kono
parents:
diff changeset
100 if Obj'Last /= High then
kono
parents:
diff changeset
101 Report.Failed ("High bound incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
102 end if;
kono
parents:
diff changeset
103 if Obj(Low) /= First_Component then
kono
parents:
diff changeset
104 Report.Failed ("First Component incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
105 end if;
kono
parents:
diff changeset
106 if Obj(Color_Type'Succ(Low)) /= Second_Component then
kono
parents:
diff changeset
107 Report.Failed ("First Component incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
108 end if;
kono
parents:
diff changeset
109 if Obj(High) /= Last_Component then
kono
parents:
diff changeset
110 Report.Failed ("First Component incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
111 end if;
kono
parents:
diff changeset
112 end Check_2;
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 procedure Check_3 (Test_Obj, Check_Obj : Array_3;
kono
parents:
diff changeset
115 Low_1, High_1 : Color_Type;
kono
parents:
diff changeset
116 Low_2, High_2 : Integer;
kono
parents:
diff changeset
117 Test_Case : Character) is
kono
parents:
diff changeset
118 begin
kono
parents:
diff changeset
119 if Test_Obj'First(1) /= Low_1 then
kono
parents:
diff changeset
120 Report.Failed ("Low bound for dimension 1 incorrect (" &
kono
parents:
diff changeset
121 Test_Case & ")");
kono
parents:
diff changeset
122 end if;
kono
parents:
diff changeset
123 if Test_Obj'Last(1) /= High_1 then
kono
parents:
diff changeset
124 Report.Failed ("High bound for dimension 1 incorrect (" &
kono
parents:
diff changeset
125 Test_Case & ")");
kono
parents:
diff changeset
126 end if;
kono
parents:
diff changeset
127 if Test_Obj'First(2) /= Low_2 then
kono
parents:
diff changeset
128 Report.Failed ("Low bound for dimension 2 incorrect (" &
kono
parents:
diff changeset
129 Test_Case & ")");
kono
parents:
diff changeset
130 end if;
kono
parents:
diff changeset
131 if Test_Obj'Last(2) /= High_2 then
kono
parents:
diff changeset
132 Report.Failed ("High bound for dimension 2 incorrect (" &
kono
parents:
diff changeset
133 Test_Case & ")");
kono
parents:
diff changeset
134 end if;
kono
parents:
diff changeset
135 if Test_Obj /= Check_Obj then
kono
parents:
diff changeset
136 Report.Failed ("Components incorrect (" & Test_Case & ")");
kono
parents:
diff changeset
137 end if;
kono
parents:
diff changeset
138 end Check_3;
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 procedure Subtest_Check_1 (Obj : Sub_1_3;
kono
parents:
diff changeset
141 First_Component, Second_Component,
kono
parents:
diff changeset
142 Last_Component : Integer;
kono
parents:
diff changeset
143 Test_Case : Character) is
kono
parents:
diff changeset
144 begin
kono
parents:
diff changeset
145 Check_1 (Obj, 5, 9, First_Component, Second_Component, Last_Component,
kono
parents:
diff changeset
146 Test_Case);
kono
parents:
diff changeset
147 end Subtest_Check_1;
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 procedure Subtest_Check_2 (Obj : Sub_2_2;
kono
parents:
diff changeset
150 First_Component, Second_Component,
kono
parents:
diff changeset
151 Last_Component : Integer;
kono
parents:
diff changeset
152 Test_Case : Character) is
kono
parents:
diff changeset
153 begin
kono
parents:
diff changeset
154 Check_2 (Obj, Green, Violet, First_Component, Second_Component,
kono
parents:
diff changeset
155 Last_Component, Test_Case);
kono
parents:
diff changeset
156 end Subtest_Check_2;
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 procedure Subtest_Check_3 (Obj : Sub_3_2;
kono
parents:
diff changeset
159 Test_Case : Character) is
kono
parents:
diff changeset
160 begin
kono
parents:
diff changeset
161 Check_3 (Obj, Obj, Orange, Green, 6, 8, Test_Case);
kono
parents:
diff changeset
162 end Subtest_Check_3;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 begin
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 Report.Test ("C433001",
kono
parents:
diff changeset
167 "Check that an others choice is allowed in an array " &
kono
parents:
diff changeset
168 "aggregate whose applicable index constraint is dynamic. " &
kono
parents:
diff changeset
169 "Also check index choices are within the applicable index " &
kono
parents:
diff changeset
170 "constraint for array aggregates with others choices");
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 -- Check with a qualified expression:
kono
parents:
diff changeset
173 Check_1 (Sub_1_1'(2, 3, others => 4), Low => 1, High => 3,
kono
parents:
diff changeset
174 First_Component => 2, Second_Component => 3, Last_Component => 4,
kono
parents:
diff changeset
175 Test_Case => 'A');
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 Check_2 (Sub_2_1'(1, others => Report.Ident_Int(6)),
kono
parents:
diff changeset
178 Low => Red, High => Yellow,
kono
parents:
diff changeset
179 First_Component => 1, Second_Component => 6, Last_Component => 6,
kono
parents:
diff changeset
180 Test_Case => 'B');
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 Check_3 (Sub_3_1'((1, others => 3), others => (2, 4, others => 6)),
kono
parents:
diff changeset
183 Check_Obj => ((1, 3, 3), (2, 4, 6), (2, 4, 6)),
kono
parents:
diff changeset
184 Low_1 => Red, High_1 => Yellow, Low_2 => 3, High_2 => 5,
kono
parents:
diff changeset
185 Test_Case => 'C');
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 -- Check that the others clause does not need to represent any components:
kono
parents:
diff changeset
188 Check_1 (Sub_1_2'(5, 6, 8, others => 10), Low => 3, High => 5,
kono
parents:
diff changeset
189 First_Component => 5, Second_Component => 6, Last_Component => 8,
kono
parents:
diff changeset
190 Test_Case => 'D');
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 -- Check named choices are allowed:
kono
parents:
diff changeset
193 Check_1 (Sub_1_1'(2 => Report.Ident_Int(-1), others => 8),
kono
parents:
diff changeset
194 Low => 1, High => 3,
kono
parents:
diff changeset
195 First_Component => 8, Second_Component => -1, Last_Component => 8,
kono
parents:
diff changeset
196 Test_Case => 'E');
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 -- Check named choices and formal parameters:
kono
parents:
diff changeset
199 Subtest_Check_1 ((6 => 4, 8 => 86, others => 1),
kono
parents:
diff changeset
200 First_Component => 1, Second_Component => 4, Last_Component => 1,
kono
parents:
diff changeset
201 Test_Case => 'F');
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 Subtest_Check_2 ((Green => Report.Ident_Int(88), Violet => 89,
kono
parents:
diff changeset
204 Indigo => Report.Ident_Int(42), Blue => 0, others => -1),
kono
parents:
diff changeset
205 First_Component => 88, Second_Component => 0, Last_Component => 89,
kono
parents:
diff changeset
206 Test_Case => 'G');
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 Subtest_Check_3 ((Yellow => (7 => 0, others => 10), others => (1, 2, 3)),
kono
parents:
diff changeset
209 Test_Case => 'H');
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 -- Check object declarations and assignment:
kono
parents:
diff changeset
212 declare
kono
parents:
diff changeset
213 Var : Sub_1_2 := (4, 36, others => 86);
kono
parents:
diff changeset
214 begin
kono
parents:
diff changeset
215 Check_1 (Var, Low => 3, High => 5,
kono
parents:
diff changeset
216 First_Component => 4, Second_Component => 36,
kono
parents:
diff changeset
217 Last_Component => 86,
kono
parents:
diff changeset
218 Test_Case => 'I');
kono
parents:
diff changeset
219 Var := (5 => 415, others => Report.Ident_Int(1522));
kono
parents:
diff changeset
220 Check_1 (Var, Low => 3, High => 5,
kono
parents:
diff changeset
221 First_Component => 1522, Second_Component => 1522,
kono
parents:
diff changeset
222 Last_Component => 415,
kono
parents:
diff changeset
223 Test_Case => 'J');
kono
parents:
diff changeset
224 end;
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 -- Check positional aggregates that are too long:
kono
parents:
diff changeset
227 begin
kono
parents:
diff changeset
228 Subtest_Check_2 ((Report.Ident_Int(88), 89, 90, 91, 92, others => 93),
kono
parents:
diff changeset
229 First_Component => 88, Second_Component => 89,
kono
parents:
diff changeset
230 Last_Component => 91,
kono
parents:
diff changeset
231 Test_Case => 'K');
kono
parents:
diff changeset
232 Report.Failed ("Constraint_Error not raised by positional " &
kono
parents:
diff changeset
233 "aggregate with too many choices (K)");
kono
parents:
diff changeset
234 exception
kono
parents:
diff changeset
235 when Constraint_Error => null; -- Expected exception.
kono
parents:
diff changeset
236 end;
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 begin
kono
parents:
diff changeset
239 Subtest_Check_3 (((0, others => 10), (2, 3, others => 4),
kono
parents:
diff changeset
240 (5, 6, 8, others => 10), (1, 4, 7), others => (1, 2, 3)),
kono
parents:
diff changeset
241 Test_Case => 'L');
kono
parents:
diff changeset
242 Report.Failed ("Constraint_Error not raised by positional " &
kono
parents:
diff changeset
243 "aggregate with too many choices (L)");
kono
parents:
diff changeset
244 exception
kono
parents:
diff changeset
245 when Constraint_Error => null; -- Expected exception.
kono
parents:
diff changeset
246 end;
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 -- Check named aggregates with choices in the index subtype but not in the
kono
parents:
diff changeset
249 -- applicable index constraint:
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 begin
kono
parents:
diff changeset
252 Subtest_Check_1 ((5 => Report.Ident_Int(88), 8 => 89,
kono
parents:
diff changeset
253 10 => 66, -- 10 not in applicable index constraint
kono
parents:
diff changeset
254 others => 93),
kono
parents:
diff changeset
255 First_Component => 88, Second_Component => 93,
kono
parents:
diff changeset
256 Last_Component => 93,
kono
parents:
diff changeset
257 Test_Case => 'M');
kono
parents:
diff changeset
258 Report.Failed ("Constraint_Error not raised by aggregate choice " &
kono
parents:
diff changeset
259 "index outside of applicable index constraint (M)");
kono
parents:
diff changeset
260 exception
kono
parents:
diff changeset
261 when Constraint_Error => null; -- Expected exception.
kono
parents:
diff changeset
262 end;
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 begin
kono
parents:
diff changeset
265 Subtest_Check_2 (
kono
parents:
diff changeset
266 (Yellow => 23, -- Yellow not in applicable index constraint.
kono
parents:
diff changeset
267 Blue => 16, others => 77),
kono
parents:
diff changeset
268 First_Component => 77, Second_Component => 16,
kono
parents:
diff changeset
269 Last_Component => 77,
kono
parents:
diff changeset
270 Test_Case => 'N');
kono
parents:
diff changeset
271 Report.Failed ("Constraint_Error not raised by aggregate choice " &
kono
parents:
diff changeset
272 "index outside of applicable index constraint (N)");
kono
parents:
diff changeset
273 exception
kono
parents:
diff changeset
274 when Constraint_Error => null; -- Expected exception.
kono
parents:
diff changeset
275 end;
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 begin
kono
parents:
diff changeset
278 Subtest_Check_3 ((Orange => (0, others => 10),
kono
parents:
diff changeset
279 Blue => (2, 3, others => 4), -- Blue not in applicable index cons.
kono
parents:
diff changeset
280 others => (1, 2, 3)),
kono
parents:
diff changeset
281 Test_Case => 'P');
kono
parents:
diff changeset
282 Report.Failed ("Constraint_Error not raised by aggregate choice " &
kono
parents:
diff changeset
283 "index outside of applicable index constraint (P)");
kono
parents:
diff changeset
284 exception
kono
parents:
diff changeset
285 when Constraint_Error => null; -- Expected exception.
kono
parents:
diff changeset
286 end;
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 begin
kono
parents:
diff changeset
289 Subtest_Check_3 ((Orange => (6 => 0, others => Report.Ident_Int(10)),
kono
parents:
diff changeset
290 Green => (8 => 2, 4 => 3, others => 7),
kono
parents:
diff changeset
291 -- 4 not in applicable index cons.
kono
parents:
diff changeset
292 others => (1, 2, 3, others => Report.Ident_Int(10))),
kono
parents:
diff changeset
293 Test_Case => 'Q');
kono
parents:
diff changeset
294 Report.Failed ("Constraint_Error not raised by aggregate choice " &
kono
parents:
diff changeset
295 "index outside of applicable index constraint (Q)");
kono
parents:
diff changeset
296 exception
kono
parents:
diff changeset
297 when Constraint_Error => null; -- Expected exception.
kono
parents:
diff changeset
298 end;
kono
parents:
diff changeset
299
kono
parents:
diff changeset
300 Report.Result;
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 end C433001;