annotate gcc/testsuite/ada/acats/tests/cc/cc51d01.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 -- CC51D01.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, in an instance, each implicit declaration of a user-defined
kono
parents:
diff changeset
28 -- subprogram of a formal private extension declares a view of the
kono
parents:
diff changeset
29 -- corresponding primitive subprogram of the ancestor, and that if the
kono
parents:
diff changeset
30 -- tag in a call is statically determined to be that of the formal type,
kono
parents:
diff changeset
31 -- the body executed will be that corresponding to the actual type.
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- Check subprograms declared within a generic formal package. Check for
kono
parents:
diff changeset
34 -- the case where the actual type passed to the formal private extension
kono
parents:
diff changeset
35 -- is a specific tagged type. Check for several types in the same class.
kono
parents:
diff changeset
36 --
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- TEST DESCRIPTION:
kono
parents:
diff changeset
39 -- Declare a list abstraction in a generic package which manages lists of
kono
parents:
diff changeset
40 -- elements of any nonlimited type (foundation code). Declare a package
kono
parents:
diff changeset
41 -- which declares a tagged type and a type derived from it. Declare an
kono
parents:
diff changeset
42 -- operation for the root tagged type and override it for the derived
kono
parents:
diff changeset
43 -- type. Derive a type from this derived type, but do not override the
kono
parents:
diff changeset
44 -- operation. Declare a generic subprogram which operates on lists of
kono
parents:
diff changeset
45 -- elements of tagged types. Provide the generic subprogram with two
kono
parents:
diff changeset
46 -- formal parameters: (1) a formal derived tagged type which represents a
kono
parents:
diff changeset
47 -- list element type, and (2) a generic formal package with the list
kono
parents:
diff changeset
48 -- abstraction package as template. Use the formal derived type as the
kono
parents:
diff changeset
49 -- generic formal actual part for the formal package. Within the generic
kono
parents:
diff changeset
50 -- subprogram, call the operation of the root tagged type. In the main
kono
parents:
diff changeset
51 -- program, instantiate the generic list package and the generic
kono
parents:
diff changeset
52 -- subprogram with the root tagged type and each derivative, then call
kono
parents:
diff changeset
53 -- each instance with an object of the appropriate type.
kono
parents:
diff changeset
54 --
kono
parents:
diff changeset
55 -- TEST FILES:
kono
parents:
diff changeset
56 -- The following files comprise this test:
kono
parents:
diff changeset
57 --
kono
parents:
diff changeset
58 -- FC51D00.A
kono
parents:
diff changeset
59 -- -> CC51D01.A
kono
parents:
diff changeset
60 --
kono
parents:
diff changeset
61 --
kono
parents:
diff changeset
62 -- CHANGE HISTORY:
kono
parents:
diff changeset
63 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
64 -- 04 Jan 95 SAIC Moved declaration of type Ranked_ID_Type from
kono
parents:
diff changeset
65 -- main subprogram to package CC51D01_0. Removed
kono
parents:
diff changeset
66 -- case passing class-wide actual to instance.
kono
parents:
diff changeset
67 -- Updated test description and modified comments.
kono
parents:
diff changeset
68 --
kono
parents:
diff changeset
69 --!
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 package CC51D01_0 is -- This package simulates support for a personnel
kono
parents:
diff changeset
72 -- database.
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 type SSN_Type is new String (1 .. 9);
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 type Blind_ID_Type is tagged record -- Root type of
kono
parents:
diff changeset
77 SSN : SSN_Type; -- class.
kono
parents:
diff changeset
78 -- ... Other components.
kono
parents:
diff changeset
79 end record;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 procedure Update_ID (Item : in out Blind_ID_Type); -- Parent operation.
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 -- ... Other operations.
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 type Name_Type is new String (1 .. 9);
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 type Named_ID_Type is new Blind_ID_Type with record -- Direct derivative
kono
parents:
diff changeset
89 Name : Name_Type := "Doe "; -- of root type.
kono
parents:
diff changeset
90 -- ... Other components.
kono
parents:
diff changeset
91 end record;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 -- Inherits Update_ID from parent.
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 procedure Update_ID (Item : in out Named_ID_Type); -- Overrides parent's
kono
parents:
diff changeset
96 -- implementation.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 type Ranked_ID_Type is new Named_ID_Type with record
kono
parents:
diff changeset
100 Level : Integer := 0; -- Indirect derivative
kono
parents:
diff changeset
101 -- ... Other components. -- of root type.
kono
parents:
diff changeset
102 end record;
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 -- Inherits Update_ID from parent.
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 end CC51D01_0;
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 --==================================================================--
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 package body CC51D01_0 is
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 -- The implementations of Update_ID are purely artificial; the validity of
kono
parents:
diff changeset
115 -- their implementations in the context of the abstraction is irrelevant to
kono
parents:
diff changeset
116 -- the feature being tested.
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 procedure Update_ID (Item : in out Blind_ID_Type) is
kono
parents:
diff changeset
119 begin
kono
parents:
diff changeset
120 Item.SSN := "111223333";
kono
parents:
diff changeset
121 end Update_ID;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 procedure Update_ID (Item : in out Named_ID_Type) is
kono
parents:
diff changeset
125 begin
kono
parents:
diff changeset
126 Item.SSN := "444556666";
kono
parents:
diff changeset
127 -- ... Other stuff.
kono
parents:
diff changeset
128 end Update_ID;
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 end CC51D01_0;
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 --==================================================================--
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 -- --
kono
parents:
diff changeset
137 -- Formal package used here. --
kono
parents:
diff changeset
138 -- --
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 with FC51D00; -- Generic list abstraction.
kono
parents:
diff changeset
141 with CC51D01_0; -- Tagged type declarations.
kono
parents:
diff changeset
142 generic -- This procedure simulates a generic operation for types
kono
parents:
diff changeset
143 -- in the class rooted at Blind_ID_Type.
kono
parents:
diff changeset
144 type Elem_Type is new CC51D01_0.Blind_ID_Type with private;
kono
parents:
diff changeset
145 with package List_Mgr is new FC51D00 (Elem_Type);
kono
parents:
diff changeset
146 procedure CC51D01_1 (L : in out List_Mgr.List_Type; E : in Elem_Type);
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 --==================================================================--
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 -- The implementation of CC51D01_1 is purely artificial; the validity
kono
parents:
diff changeset
153 -- of its implementation in the context of the abstraction is irrelevant
kono
parents:
diff changeset
154 -- to the feature being tested.
kono
parents:
diff changeset
155 --
kono
parents:
diff changeset
156 -- The expected behavior here is as follows: for each actual type corresponding
kono
parents:
diff changeset
157 -- to Elem_Type, the call to Update_ID should invoke the actual type's
kono
parents:
diff changeset
158 -- implementation, which updates the object's SSN field. Write_Element then
kono
parents:
diff changeset
159 -- adds the object to the list.
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 procedure CC51D01_1 (L : in out List_Mgr.List_Type; E : in Elem_Type) is
kono
parents:
diff changeset
162 Element : Elem_Type := E; -- Can't update IN parameter.
kono
parents:
diff changeset
163 begin
kono
parents:
diff changeset
164 Update_ID (Element); -- Executes actual type's version.
kono
parents:
diff changeset
165 List_Mgr.Write_Element (1, L, Element); -- Executes actual type's version.
kono
parents:
diff changeset
166 end CC51D01_1;
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 --==================================================================--
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 with FC51D00; -- Generic list abstraction.
kono
parents:
diff changeset
173 with CC51D01_0; -- Tagged type declarations.
kono
parents:
diff changeset
174 with CC51D01_1; -- Generic operation.
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 with Report;
kono
parents:
diff changeset
177 procedure CC51D01 is
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 use CC51D01_0; -- All types & ops
kono
parents:
diff changeset
180 -- directly visible.
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 -- Begin test code declarations: -----------------------
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 TC_Expected_1 : Blind_ID_Type := (SSN => "111223333");
kono
parents:
diff changeset
185 TC_Expected_2 : Named_ID_Type := ("444556666", "Doe ");
kono
parents:
diff changeset
186 TC_Expected_3 : Ranked_ID_Type := ("444556666", "Doe ", 0);
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 TC_Initial_1 : Blind_ID_Type := (SSN => "777889999");
kono
parents:
diff changeset
189 TC_Initial_2 : Named_ID_Type := ("777889999", "Doe ");
kono
parents:
diff changeset
190 TC_Initial_3 : Ranked_ID_Type := ("777889999", "Doe ", 0);
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 -- End test code declarations. -------------------------
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 -- Begin instantiations and list declarations: ---------
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 -- At this point in an application, the generic list package would be
kono
parents:
diff changeset
198 -- instantiated for one of the visible tagged types. Next, the generic
kono
parents:
diff changeset
199 -- subprogram would be instantiated for the same tagged type and the
kono
parents:
diff changeset
200 -- preceding list package instance.
kono
parents:
diff changeset
201 --
kono
parents:
diff changeset
202 -- In order to cover all the important cases, this test instantiates several
kono
parents:
diff changeset
203 -- packages and subprograms (probably more than would typically appear
kono
parents:
diff changeset
204 -- in user code).
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 -- Support for lists of blind IDs:
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 package Blind_Lists is new FC51D00 (Blind_ID_Type);
kono
parents:
diff changeset
209 procedure Update_and_Write is new CC51D01_1 (Blind_ID_Type, Blind_Lists);
kono
parents:
diff changeset
210 Blind_List : Blind_Lists.List_Type;
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 -- Support for lists of named IDs:
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 package Named_Lists is new FC51D00 (Named_ID_Type);
kono
parents:
diff changeset
216 procedure Update_and_Write is new -- Overloads subprog
kono
parents:
diff changeset
217 CC51D01_1 (Elem_Type => Named_ID_Type, -- for Blind_ID_Type.
kono
parents:
diff changeset
218 List_Mgr => Named_Lists);
kono
parents:
diff changeset
219 Named_List : Named_Lists.List_Type;
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 -- Support for lists of ranked IDs:
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 package Ranked_Lists is new FC51D00 (Ranked_ID_Type);
kono
parents:
diff changeset
225 procedure Update_and_Write is new -- Overloads.
kono
parents:
diff changeset
226 CC51D01_1 (Elem_Type => Ranked_ID_Type,
kono
parents:
diff changeset
227 List_Mgr => Ranked_Lists);
kono
parents:
diff changeset
228 Ranked_List : Ranked_Lists.List_Type;
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 -- End instantiations and list declarations. -----------
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 begin
kono
parents:
diff changeset
234 Report.Test ("CC51D01", "Formal private extension, specific tagged " &
kono
parents:
diff changeset
235 "type actual: body of primitive subprogram executed is " &
kono
parents:
diff changeset
236 "that of actual type. Check for subprograms declared in " &
kono
parents:
diff changeset
237 "a formal package");
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239
kono
parents:
diff changeset
240 Update_and_Write (Blind_List, TC_Initial_1);
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 if (Blind_Lists.View_Element (1, Blind_List) /= TC_Expected_1) then
kono
parents:
diff changeset
243 Report.Failed ("Wrong result for root tagged type");
kono
parents:
diff changeset
244 end if;
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 Update_and_Write (Named_List, TC_Initial_2);
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 if (Named_Lists.View_Element (1, Named_List) /= TC_Expected_2) then
kono
parents:
diff changeset
250 Report.Failed ("Wrong result for type derived directly from root");
kono
parents:
diff changeset
251 end if;
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 Update_and_Write (Ranked_List, TC_Initial_3);
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 if (Ranked_Lists.View_Element (1, Ranked_List) /= TC_Expected_3) then
kono
parents:
diff changeset
257 Report.Failed ("Wrong result for type derived indirectly from root");
kono
parents:
diff changeset
258 end if;
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 Report.Result;
kono
parents:
diff changeset
262 end CC51D01;