annotate gcc/testsuite/ada/acats/tests/cc/cc54002.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 -- CC54002.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 a general access-to-variable type may be passed as an
kono
parents:
diff changeset
28 -- actual to a generic formal general access-to-variable type. Check that
kono
parents:
diff changeset
29 -- designated objects may be read and updated through the access value.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- TEST DESCRIPTION:
kono
parents:
diff changeset
32 -- The generic implements a List of access objects as an array, which
kono
parents:
diff changeset
33 -- is itself a component of a record. The designated type of the formal
kono
parents:
diff changeset
34 -- access type is a formal private type declared in the same generic
kono
parents:
diff changeset
35 -- formal part.
kono
parents:
diff changeset
36 --
kono
parents:
diff changeset
37 -- The access objects to be placed in the List are created both
kono
parents:
diff changeset
38 -- statically and dynamically, utilizing allocators and the 'Access
kono
parents:
diff changeset
39 -- attribute.
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 -- CHANGE HISTORY:
kono
parents:
diff changeset
43 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
44 -- 10 Apr 96 SAIC ACVC 2.1: Added pragma Elaborate to context clause
kono
parents:
diff changeset
45 -- preceding CC54002_1.
kono
parents:
diff changeset
46 --
kono
parents:
diff changeset
47 --!
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 generic
kono
parents:
diff changeset
50 Size : in Positive;
kono
parents:
diff changeset
51 type Element_Type (<>) is private;
kono
parents:
diff changeset
52 type Element_Ptr is access all Element_Type;
kono
parents:
diff changeset
53 package CC54002_0 is -- Generic list of pointers.
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 subtype Index is Positive range 1 .. (Size + 1);
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 type List_Array is array (Index) of Element_Ptr;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 type List_Type is record
kono
parents:
diff changeset
60 Elements : List_Array;
kono
parents:
diff changeset
61 Next : Index := 1; -- Next available "slot" in list.
kono
parents:
diff changeset
62 end record;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 procedure Put (List : in out List_Type;
kono
parents:
diff changeset
66 Elem_Ptr : in Element_Ptr;
kono
parents:
diff changeset
67 Location : in Index);
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 procedure Get (List : in out List_Type;
kono
parents:
diff changeset
70 Elem_Ptr : out Element_Ptr;
kono
parents:
diff changeset
71 Location : in Index);
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 -- ... Other operations.
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 end CC54002_0;
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 --===================================================================--
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 package body CC54002_0 is
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 procedure Put (List : in out List_Type;
kono
parents:
diff changeset
84 Elem_Ptr : in Element_Ptr;
kono
parents:
diff changeset
85 Location : in Index) is
kono
parents:
diff changeset
86 begin
kono
parents:
diff changeset
87 List.Elements(Location) := Elem_Ptr;
kono
parents:
diff changeset
88 end Put;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 procedure Get (List : in out List_Type;
kono
parents:
diff changeset
92 Elem_Ptr : out Element_Ptr;
kono
parents:
diff changeset
93 Location : in Index) is
kono
parents:
diff changeset
94 begin -- Artificial: no provision for getting "empty" element.
kono
parents:
diff changeset
95 Elem_Ptr := List.Elements(Location);
kono
parents:
diff changeset
96 end Get;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 end CC54002_0;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 --===================================================================--
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 with CC54002_0; -- Generic List of pointers.
kono
parents:
diff changeset
105 pragma Elaborate (CC54002_0);
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 package CC54002_1 is
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 subtype Lengths is Natural range 0 .. 50;
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 type Subscriber (NLen, ALen: Lengths := 50) is record
kono
parents:
diff changeset
112 Name : String(1 .. NLen);
kono
parents:
diff changeset
113 Address : String(1 .. ALen);
kono
parents:
diff changeset
114 -- ... Other components.
kono
parents:
diff changeset
115 end record;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 type Subscriber_Ptr is access all Subscriber; -- General access-to-
kono
parents:
diff changeset
118 -- variable type.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 package District_Subscription_Lists is new CC54002_0
kono
parents:
diff changeset
121 (Element_Type => Subscriber,
kono
parents:
diff changeset
122 Element_Ptr => Subscriber_Ptr,
kono
parents:
diff changeset
123 Size => 100);
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 District_01_Subscribers : District_Subscription_Lists.List_Type;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 New_Subscriber_01 : aliased CC54002_1.Subscriber :=
kono
parents:
diff changeset
129 (12, 23, "Brown, Silas", "King's Pyland, Dartmoor");
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 New_Subscriber_02 : aliased CC54002_1.Subscriber :=
kono
parents:
diff changeset
132 (16, 23, "Hatherly, Victor", "16A Victoria St. London");
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 end CC54002_1;
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 -- No body for CC54002_1.
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 --===================================================================--
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 with CC54002_1;
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 with Report;
kono
parents:
diff changeset
145 procedure CC54002 is
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 Mod_Subscriber_01 : constant CC54002_1.Subscriber :=
kono
parents:
diff changeset
148 (12, 23, "Brown, Silas", "Mapleton, Dartmoor ");
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 TC_Actual_01, TC_Actual_02 : CC54002_1.Subscriber_Ptr;
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 use type CC54002_1.Subscriber; -- "/=" directly visible.
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 begin
kono
parents:
diff changeset
156 Report.Test ("CC54002", "Check that a general access-to-variable type " &
kono
parents:
diff changeset
157 "may be passed as an actual to a generic formal " &
kono
parents:
diff changeset
158 "access-to-variable type");
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 -- Add elements to the list:
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 CC54002_1.District_Subscription_Lists.Put -- Element created statically.
kono
parents:
diff changeset
164 (List => CC54002_1.District_01_Subscribers,
kono
parents:
diff changeset
165 Elem_Ptr => CC54002_1.New_Subscriber_01'Access,
kono
parents:
diff changeset
166 Location => 1);
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 CC54002_1.District_Subscription_Lists.Put -- Element created dynamically.
kono
parents:
diff changeset
169 (List => CC54002_1.District_01_Subscribers,
kono
parents:
diff changeset
170 Elem_Ptr => new CC54002_1.Subscriber'(CC54002_1.New_Subscriber_02),
kono
parents:
diff changeset
171 Location => 2);
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 -- Manipulation of the objects on the list is performed below directly
kono
parents:
diff changeset
175 -- through the access objects. Although such manipulation is artificial
kono
parents:
diff changeset
176 -- from the perspective of this usage model, it is not artificial in
kono
parents:
diff changeset
177 -- general and is necessary in order to test the objective.
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 -- Modify the first list element through the access object:
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 CC54002_1.District_01_Subscribers.Elements(1).Address := -- Update
kono
parents:
diff changeset
183 "Mapleton, Dartmoor "; -- Implicit dereference. -- through the
kono
parents:
diff changeset
184 -- access
kono
parents:
diff changeset
185 -- object.
kono
parents:
diff changeset
186 -- Retrieve elements of the list:
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 CC54002_1.District_Subscription_Lists.Get
kono
parents:
diff changeset
189 (CC54002_1.District_01_Subscribers,
kono
parents:
diff changeset
190 TC_Actual_01,
kono
parents:
diff changeset
191 1);
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 CC54002_1.District_Subscription_Lists.Get
kono
parents:
diff changeset
194 (CC54002_1.District_01_Subscribers,
kono
parents:
diff changeset
195 TC_Actual_02,
kono
parents:
diff changeset
196 2);
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 -- Verify list contents in two ways: 1st verify the directly-dereferenced
kono
parents:
diff changeset
199 -- access objects against the dereferenced access objects returned by Get;
kono
parents:
diff changeset
200 -- 2nd verify them against objects the expected values:
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 -- Read
kono
parents:
diff changeset
203 -- through the
kono
parents:
diff changeset
204 -- access
kono
parents:
diff changeset
205 -- objects.
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 if CC54002_1.District_01_Subscribers.Elements(1).all /= TC_Actual_01.all
kono
parents:
diff changeset
208 or else
kono
parents:
diff changeset
209 CC54002_1.District_01_Subscribers.Elements(2).all /= TC_Actual_02.all
kono
parents:
diff changeset
210 then
kono
parents:
diff changeset
211 Report.Failed ("Wrong results returned by Get");
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 elsif CC54002_1.District_01_Subscribers.Elements(1).all /=
kono
parents:
diff changeset
214 Mod_Subscriber_01
kono
parents:
diff changeset
215 or
kono
parents:
diff changeset
216 CC54002_1.District_01_Subscribers.Elements(2).all /=
kono
parents:
diff changeset
217 CC54002_1.New_Subscriber_02
kono
parents:
diff changeset
218 then
kono
parents:
diff changeset
219 Report.Failed ("List elements do not have expected values");
kono
parents:
diff changeset
220 end if;
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 Report.Result;
kono
parents:
diff changeset
223 end CC54002;