annotate gcc/testsuite/ada/acats/tests/cc/cc51006.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 -- CC51006.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 primitive
kono
parents:
diff changeset
28 -- subprogram of a formal (nontagged) derived type declares a view of
kono
parents:
diff changeset
29 -- the corresponding primitive subprogram of the ancestor type, even if
kono
parents:
diff changeset
30 -- the subprogram has been overridden for the actual type. Check that for
kono
parents:
diff changeset
31 -- a formal derived type with no discriminant part, if the ancestor
kono
parents:
diff changeset
32 -- subtype is an unconstrained scalar subtype then the actual may be
kono
parents:
diff changeset
33 -- either constrained or unconstrained.
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- TEST DESCRIPTION:
kono
parents:
diff changeset
36 -- The formal derived type has no discriminant part, but the ancestor
kono
parents:
diff changeset
37 -- subtype is unconstrained, making the formal type unconstrained. Since
kono
parents:
diff changeset
38 -- the ancestor subtype is a scalar subtype (not an access or composite
kono
parents:
diff changeset
39 -- subtype), the actual may be either constrained or unconstrained.
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- Declare a root type of a class as an unconstrained scalar (use floating
kono
parents:
diff changeset
42 -- point). Declare a primitive subprogram of the root type. Declare a
kono
parents:
diff changeset
43 -- generic package which has a formal derived type with the scalar root
kono
parents:
diff changeset
44 -- type as ancestor. Inside the generic, declare an operation which calls
kono
parents:
diff changeset
45 -- the ancestor type's primitive subprogram. Derive both constrained and
kono
parents:
diff changeset
46 -- unconstrained types from the root type and override the primitive
kono
parents:
diff changeset
47 -- subprogram for each. Declare a constrained subtype of the unconstrained
kono
parents:
diff changeset
48 -- derivative. Instantiate the generic package for the derived types and
kono
parents:
diff changeset
49 -- the subtype and call the "generic" operation for each one. Confirm that
kono
parents:
diff changeset
50 -- in all cases the root type's implementation of the primitive
kono
parents:
diff changeset
51 -- subprogram is called.
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 --
kono
parents:
diff changeset
54 -- CHANGE HISTORY:
kono
parents:
diff changeset
55 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
56 --
kono
parents:
diff changeset
57 --!
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 package CC51006_0 is -- Weight class.
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 type Weight_Type is digits 3; -- Root type of class (unconstrained).
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 function Weight_To_String (Wt : Weight_Type) return String;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 -- ... Other operations.
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 end CC51006_0;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 --==================================================================--
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 package body CC51006_0 is
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 -- The implementations of the operations below are purely artificial; the
kono
parents:
diff changeset
76 -- validity of their implementations in the context of the abstraction is
kono
parents:
diff changeset
77 -- irrelevant to the feature being tested.
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 function Weight_To_String (Wt : Weight_Type) return String is
kono
parents:
diff changeset
80 begin
kono
parents:
diff changeset
81 if Wt > 0.0 then -- Always true for this test.
kono
parents:
diff changeset
82 return ("Root type's implementation called");
kono
parents:
diff changeset
83 else
kono
parents:
diff changeset
84 return ("Unexpected result ");
kono
parents:
diff changeset
85 end if;
kono
parents:
diff changeset
86 end Weight_To_String;
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 end CC51006_0;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 --==================================================================--
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 with CC51006_0; -- Weight class.
kono
parents:
diff changeset
95 generic -- Generic weight operations.
kono
parents:
diff changeset
96 type Weight is new CC51006_0.Weight_Type;
kono
parents:
diff changeset
97 package CC51006_1 is
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 procedure Output_Weight (Wt : in Weight; TC_Return : out String);
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 -- ... Other operations.
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 end CC51006_1;
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 --==================================================================--
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 package body CC51006_1 is
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 -- The implementation of this procedure is purely artificial, and contains
kono
parents:
diff changeset
113 -- an artificial parameter for testing purposes: the procedure returns the
kono
parents:
diff changeset
114 -- weight string to the caller.
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 procedure Output_Weight (Wt : in Weight; TC_Return : out String) is
kono
parents:
diff changeset
117 begin
kono
parents:
diff changeset
118 TC_Return := Weight_To_String (Wt); -- Should always call root type's
kono
parents:
diff changeset
119 end Output_Weight; -- implementation.
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 end CC51006_1;
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 --==================================================================--
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 with CC51006_0; -- Weight class.
kono
parents:
diff changeset
129 use CC51006_0;
kono
parents:
diff changeset
130 package CC51006_2 is -- Extensions to weight class.
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 type Grams is new Weight_Type; -- Unconstrained
kono
parents:
diff changeset
133 -- derivative.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 function Weight_To_String (Wt : Grams) return String; -- Overrides root
kono
parents:
diff changeset
136 -- type's operation.
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 subtype Milligrams is Grams -- Constrained
kono
parents:
diff changeset
139 range 0.0 .. 0.999; -- subtype (of der.).
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 type Pounds is new Weight_Type -- Constrained
kono
parents:
diff changeset
142 range 0.0 .. 500.0; -- derivative.
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 function Weight_To_String (Wt : Pounds) return String; -- Overrides root
kono
parents:
diff changeset
145 -- type's operation.
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 end CC51006_2;
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
kono
parents:
diff changeset
153 package body CC51006_2 is
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 -- The implementations of the operations below are purely artificial; the
kono
parents:
diff changeset
156 -- validity of their implementations in the context of the abstraction is
kono
parents:
diff changeset
157 -- irrelevant to the feature being tested.
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 function Weight_To_String (Wt : Grams) return String is
kono
parents:
diff changeset
160 begin
kono
parents:
diff changeset
161 return ("GRAMS: Should never be called ");
kono
parents:
diff changeset
162 end Weight_To_String;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 function Weight_To_String (Wt : Pounds) return String is
kono
parents:
diff changeset
166 begin
kono
parents:
diff changeset
167 return ("POUNDS: Should never be called ");
kono
parents:
diff changeset
168 end Weight_To_String;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 end CC51006_2;
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 --==================================================================--
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 with CC51006_1; -- Generic weight operations.
kono
parents:
diff changeset
177 with CC51006_2; -- Extensions to weight class.
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 with Report;
kono
parents:
diff changeset
180 procedure CC51006 is
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 package Metric_Wts_G is new CC51006_1 (CC51006_2.Grams); -- Unconstr.
kono
parents:
diff changeset
183 package Metric_Wts_MG is new CC51006_1 (CC51006_2.Milligrams); -- Constr.
kono
parents:
diff changeset
184 package US_Wts is new CC51006_1 (CC51006_2.Pounds); -- Constr.
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 Gms : CC51006_2.Grams := 113.451;
kono
parents:
diff changeset
187 Mgm : CC51006_2.Milligrams := 0.549;
kono
parents:
diff changeset
188 Lbs : CC51006_2.Pounds := 24.52;
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 subtype TC_Buffers is String (1 .. 33);
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 TC_Expected : constant TC_Buffers := "Root type's implementation called";
kono
parents:
diff changeset
194 TC_Buffer : TC_Buffers;
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 begin
kono
parents:
diff changeset
197 Report.Test ("CC51006", "Check that, in an instance, each implicit " &
kono
parents:
diff changeset
198 "declaration of a primitive subprogram of a formal " &
kono
parents:
diff changeset
199 "(nontagged) type declares a view of the corresponding " &
kono
parents:
diff changeset
200 "primitive subprogram of the ancestor type");
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 Metric_Wts_G.Output_Weight (Gms, TC_Buffer);
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 if TC_Buffer /= TC_Expected then
kono
parents:
diff changeset
206 Report.Failed ("Root operation not called for unconstrained derivative");
kono
parents:
diff changeset
207 end if;
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 Metric_Wts_MG.Output_Weight (Mgm, TC_Buffer);
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 if TC_Buffer /= TC_Expected then
kono
parents:
diff changeset
213 Report.Failed ("Root operation not called for constrained subtype");
kono
parents:
diff changeset
214 end if;
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 US_Wts.Output_Weight (Lbs, TC_Buffer);
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 if TC_Buffer /= TC_Expected then
kono
parents:
diff changeset
220 Report.Failed ("Root operation not called for constrained derivative");
kono
parents:
diff changeset
221 end if;
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 Report.Result;
kono
parents:
diff changeset
224 end CC51006;