annotate gcc/testsuite/ada/acats/tests/c4/c460004.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 -- C460004.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 the operand type of a type conversion is class-wide,
kono
parents:
diff changeset
28 -- Constraint_Error is raised if the tag of the operand does not
kono
parents:
diff changeset
29 -- identify a specific type that is covered by or descended from the
kono
parents:
diff changeset
30 -- target type.
kono
parents:
diff changeset
31 --
kono
parents:
diff changeset
32 -- TEST DESCRIPTION:
kono
parents:
diff changeset
33 -- View conversions of class-wide operands to specific types are
kono
parents:
diff changeset
34 -- placed on the right and left sides of assignment statements, and
kono
parents:
diff changeset
35 -- conversions of class-wide operands to class-wide types are used
kono
parents:
diff changeset
36 -- as actual parameters to dispatching operations. In all cases, a
kono
parents:
diff changeset
37 -- check is made that Constraint_Error is raised if the tag of the
kono
parents:
diff changeset
38 -- operand does not identify a specific type covered by or descended
kono
parents:
diff changeset
39 -- from the target type, and not raised otherwise.
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- A specific type is descended from itself and from those types it is
kono
parents:
diff changeset
42 -- directly or indirectly derived from. A specific type is covered by
kono
parents:
diff changeset
43 -- itself and each class-wide type to whose class it belongs.
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 -- A class-wide type T'Class is descended from T and those types which
kono
parents:
diff changeset
46 -- T is descended from. A class-wide type is covered by each class-wide
kono
parents:
diff changeset
47 -- type to whose class it belongs.
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 --
kono
parents:
diff changeset
50 -- CHANGE HISTORY:
kono
parents:
diff changeset
51 -- 19 Jul 95 SAIC Initial prerelease version.
kono
parents:
diff changeset
52 -- 18 Apr 96 SAIC ACVC 2.1: Added a check for correct tag.
kono
parents:
diff changeset
53 --
kono
parents:
diff changeset
54 --!
kono
parents:
diff changeset
55 package C460004_0 is
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 type Tag_Type is tagged record
kono
parents:
diff changeset
58 C1 : Natural;
kono
parents:
diff changeset
59 end record;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 procedure Proc (X : in out Tag_Type);
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 type DTag_Type is new Tag_Type with record
kono
parents:
diff changeset
65 C2 : String (1 .. 5);
kono
parents:
diff changeset
66 end record;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 procedure Proc (X : in out DTag_Type);
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 type DDTag_Type is new DTag_Type with record
kono
parents:
diff changeset
72 C3 : String (1 .. 5);
kono
parents:
diff changeset
73 end record;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 procedure Proc (X : in out DDTag_Type);
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 procedure NewProc (X : in DDTag_Type);
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 function CWFunc (X : Tag_Type'Class) return Tag_Type'Class;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 end C460004_0;
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 --==================================================================--
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 with Report;
kono
parents:
diff changeset
87 package body C460004_0 is
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 procedure Proc (X : in out Tag_Type) is
kono
parents:
diff changeset
90 begin
kono
parents:
diff changeset
91 X.C1 := 25;
kono
parents:
diff changeset
92 end Proc;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 -----------------------------------------
kono
parents:
diff changeset
95 procedure Proc (X : in out DTag_Type) is
kono
parents:
diff changeset
96 begin
kono
parents:
diff changeset
97 Proc ( Tag_Type(X) );
kono
parents:
diff changeset
98 X.C2 := "Earth";
kono
parents:
diff changeset
99 end Proc;
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 -----------------------------------------
kono
parents:
diff changeset
102 procedure Proc (X : in out DDTag_Type) is
kono
parents:
diff changeset
103 begin
kono
parents:
diff changeset
104 Proc ( DTag_Type(X) );
kono
parents:
diff changeset
105 X.C3 := "Orbit";
kono
parents:
diff changeset
106 end Proc;
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 -----------------------------------------
kono
parents:
diff changeset
109 procedure NewProc (X : in DDTag_Type) is
kono
parents:
diff changeset
110 Y : DDTag_Type := X;
kono
parents:
diff changeset
111 begin
kono
parents:
diff changeset
112 Proc (Y);
kono
parents:
diff changeset
113 exception
kono
parents:
diff changeset
114 when others =>
kono
parents:
diff changeset
115 Report.Failed ("Unexpected exception in NewProc");
kono
parents:
diff changeset
116 end NewProc;
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 -----------------------------------------
kono
parents:
diff changeset
119 function CWFunc (X : Tag_Type'Class) return Tag_Type'Class is
kono
parents:
diff changeset
120 Y : Tag_Type'Class := X;
kono
parents:
diff changeset
121 begin
kono
parents:
diff changeset
122 Proc (Y);
kono
parents:
diff changeset
123 return Y;
kono
parents:
diff changeset
124 end CWFunc;
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 end C460004_0;
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 --==================================================================--
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 with C460004_0;
kono
parents:
diff changeset
133 use C460004_0;
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 with Report;
kono
parents:
diff changeset
136 procedure C460004 is
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 Tag_Type_Init : constant Tag_Type := (C1 => 0);
kono
parents:
diff changeset
139 DTag_Type_Init : constant DTag_Type := (Tag_Type_Init with "Hello");
kono
parents:
diff changeset
140 DDTag_Type_Init : constant DDTag_Type := (DTag_Type_Init with "World");
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 Tag_Type_Value : constant Tag_Type := (C1 => 25);
kono
parents:
diff changeset
143 DTag_Type_Value : constant DTag_Type := (Tag_Type_Value with "Earth");
kono
parents:
diff changeset
144 DDTag_Type_Value : constant DDTag_Type := (DTag_Type_Value with "Orbit");
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 begin
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 Report.Test ("C460004", "Check that for a view conversion of a " &
kono
parents:
diff changeset
149 "class-wide operand, Constraint_Error is raised if the " &
kono
parents:
diff changeset
150 "tag of the operand does not identify a specific type " &
kono
parents:
diff changeset
151 "covered by or descended from the target type");
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 --
kono
parents:
diff changeset
154 -- View conversion to specific type:
kono
parents:
diff changeset
155 --
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 declare
kono
parents:
diff changeset
158 procedure CW_Proc (P : Tag_Type'Class) is
kono
parents:
diff changeset
159 Target : Tag_Type := Tag_Type_Init;
kono
parents:
diff changeset
160 begin
kono
parents:
diff changeset
161 Target := Tag_Type(P);
kono
parents:
diff changeset
162 if (Target /= Tag_Type_Value) then
kono
parents:
diff changeset
163 Report.Failed ("Target has wrong value: #01");
kono
parents:
diff changeset
164 end if;
kono
parents:
diff changeset
165 exception
kono
parents:
diff changeset
166 when Constraint_Error =>
kono
parents:
diff changeset
167 Report.Failed ("Constraint_Error raised: #01");
kono
parents:
diff changeset
168 when others =>
kono
parents:
diff changeset
169 Report.Failed ("Unexpected exception: #01");
kono
parents:
diff changeset
170 end CW_Proc;
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 begin
kono
parents:
diff changeset
173 CW_Proc (DDTag_Type_Value);
kono
parents:
diff changeset
174 end;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 ----------------------------------------------------------------------
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 declare
kono
parents:
diff changeset
179 Target : DTag_Type := DTag_Type_Init;
kono
parents:
diff changeset
180 begin
kono
parents:
diff changeset
181 Target := DTag_Type(CWFunc(DDTag_Type_Value));
kono
parents:
diff changeset
182 if (Target /= DTag_Type_Value) then
kono
parents:
diff changeset
183 Report.Failed ("Target has wrong value: #02");
kono
parents:
diff changeset
184 end if;
kono
parents:
diff changeset
185 exception
kono
parents:
diff changeset
186 when Constraint_Error => Report.Failed ("Constraint_Error raised: #02");
kono
parents:
diff changeset
187 when others => Report.Failed ("Unexpected exception: #02");
kono
parents:
diff changeset
188 end;
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 ----------------------------------------------------------------------
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 declare
kono
parents:
diff changeset
193 Target : DDTag_Type;
kono
parents:
diff changeset
194 begin
kono
parents:
diff changeset
195 Target := DDTag_Type(CWFunc(Tag_Type_Value));
kono
parents:
diff changeset
196 -- CWFunc returns a Tag_Type; its tag is preserved through
kono
parents:
diff changeset
197 -- the view conversion. Constraint_Error should be raised.
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 Report.Failed ("Constraint_Error not raised: #03");
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 exception
kono
parents:
diff changeset
202 when Constraint_Error => null; -- expected exception
kono
parents:
diff changeset
203 when others => Report.Failed ("Unexpected exception: #03");
kono
parents:
diff changeset
204 end;
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 ----------------------------------------------------------------------
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 declare
kono
parents:
diff changeset
209 procedure CW_Proc (P : Tag_Type'Class) is
kono
parents:
diff changeset
210 begin
kono
parents:
diff changeset
211 NewProc (DDTag_Type(P));
kono
parents:
diff changeset
212 Report.Failed ("Constraint_Error not raised: #04");
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 exception
kono
parents:
diff changeset
215 when Constraint_Error => null; -- expected exception
kono
parents:
diff changeset
216 when others => Report.Failed ("Unexpected exception: #04");
kono
parents:
diff changeset
217 end CW_Proc;
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 begin
kono
parents:
diff changeset
220 CW_Proc (DTag_Type_Value);
kono
parents:
diff changeset
221 end;
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 ----------------------------------------------------------------------
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 declare
kono
parents:
diff changeset
226 procedure CW_Proc (P : Tag_Type'Class) is
kono
parents:
diff changeset
227 Target : DDTag_Type := DDTag_Type_Init;
kono
parents:
diff changeset
228 begin
kono
parents:
diff changeset
229 Target := DDTag_Type(P);
kono
parents:
diff changeset
230 if (Target /= DDTag_Type_Value) then
kono
parents:
diff changeset
231 Report.Failed ("Target has wrong value: #05");
kono
parents:
diff changeset
232 end if;
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 exception
kono
parents:
diff changeset
235 when Constraint_Error =>
kono
parents:
diff changeset
236 Report.Failed ("Constraint_Error raised: #05");
kono
parents:
diff changeset
237 when others
kono
parents:
diff changeset
238 => Report.Failed ("Unexpected exception: #05");
kono
parents:
diff changeset
239 end CW_Proc;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 begin
kono
parents:
diff changeset
242 CW_Proc (DDTag_Type_Value);
kono
parents:
diff changeset
243 end;
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 --
kono
parents:
diff changeset
247 -- View conversion to class-wide type:
kono
parents:
diff changeset
248 --
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 declare
kono
parents:
diff changeset
251 procedure CW_Proc (P : Tag_Type'Class) is
kono
parents:
diff changeset
252 Operand : Tag_Type'Class := P;
kono
parents:
diff changeset
253 begin
kono
parents:
diff changeset
254 Proc( DTag_Type'Class(Operand) );
kono
parents:
diff changeset
255 Report.Failed ("Constraint_Error not raised: #06");
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 exception
kono
parents:
diff changeset
258 when Constraint_Error => null; -- expected exception
kono
parents:
diff changeset
259 when others => Report.Failed ("Unexpected exception: #06");
kono
parents:
diff changeset
260 end CW_Proc;
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 begin
kono
parents:
diff changeset
263 CW_Proc (Tag_Type_Init);
kono
parents:
diff changeset
264 end;
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 ----------------------------------------------------------------------
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 declare
kono
parents:
diff changeset
269 procedure CW_Proc (P : Tag_Type'Class) is
kono
parents:
diff changeset
270 Operand : Tag_Type'Class := P;
kono
parents:
diff changeset
271 begin
kono
parents:
diff changeset
272 Proc( DDTag_Type'Class(Operand) );
kono
parents:
diff changeset
273 Report.Failed ("Constraint_Error not raised: #07");
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 exception
kono
parents:
diff changeset
276 when Constraint_Error => null; -- expected exception
kono
parents:
diff changeset
277 when others => Report.Failed ("Unexpected exception: #07");
kono
parents:
diff changeset
278 end CW_Proc;
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 begin
kono
parents:
diff changeset
281 CW_Proc (Tag_Type_Init);
kono
parents:
diff changeset
282 end;
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 ----------------------------------------------------------------------
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 declare
kono
parents:
diff changeset
287 procedure CW_Proc (P : Tag_Type'Class) is
kono
parents:
diff changeset
288 Operand : Tag_Type'Class := P;
kono
parents:
diff changeset
289 begin
kono
parents:
diff changeset
290 Proc( DTag_Type'Class(Operand) );
kono
parents:
diff changeset
291 if Operand not in DTag_Type then
kono
parents:
diff changeset
292 Report.Failed ("Operand has wrong tag: #08");
kono
parents:
diff changeset
293 elsif (Operand /= Tag_Type'Class (DTag_Type_Value)) then
kono
parents:
diff changeset
294 Report.Failed ("Operand has wrong value: #08");
kono
parents:
diff changeset
295 end if;
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 exception
kono
parents:
diff changeset
298 when Constraint_Error =>
kono
parents:
diff changeset
299 Report.Failed ("Constraint_Error raised: #08");
kono
parents:
diff changeset
300 when others =>
kono
parents:
diff changeset
301 Report.Failed ("Unexpected exception: #08");
kono
parents:
diff changeset
302 end CW_Proc;
kono
parents:
diff changeset
303
kono
parents:
diff changeset
304 begin
kono
parents:
diff changeset
305 CW_Proc (DTag_Type_Init);
kono
parents:
diff changeset
306 end;
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 ----------------------------------------------------------------------
kono
parents:
diff changeset
309
kono
parents:
diff changeset
310 declare
kono
parents:
diff changeset
311 procedure CW_Proc (P : Tag_Type'Class) is
kono
parents:
diff changeset
312 Operand : Tag_Type'Class := P;
kono
parents:
diff changeset
313 begin
kono
parents:
diff changeset
314 Proc( Tag_Type'Class(Operand) );
kono
parents:
diff changeset
315 if Operand not in DDTag_Type then
kono
parents:
diff changeset
316 Report.Failed ("Operand has wrong tag: #09");
kono
parents:
diff changeset
317 elsif (Operand /= Tag_Type'Class (DDTag_Type_Value)) then
kono
parents:
diff changeset
318 Report.Failed ("Operand has wrong value: #09");
kono
parents:
diff changeset
319 end if;
kono
parents:
diff changeset
320
kono
parents:
diff changeset
321 exception
kono
parents:
diff changeset
322 when Constraint_Error =>
kono
parents:
diff changeset
323 Report.Failed ("Constraint_Error raised: #09");
kono
parents:
diff changeset
324 when others =>
kono
parents:
diff changeset
325 Report.Failed ("Unexpected exception: #09");
kono
parents:
diff changeset
326 end CW_Proc;
kono
parents:
diff changeset
327
kono
parents:
diff changeset
328 begin
kono
parents:
diff changeset
329 CW_Proc (DDTag_Type_Init);
kono
parents:
diff changeset
330 end;
kono
parents:
diff changeset
331
kono
parents:
diff changeset
332
kono
parents:
diff changeset
333 Report.Result;
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 end C460004;