Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / ada / acats / tests / c3 / c3a1001.a
blob9b05b5da254992a12d96baf221b734a04b6f6f03
1 -- C3A1001.A
2 --
3 -- Grant of Unlimited Rights
4 --
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
14 -- to do so.
16 -- DISCLAIMER
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
24 --*
26 -- OBJECTIVE:
27 -- Check that the full type completing a type with no discriminant part
28 -- or an unknown discriminant part may have explicitly declared or
29 -- inherited discriminants.
30 -- Check for cases where the types are records and protected types.
32 -- TEST DESCRIPTION:
33 -- Declare two groups of incomplete types: one group with no discriminant
34 -- part and one group with unknown discriminant part. Both groups of
35 -- incomplete types are completed with both explicit and inherited
36 -- discriminants. Discriminants for record and protected types are
37 -- declared with default and non default values.
38 -- In the main program, verify that objects of both groups of incomplete
39 -- types can be created by default values or by assignments.
42 -- CHANGE HISTORY:
43 -- 11 Oct 95 SAIC Initial prerelease version.
44 -- 11 Nov 96 SAIC Revised for version 2.1.
46 --!
48 package C3A1001_0 is
50 type Incomplete1 (<>); -- unknown discriminant
52 type Incomplete2; -- no discriminant
54 type Incomplete3 (<>); -- unknown discriminant
56 type Incomplete4; -- no discriminant
58 type Incomplete5 (<>); -- unknown discriminant
60 type Incomplete6; -- no discriminant
62 type Incomplete8; -- no discriminant
64 subtype Small_Int is Integer range 1 .. 10;
66 type Enu_Type is (M, F);
68 type Incomplete1 (Disc : Enu_Type) is -- unknown discriminant/
69 record -- explicit discriminant
70 case Disc is
71 when M => MInteger : Small_Int := 3;
72 when F => FInteger : Small_Int := 8;
73 end case;
74 end record;
76 type Incomplete2 (Disc : Small_Int := 8) is -- no discriminant/
77 record -- explicit discriminant
78 ID : String (1 .. Disc) := "Plymouth";
79 end record;
81 type Incomplete3 is new Incomplete2; -- unknown discriminant/
82 -- inherited discriminant
84 type Incomplete4 is new Incomplete2; -- no discriminant/
85 -- inherited discriminant
87 protected type Incomplete5 -- unknown discriminant/
88 (Disc : Enu_Type) is -- explicit discriminant
89 function Get_Priv_Val return Enu_Type;
90 private
91 Enu_Obj : Enu_Type := Disc;
92 end Incomplete5;
94 protected type Incomplete6 -- no discriminant/
95 (Disc : Small_Int := 1) is -- explicit discriminant
96 function Get_Priv_Val return Small_Int; -- with default
97 private
98 Num : Small_Int := Disc;
99 end Incomplete6;
101 type Incomplete8 (Disc : Small_Int) is -- no discriminant/
102 record -- explicit discriminant
103 Str : String (1 .. Disc); -- no default
104 end record;
106 type Incomplete9 is new Incomplete8;
108 function Return_String (S : String) return String;
110 end C3A1001_0;
112 --==================================================================--
114 with Report;
116 package body C3A1001_0 is
118 protected body Incomplete5 is
120 function Get_Priv_Val return Enu_Type is
121 begin
122 return Enu_Obj;
123 end Get_Priv_Val;
125 end Incomplete5;
127 ----------------------------------------------------------------------
128 protected body Incomplete6 is
130 function Get_Priv_Val return Small_Int is
131 begin
132 return Num;
133 end Get_Priv_Val;
135 end Incomplete6;
137 ----------------------------------------------------------------------
138 function Return_String (S : String) return String is
139 begin
140 if Report.Ident_Bool(True) = True then
141 return S;
142 end if;
144 return S;
145 end Return_String;
147 end C3A1001_0;
149 --==================================================================--
151 with Report;
153 with C3A1001_0;
154 use C3A1001_0;
156 procedure C3A1001 is
158 -- Discriminant value comes from default.
160 Incomplete2_Obj_1 : Incomplete2;
162 Incomplete4_Obj_1 : Incomplete4;
164 Incomplete6_Obj_1 : Incomplete6;
166 -- Discriminant value comes from explicit constraint.
168 Incomplete1_Obj_1 : Incomplete1 (F);
170 Incomplete5_Obj_1 : Incomplete5 (M);
172 Incomplete6_Obj_2 : Incomplete6 (2);
174 -- Discriminant value comes from assignment.
176 Incomplete3_Obj_1 : Incomplete3 := (Disc => 6, ID => "Sentra");
178 Incomplete1_Obj_2 : Incomplete1 := (Disc => M, MInteger => 9);
180 Incomplete2_Obj_2 : Incomplete2 := (Disc => 5, ID => "Buick");
182 begin
184 Report.Test ("C3A1001", "Check that the full type completing a type " &
185 "with no discriminant part or an unknown discriminant " &
186 "part may have explicitly declared or inherited " &
187 "discriminants. Check for cases where the types are " &
188 "records and protected types");
190 -- Check the initial values.
192 if (Incomplete2_Obj_1.Disc /= 8) or
193 (Incomplete2_Obj_1.ID /= "Plymouth") then
194 Report.Failed ("Wrong initial values for Incomplete2_Obj_1");
195 end if;
197 if (Incomplete4_Obj_1.Disc /= 8) or
198 (Incomplete4_Obj_1.ID /= "Plymouth") then
199 Report.Failed ("Wrong initial values for Incomplete4_Obj_1");
200 end if;
202 if (Incomplete6_Obj_1.Disc /= 1) or
203 (Incomplete6_Obj_1.Get_Priv_Val /= 1) then
204 Report.Failed ("Wrong initial value for Incomplete6_Obj_1");
205 end if;
207 -- Check the explicit values.
209 if (Incomplete1_Obj_1.Disc /= F) or
210 (Incomplete1_Obj_1.FInteger /= 8) then
211 Report.Failed ("Wrong values for Incomplete1_Obj_1");
212 end if;
214 if (Incomplete5_Obj_1.Disc /= M) or
215 (Incomplete5_Obj_1.Get_Priv_Val /= M) then
216 Report.Failed ("Wrong value for Incomplete5_Obj_1");
217 end if;
219 if (Incomplete6_Obj_2.Disc /= 2) or
220 (Incomplete6_Obj_2.Get_Priv_Val /= 2) then
221 Report.Failed ("Wrong value for Incomplete6_Obj_2");
222 end if;
224 -- Check the assigned values.
226 if (Incomplete3_Obj_1.Disc /= 6) or
227 (Incomplete3_Obj_1.ID /= "Sentra") then
228 Report.Failed ("Wrong values for Incomplete3_Obj_1");
229 end if;
231 if (Incomplete1_Obj_2.Disc /= M) or
232 (Incomplete1_Obj_2.MInteger /= 9) then
233 Report.Failed ("Wrong values for Incomplete1_Obj_2");
234 end if;
236 if (Incomplete2_Obj_2.Disc /= 5) or
237 (Incomplete2_Obj_2.ID /= "Buick") then
238 Report.Failed ("Wrong values for Incomplete2_Obj_2");
239 end if;
241 -- Make sure that assignments work without problems.
243 Incomplete1_Obj_1.FInteger := 1;
245 -- Avoid optimization (dead variable removal of FInteger):
247 if Incomplete1_Obj_1.FInteger /= Report.Ident_Int(1)
248 then
249 Report.Failed ("Wrong value stored in Incomplete1_Obj_1.FInteger");
250 end if;
252 Incomplete2_Obj_1.ID := Return_String ("12345678");
254 -- Avoid optimization (dead variable removal of ID)
256 if Incomplete2_Obj_1.ID /= Return_String ("12345678")
257 then
258 Report.Failed ("Wrong values for Incomplete8_Obj_1.ID");
259 end if;
261 Incomplete4_Obj_1.ID := Return_String ("87654321");
263 -- Avoid optimization (dead variable removal of ID)
265 if Incomplete4_Obj_1.ID /= Return_String ("87654321")
266 then
267 Report.Failed ("Wrong values for Incomplete4_Obj_1.ID");
268 end if;
271 Test1:
272 declare
274 Incomplete8_Obj_1 : Incomplete8 (10);
276 begin
277 Incomplete8_Obj_1.Str := "Merry Xmas";
279 -- Avoid optimization (dead variable removal of Str):
281 if Return_String (Incomplete8_Obj_1.Str) /= "Merry Xmas"
282 then
283 Report.Failed ("Wrong values for Incomplete8_Obj_1.Str");
284 end if;
286 exception
287 when Constraint_Error =>
288 Report.Failed ("Constraint_Error raised in Incomplete8_Obj_1");
290 end Test1;
292 Test2:
293 declare
295 Incomplete8_Obj_2 : Incomplete8 (5);
297 begin
298 Incomplete8_Obj_2.Str := "Happy";
300 -- Avoid optimization (dead variable removal of Str):
302 if Return_String (Incomplete8_Obj_2.Str) /= "Happy"
303 then
304 Report.Failed ("Wrong values for Incomplete8_Obj_1.Str");
305 end if;
307 exception
308 when Constraint_Error =>
309 Report.Failed ("Constraint_Error raised in Incomplete8_Obj_2");
311 end Test2;
313 Report.Result;
315 end C3A1001;