annotate gcc/testsuite/ada/acats/tests/c7/c760007.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 -- C760007.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 Adjust is called for the execution of a return
kono
parents:
diff changeset
28 -- statement for a function returning a result of a (non-limited)
kono
parents:
diff changeset
29 -- controlled type.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- Check that Adjust is called when evaluating an aggregate
kono
parents:
diff changeset
32 -- component association for a controlled component.
kono
parents:
diff changeset
33 --
kono
parents:
diff changeset
34 -- Check that Adjust is called for the assignment of the ancestor
kono
parents:
diff changeset
35 -- expression of an extension aggregate when the type of the
kono
parents:
diff changeset
36 -- aggregate is controlled.
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- TEST DESCRIPTION:
kono
parents:
diff changeset
39 -- A type is derived from Ada.Finalization.Controlled; the dispatching
kono
parents:
diff changeset
40 -- procedure Adjust is defined for the new type. Structures and
kono
parents:
diff changeset
41 -- subprograms to model the test objectives are used to check that
kono
parents:
diff changeset
42 -- Adjust is called at the right time. For the sake of simplicity,
kono
parents:
diff changeset
43 -- globally accessible data is used to check that the calls are made.
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 -- CHANGE HISTORY:
kono
parents:
diff changeset
47 -- 06 DEC 94 SAIC ACVC 2.0
kono
parents:
diff changeset
48 -- 14 OCT 95 SAIC Update and repair for ACVC 2.0.1
kono
parents:
diff changeset
49 -- 05 APR 96 SAIC Add RM reference
kono
parents:
diff changeset
50 -- 06 NOV 96 SAIC Reduce adjust requirement
kono
parents:
diff changeset
51 -- 25 NOV 97 EDS Allowed zero calls to adjust at line 144
kono
parents:
diff changeset
52 --!
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 ---------------------------------------------------------------- C760007_0
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 with Ada.Finalization;
kono
parents:
diff changeset
57 package C760007_0 is
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 type Controlled is new Ada.Finalization.Controlled with record
kono
parents:
diff changeset
60 TC_ID : Natural := Natural'Last;
kono
parents:
diff changeset
61 end record;
kono
parents:
diff changeset
62 procedure Adjust( Object: in out Controlled );
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 type Structure is record
kono
parents:
diff changeset
65 Controlled_Component : Controlled;
kono
parents:
diff changeset
66 end record;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 type Child is new Controlled with record
kono
parents:
diff changeset
69 TC_XX : Natural := Natural'Last;
kono
parents:
diff changeset
70 end record;
kono
parents:
diff changeset
71 procedure Adjust( Object: in out Child );
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 Adjust_Count : Natural := 0;
kono
parents:
diff changeset
74 Child_Adjust_Count : Natural := 0;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 end C760007_0;
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 package body C760007_0 is
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure Adjust( Object: in out Controlled ) is
kono
parents:
diff changeset
81 begin
kono
parents:
diff changeset
82 Adjust_Count := Adjust_Count +1;
kono
parents:
diff changeset
83 end Adjust;
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 procedure Adjust( Object: in out Child ) is
kono
parents:
diff changeset
86 begin
kono
parents:
diff changeset
87 Child_Adjust_Count := Child_Adjust_Count +1;
kono
parents:
diff changeset
88 end Adjust;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 end C760007_0;
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 ------------------------------------------------------------------ C760007
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 with Report;
kono
parents:
diff changeset
95 with C760007_0;
kono
parents:
diff changeset
96 procedure C760007 is
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 procedure Check_Adjust_Count(Message: String;
kono
parents:
diff changeset
99 Min: Natural := 1;
kono
parents:
diff changeset
100 Max: Natural := 2) is
kono
parents:
diff changeset
101 begin
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 -- in order to allow for the anonymous objects referred to in
kono
parents:
diff changeset
104 -- the reference manual, the check for calls to Adjust must be
kono
parents:
diff changeset
105 -- in a range. This number must then be further adjusted
kono
parents:
diff changeset
106 -- to allow for the optimization that does not call for an adjust
kono
parents:
diff changeset
107 -- of an aggregate initial value built directly in the object
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 if C760007_0.Adjust_Count not in Min..Max then
kono
parents:
diff changeset
110 Report.Failed(Message
kono
parents:
diff changeset
111 & " = " & Natural'Image(C760007_0.Adjust_Count));
kono
parents:
diff changeset
112 end if;
kono
parents:
diff changeset
113 C760007_0.Adjust_Count := 0;
kono
parents:
diff changeset
114 end Check_Adjust_Count;
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 procedure Check_Child_Adjust_Count(Message: String;
kono
parents:
diff changeset
117 Min: Natural := 1;
kono
parents:
diff changeset
118 Max: Natural := 2) is
kono
parents:
diff changeset
119 begin
kono
parents:
diff changeset
120 -- ditto above
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 if C760007_0.Child_Adjust_Count not in Min..Max then
kono
parents:
diff changeset
123 Report.Failed(Message
kono
parents:
diff changeset
124 & " = " & Natural'Image(C760007_0.Child_Adjust_Count));
kono
parents:
diff changeset
125 end if;
kono
parents:
diff changeset
126 C760007_0.Child_Adjust_Count := 0;
kono
parents:
diff changeset
127 end Check_Child_Adjust_Count;
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 Object : C760007_0.Controlled;
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 -- Check that Adjust is called for the execution of a return
kono
parents:
diff changeset
132 -- statement for a function returning a result of a (non-limited)
kono
parents:
diff changeset
133 -- controlled type or a result of a noncontrolled type with
kono
parents:
diff changeset
134 -- controlled components.
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 procedure Subtest_1 is
kono
parents:
diff changeset
137 function Create return C760007_0.Controlled is
kono
parents:
diff changeset
138 New_Object : C760007_0.Controlled;
kono
parents:
diff changeset
139 begin
kono
parents:
diff changeset
140 return New_Object;
kono
parents:
diff changeset
141 end Create;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 procedure Examine( Thing : in C760007_0.Controlled ) is
kono
parents:
diff changeset
144 begin
kono
parents:
diff changeset
145 Check_Adjust_Count("Function call passed as parameter",0);
kono
parents:
diff changeset
146 end Examine;
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 begin
kono
parents:
diff changeset
149 -- this assignment must call Adjust:
kono
parents:
diff changeset
150 -- 1: on the value resulting from the function
kono
parents:
diff changeset
151 -- ** unless this is optimized out by building the result directly
kono
parents:
diff changeset
152 -- in the target object.
kono
parents:
diff changeset
153 -- 2: on Object once it's been assigned
kono
parents:
diff changeset
154 -- may call adjust
kono
parents:
diff changeset
155 -- 1: for a anonymous object created in the evaluation of the function
kono
parents:
diff changeset
156 -- 2: for a anonymous object created in the assignment operation
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 Object := Create;
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 Check_Adjust_Count("Function call",1,4);
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 Examine( Create );
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 end Subtest_1;
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 -- Check that Adjust is called when evaluating an aggregate
kono
parents:
diff changeset
167 -- component association for a controlled component.
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 procedure Subtest_2 is
kono
parents:
diff changeset
170 S : C760007_0.Structure;
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 procedure Examine( Thing : in C760007_0.Structure ) is
kono
parents:
diff changeset
173 begin
kono
parents:
diff changeset
174 Check_Adjust_Count("Aggregate passed as parameter");
kono
parents:
diff changeset
175 end Examine;
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 begin
kono
parents:
diff changeset
178 -- this assignment must call Adjust:
kono
parents:
diff changeset
179 -- 1: on the value resulting from the aggregate
kono
parents:
diff changeset
180 -- ** unless this is optimized out by building the result directly
kono
parents:
diff changeset
181 -- in the target object.
kono
parents:
diff changeset
182 -- 2: on Object once it's been assigned
kono
parents:
diff changeset
183 -- may call adjust
kono
parents:
diff changeset
184 -- 1: for a anonymous object created in the evaluation of the aggregate
kono
parents:
diff changeset
185 -- 2: for a anonymous object created in the assignment operation
kono
parents:
diff changeset
186 S := ( Controlled_Component => Object );
kono
parents:
diff changeset
187 Check_Adjust_Count("Aggregate and Assignment", 1, 4);
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 Examine( C760007_0.Structure'(Controlled_Component => Object) );
kono
parents:
diff changeset
190 end Subtest_2;
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 -- Check that Adjust is called for the assignment of the ancestor
kono
parents:
diff changeset
193 -- expression of an extension aggregate when the type of the
kono
parents:
diff changeset
194 -- aggregate is controlled.
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 procedure Subtest_3 is
kono
parents:
diff changeset
197 Bambino : C760007_0.Child;
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 procedure Examine( Thing : in C760007_0.Child ) is
kono
parents:
diff changeset
200 begin
kono
parents:
diff changeset
201 Check_Adjust_Count("Extension aggregate as parameter (ancestor)", 0, 2);
kono
parents:
diff changeset
202 Check_Child_Adjust_Count("Extension aggregate as parameter", 0, 4);
kono
parents:
diff changeset
203 end Examine;
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 begin
kono
parents:
diff changeset
206 -- implementation permissions make all of the following calls to adjust
kono
parents:
diff changeset
207 -- optional:
kono
parents:
diff changeset
208 -- these assignments may call Adjust:
kono
parents:
diff changeset
209 -- 1: on the value resulting from the aggregate
kono
parents:
diff changeset
210 -- 2: on Object once it's been assigned
kono
parents:
diff changeset
211 -- 3: for a anonymous object created in the evaluation of the aggregate
kono
parents:
diff changeset
212 -- 4: for a anonymous object created in the assignment operation
kono
parents:
diff changeset
213 Bambino := ( Object with TC_XX => 10 );
kono
parents:
diff changeset
214 Check_Adjust_Count("Ancestor (expression) part of aggregate", 0, 2);
kono
parents:
diff changeset
215 Check_Child_Adjust_Count("Child aggregate assignment 1", 0, 4 );
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 Bambino := ( C760007_0.Controlled with TC_XX => 11 );
kono
parents:
diff changeset
218 Check_Adjust_Count("Ancestor (subtype_mark) part of aggregate", 0, 2);
kono
parents:
diff changeset
219 Check_Child_Adjust_Count("Child aggregate assignment 2", 0, 4 );
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 Examine( ( Object with TC_XX => 21 ) );
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 Examine( ( C760007_0.Controlled with TC_XX => 37 ) );
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 end Subtest_3;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 begin -- Main test procedure.
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 Report.Test ("C760007", "Check that Adjust is called for the " &
kono
parents:
diff changeset
230 "execution of a return statement for a " &
kono
parents:
diff changeset
231 "function returning a result containing a " &
kono
parents:
diff changeset
232 "controlled type. Check that Adjust is " &
kono
parents:
diff changeset
233 "called when evaluating an aggregate " &
kono
parents:
diff changeset
234 "component association for a controlled " &
kono
parents:
diff changeset
235 "component. " &
kono
parents:
diff changeset
236 "Check that Adjust is called for the " &
kono
parents:
diff changeset
237 "assignment of the ancestor expression of an " &
kono
parents:
diff changeset
238 "extension aggregate when the type of the " &
kono
parents:
diff changeset
239 "aggregate is controlled" );
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 Subtest_1;
kono
parents:
diff changeset
242 Subtest_2;
kono
parents:
diff changeset
243 Subtest_3;
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 Report.Result;
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 end C760007;