annotate gcc/testsuite/ada/acats/tests/c3/c3a1001.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 -- C3A1001.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 the full type completing a type with no discriminant part
kono
parents:
diff changeset
28 -- or an unknown discriminant part may have explicitly declared or
kono
parents:
diff changeset
29 -- inherited discriminants.
kono
parents:
diff changeset
30 -- Check for cases where the types are records and protected types.
kono
parents:
diff changeset
31 --
kono
parents:
diff changeset
32 -- TEST DESCRIPTION:
kono
parents:
diff changeset
33 -- Declare two groups of incomplete types: one group with no discriminant
kono
parents:
diff changeset
34 -- part and one group with unknown discriminant part. Both groups of
kono
parents:
diff changeset
35 -- incomplete types are completed with both explicit and inherited
kono
parents:
diff changeset
36 -- discriminants. Discriminants for record and protected types are
kono
parents:
diff changeset
37 -- declared with default and non default values.
kono
parents:
diff changeset
38 -- In the main program, verify that objects of both groups of incomplete
kono
parents:
diff changeset
39 -- types can be created by default values or by assignments.
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 -- CHANGE HISTORY:
kono
parents:
diff changeset
43 -- 11 Oct 95 SAIC Initial prerelease version.
kono
parents:
diff changeset
44 -- 11 Nov 96 SAIC Revised for version 2.1.
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 --!
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 package C3A1001_0 is
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 type Incomplete1 (<>); -- unknown discriminant
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 type Incomplete2; -- no discriminant
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 type Incomplete3 (<>); -- unknown discriminant
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 type Incomplete4; -- no discriminant
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 type Incomplete5 (<>); -- unknown discriminant
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 type Incomplete6; -- no discriminant
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 type Incomplete8; -- no discriminant
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 subtype Small_Int is Integer range 1 .. 10;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 type Enu_Type is (M, F);
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 type Incomplete1 (Disc : Enu_Type) is -- unknown discriminant/
kono
parents:
diff changeset
69 record -- explicit discriminant
kono
parents:
diff changeset
70 case Disc is
kono
parents:
diff changeset
71 when M => MInteger : Small_Int := 3;
kono
parents:
diff changeset
72 when F => FInteger : Small_Int := 8;
kono
parents:
diff changeset
73 end case;
kono
parents:
diff changeset
74 end record;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 type Incomplete2 (Disc : Small_Int := 8) is -- no discriminant/
kono
parents:
diff changeset
77 record -- explicit discriminant
kono
parents:
diff changeset
78 ID : String (1 .. Disc) := "Plymouth";
kono
parents:
diff changeset
79 end record;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 type Incomplete3 is new Incomplete2; -- unknown discriminant/
kono
parents:
diff changeset
82 -- inherited discriminant
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 type Incomplete4 is new Incomplete2; -- no discriminant/
kono
parents:
diff changeset
85 -- inherited discriminant
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 protected type Incomplete5 -- unknown discriminant/
kono
parents:
diff changeset
88 (Disc : Enu_Type) is -- explicit discriminant
kono
parents:
diff changeset
89 function Get_Priv_Val return Enu_Type;
kono
parents:
diff changeset
90 private
kono
parents:
diff changeset
91 Enu_Obj : Enu_Type := Disc;
kono
parents:
diff changeset
92 end Incomplete5;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 protected type Incomplete6 -- no discriminant/
kono
parents:
diff changeset
95 (Disc : Small_Int := 1) is -- explicit discriminant
kono
parents:
diff changeset
96 function Get_Priv_Val return Small_Int; -- with default
kono
parents:
diff changeset
97 private
kono
parents:
diff changeset
98 Num : Small_Int := Disc;
kono
parents:
diff changeset
99 end Incomplete6;
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 type Incomplete8 (Disc : Small_Int) is -- no discriminant/
kono
parents:
diff changeset
102 record -- explicit discriminant
kono
parents:
diff changeset
103 Str : String (1 .. Disc); -- no default
kono
parents:
diff changeset
104 end record;
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 type Incomplete9 is new Incomplete8;
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 function Return_String (S : String) return String;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 end C3A1001_0;
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 --==================================================================--
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 with Report;
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 package body C3A1001_0 is
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 protected body Incomplete5 is
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 function Get_Priv_Val return Enu_Type is
kono
parents:
diff changeset
121 begin
kono
parents:
diff changeset
122 return Enu_Obj;
kono
parents:
diff changeset
123 end Get_Priv_Val;
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 end Incomplete5;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 ----------------------------------------------------------------------
kono
parents:
diff changeset
128 protected body Incomplete6 is
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 function Get_Priv_Val return Small_Int is
kono
parents:
diff changeset
131 begin
kono
parents:
diff changeset
132 return Num;
kono
parents:
diff changeset
133 end Get_Priv_Val;
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 end Incomplete6;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 ----------------------------------------------------------------------
kono
parents:
diff changeset
138 function Return_String (S : String) return String is
kono
parents:
diff changeset
139 begin
kono
parents:
diff changeset
140 if Report.Ident_Bool(True) = True then
kono
parents:
diff changeset
141 return S;
kono
parents:
diff changeset
142 end if;
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 return S;
kono
parents:
diff changeset
145 end Return_String;
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 end C3A1001_0;
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 --==================================================================--
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 with Report;
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 with C3A1001_0;
kono
parents:
diff changeset
154 use C3A1001_0;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 procedure C3A1001 is
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 -- Discriminant value comes from default.
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 Incomplete2_Obj_1 : Incomplete2;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 Incomplete4_Obj_1 : Incomplete4;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 Incomplete6_Obj_1 : Incomplete6;
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 -- Discriminant value comes from explicit constraint.
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 Incomplete1_Obj_1 : Incomplete1 (F);
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 Incomplete5_Obj_1 : Incomplete5 (M);
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 Incomplete6_Obj_2 : Incomplete6 (2);
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 -- Discriminant value comes from assignment.
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 Incomplete3_Obj_1 : Incomplete3 := (Disc => 6, ID => "Sentra");
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 Incomplete1_Obj_2 : Incomplete1 := (Disc => M, MInteger => 9);
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 Incomplete2_Obj_2 : Incomplete2 := (Disc => 5, ID => "Buick");
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 begin
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 Report.Test ("C3A1001", "Check that the full type completing a type " &
kono
parents:
diff changeset
185 "with no discriminant part or an unknown discriminant " &
kono
parents:
diff changeset
186 "part may have explicitly declared or inherited " &
kono
parents:
diff changeset
187 "discriminants. Check for cases where the types are " &
kono
parents:
diff changeset
188 "records and protected types");
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 -- Check the initial values.
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 if (Incomplete2_Obj_1.Disc /= 8) or
kono
parents:
diff changeset
193 (Incomplete2_Obj_1.ID /= "Plymouth") then
kono
parents:
diff changeset
194 Report.Failed ("Wrong initial values for Incomplete2_Obj_1");
kono
parents:
diff changeset
195 end if;
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 if (Incomplete4_Obj_1.Disc /= 8) or
kono
parents:
diff changeset
198 (Incomplete4_Obj_1.ID /= "Plymouth") then
kono
parents:
diff changeset
199 Report.Failed ("Wrong initial values for Incomplete4_Obj_1");
kono
parents:
diff changeset
200 end if;
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 if (Incomplete6_Obj_1.Disc /= 1) or
kono
parents:
diff changeset
203 (Incomplete6_Obj_1.Get_Priv_Val /= 1) then
kono
parents:
diff changeset
204 Report.Failed ("Wrong initial value for Incomplete6_Obj_1");
kono
parents:
diff changeset
205 end if;
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 -- Check the explicit values.
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 if (Incomplete1_Obj_1.Disc /= F) or
kono
parents:
diff changeset
210 (Incomplete1_Obj_1.FInteger /= 8) then
kono
parents:
diff changeset
211 Report.Failed ("Wrong values for Incomplete1_Obj_1");
kono
parents:
diff changeset
212 end if;
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 if (Incomplete5_Obj_1.Disc /= M) or
kono
parents:
diff changeset
215 (Incomplete5_Obj_1.Get_Priv_Val /= M) then
kono
parents:
diff changeset
216 Report.Failed ("Wrong value for Incomplete5_Obj_1");
kono
parents:
diff changeset
217 end if;
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 if (Incomplete6_Obj_2.Disc /= 2) or
kono
parents:
diff changeset
220 (Incomplete6_Obj_2.Get_Priv_Val /= 2) then
kono
parents:
diff changeset
221 Report.Failed ("Wrong value for Incomplete6_Obj_2");
kono
parents:
diff changeset
222 end if;
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 -- Check the assigned values.
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 if (Incomplete3_Obj_1.Disc /= 6) or
kono
parents:
diff changeset
227 (Incomplete3_Obj_1.ID /= "Sentra") then
kono
parents:
diff changeset
228 Report.Failed ("Wrong values for Incomplete3_Obj_1");
kono
parents:
diff changeset
229 end if;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 if (Incomplete1_Obj_2.Disc /= M) or
kono
parents:
diff changeset
232 (Incomplete1_Obj_2.MInteger /= 9) then
kono
parents:
diff changeset
233 Report.Failed ("Wrong values for Incomplete1_Obj_2");
kono
parents:
diff changeset
234 end if;
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 if (Incomplete2_Obj_2.Disc /= 5) or
kono
parents:
diff changeset
237 (Incomplete2_Obj_2.ID /= "Buick") then
kono
parents:
diff changeset
238 Report.Failed ("Wrong values for Incomplete2_Obj_2");
kono
parents:
diff changeset
239 end if;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 -- Make sure that assignments work without problems.
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 Incomplete1_Obj_1.FInteger := 1;
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 -- Avoid optimization (dead variable removal of FInteger):
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 if Incomplete1_Obj_1.FInteger /= Report.Ident_Int(1)
kono
parents:
diff changeset
248 then
kono
parents:
diff changeset
249 Report.Failed ("Wrong value stored in Incomplete1_Obj_1.FInteger");
kono
parents:
diff changeset
250 end if;
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 Incomplete2_Obj_1.ID := Return_String ("12345678");
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 -- Avoid optimization (dead variable removal of ID)
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 if Incomplete2_Obj_1.ID /= Return_String ("12345678")
kono
parents:
diff changeset
257 then
kono
parents:
diff changeset
258 Report.Failed ("Wrong values for Incomplete8_Obj_1.ID");
kono
parents:
diff changeset
259 end if;
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 Incomplete4_Obj_1.ID := Return_String ("87654321");
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 -- Avoid optimization (dead variable removal of ID)
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 if Incomplete4_Obj_1.ID /= Return_String ("87654321")
kono
parents:
diff changeset
266 then
kono
parents:
diff changeset
267 Report.Failed ("Wrong values for Incomplete4_Obj_1.ID");
kono
parents:
diff changeset
268 end if;
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 Test1:
kono
parents:
diff changeset
272 declare
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 Incomplete8_Obj_1 : Incomplete8 (10);
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 begin
kono
parents:
diff changeset
277 Incomplete8_Obj_1.Str := "Merry Xmas";
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 -- Avoid optimization (dead variable removal of Str):
kono
parents:
diff changeset
280
kono
parents:
diff changeset
281 if Return_String (Incomplete8_Obj_1.Str) /= "Merry Xmas"
kono
parents:
diff changeset
282 then
kono
parents:
diff changeset
283 Report.Failed ("Wrong values for Incomplete8_Obj_1.Str");
kono
parents:
diff changeset
284 end if;
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 exception
kono
parents:
diff changeset
287 when Constraint_Error =>
kono
parents:
diff changeset
288 Report.Failed ("Constraint_Error raised in Incomplete8_Obj_1");
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 end Test1;
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 Test2:
kono
parents:
diff changeset
293 declare
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 Incomplete8_Obj_2 : Incomplete8 (5);
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 begin
kono
parents:
diff changeset
298 Incomplete8_Obj_2.Str := "Happy";
kono
parents:
diff changeset
299
kono
parents:
diff changeset
300 -- Avoid optimization (dead variable removal of Str):
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 if Return_String (Incomplete8_Obj_2.Str) /= "Happy"
kono
parents:
diff changeset
303 then
kono
parents:
diff changeset
304 Report.Failed ("Wrong values for Incomplete8_Obj_1.Str");
kono
parents:
diff changeset
305 end if;
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 exception
kono
parents:
diff changeset
308 when Constraint_Error =>
kono
parents:
diff changeset
309 Report.Failed ("Constraint_Error raised in Incomplete8_Obj_2");
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 end Test2;
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 Report.Result;
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 end C3A1001;