summaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats/tests/c4/c432001.a
blob: dab75b388f58b96caad0f38f7981cad7a331e230 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
-- C432001.A
--
--                             Grant of Unlimited Rights
--
--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained 
--     unlimited rights in the software and documentation contained herein.
--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making 
--     this public release, the Government intends to confer upon all 
--     recipients unlimited rights  equal to those held by the Government.  
--     These rights include rights to use, duplicate, release or disclose the 
--     released technical data and computer software in whole or in part, in 
--     any manner and for any purpose whatsoever, and to have or permit others 
--     to do so.
--
--                                    DISCLAIMER
--
--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED 
--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE 
--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
--     PARTICULAR PURPOSE OF SAID MATERIAL.
--*
--
-- OBJECTIVE:
--
--      Check that extension aggregates may be used to specify values
--      for types that are record extensions. Check that the
--      type of the ancestor expression may be any nonlimited type that
--      is a record extension, including private types and private
--      extensions. Check that the type for the aggregate is
--      derived from the type of the ancestor expression.
--
-- TEST DESCRIPTION:
--
--      Two progenitor nonlimited record types are declared, one
--      nonprivate and one private. Using these as parent types,
--      all possible combinations of record extensions are declared
--      (Nonprivate record extension of nonprivate type, private
--      extension of nonprivate type, nonprivate record extension of
--      private type, and private extension of private type). Finally,
--      each of these types is extended using nonprivate record
--      extensions.
--
--      Extension of private types is done in packages other than
--      the ones containing the parent declaration. This is done
--      to eliminate errors with extension of the partial view of
--      a type, which is not an objective of this test.
--
--      All components of private types and private extensions are given
--      default values. This eliminates the need for separate subprograms
--      whose sole purpose is to place a value into a private record type.
--
--      Types that have been extended are checked using an object of their
--      parent type as the ancestor expression. For those types that
--      have been extended twice, using only nonprivate record extensions,
--      a check is made using an object of their grandparent type as
--      the ancestor expression.
--      
--      For each type, a subprogram is defined which checks the contents
--      of the parameter, which is a value of the record extension.
--      Components of nonprivate record extensions are checked against
--      passed-in parameters of the component type. Components of private
--      extensions are checked to ensure that they maintain their initial
--      values.
--
--      To check that the aggregate's type is derived from its ancestor,
--      each Check subprogram in turn calls the Check subprogram for
--      its parent type. Explicit conversion is used to convert the
--      record extension to the parent type.
--
--
-- CHANGE HISTORY:
--      06 Dec 94   SAIC    ACVC 2.0
--
--!

with Report;
package C432001_0 is

   type Eras is (Precambrian, Paleozoic, Mesozoic, Cenozoic);

   type N is tagged record
      How_Long_Ago : Natural := Report.Ident_Int(1);
      Era          : Eras := Cenozoic;
   end record;

   function Check (Rec : in N;
                   N   : in Natural;
                   E   : in Eras) return Boolean;

   type P is tagged private;

   function Check (Rec : in P) return Boolean;

private

   type P is tagged record
      How_Long_Ago : Natural := Report.Ident_Int(150);
      Era          : Eras := Mesozoic;
   end record;

end C432001_0;

package body C432001_0 is

   function Check (Rec : in P) return Boolean is
   begin
      return Rec.How_Long_Ago = 150 and Rec.Era = Mesozoic;
   end Check;

   function Check (Rec : in N;
                   N   : in Natural;
                   E   : in Eras) return Boolean is
   begin
      return Rec.How_Long_Ago = N and Rec.Era = E;
   end Check;

end C432001_0;

with C432001_0;
package C432001_1 is

   type Periods is
      (Aphebian, Helikian, Hadrynian,
       Cambrian, Ordovician, Silurian, Devonian, Carboniferous, Permian,
       Triassic, Jurassic, Cretaceous,
       Tertiary, Quaternary);

   type N_N is new C432001_0.N with record
      Period : Periods := C432001_1.Quaternary;
   end record;

   function Check (Rec : in N_N;
                   N   : in Natural;
                   E   : in C432001_0.Eras;
                   P   : in Periods) return Boolean;

   type N_P is new C432001_0.N with private;

   function Check (Rec : in N_P) return Boolean;

   type P_N is new C432001_0.P with record
      Period : Periods := C432001_1.Jurassic;
   end record;

   function Check (Rec : in P_N;
                   P   : in Periods) return Boolean;

   type P_P is new C432001_0.P with private;

   function Check (Rec : in P_P) return Boolean;

   type P_P_Null is new C432001_0.P with null record;  

private

   type N_P is new C432001_0.N with record
      Period : Periods := C432001_1.Quaternary;
   end record;

   type P_P is new C432001_0.P with record
      Period : Periods := C432001_1.Jurassic;
   end record;

end C432001_1;

with Report;
package body C432001_1 is

   function Check (Rec : in N_N;
                   N   : in Natural;
                   E   : in C432001_0.Eras;
                   P   : in Periods) return Boolean is
   begin
      if not C432001_0.Check (C432001_0.N (Rec), N, E) then
         Report.Failed ("Conversion to parent type of " &
                        "nonprivate portion of " &
                        "nonprivate extension failed");
      end if;
      return Rec.Period = P;
   end Check;
   

   function Check (Rec : in N_P) return Boolean is
   begin
      if not C432001_0.Check (C432001_0.N (Rec), 1, C432001_0.Cenozoic) then
         Report.Failed ("Conversion to parent type of " &
                        "nonprivate portion of " &
                        "private extension failed");
      end if;
      return Rec.Period = C432001_1.Quaternary;
   end Check;

   function Check (Rec : in P_N;
                   P   : in Periods) return Boolean is
   begin
      if not C432001_0.Check (C432001_0.P (Rec)) then
         Report.Failed ("Conversion to parent type of " &
                        "private portion of " &
                        "nonprivate extension failed");
      end if;
      return Rec.Period = P;
   end Check;

   function Check (Rec : in P_P) return Boolean is
   begin
      if not C432001_0.Check (C432001_0.P (Rec)) then
         Report.Failed ("Conversion to parent type of " &
                        "private portion of " &
                        "private extension failed");
      end if;
      return Rec.Period = C432001_1.Jurassic;
   end Check;

end C432001_1;

with C432001_0;
with C432001_1;
package C432001_2 is

   -- All types herein are nonprivate extensions, since aggregates
   -- cannot be given for private extensions
   
   type N_N_N is new C432001_1.N_N with record
      Sample_On_Loan : Boolean;
   end record;

   function Check (Rec : in N_N_N;
                   N   : in Natural;
                   E   : in C432001_0.Eras;
                   P   : in C432001_1.Periods;
                   B   : in Boolean) return Boolean;

   type N_P_N is new C432001_1.N_P with record
      Sample_On_Loan : Boolean;
   end record;

   function Check (Rec : in N_P_N;
                   B   : Boolean) return Boolean;

   type P_N_N is new C432001_1.P_N with record
      Sample_On_Loan : Boolean;
   end record;

   function Check (Rec : in P_N_N;
                   P   : in C432001_1.Periods;
                   B   : Boolean) return Boolean;

   type P_P_N is new C432001_1.P_P with record
      Sample_On_Loan : Boolean;
   end record;

   function Check (Rec : in P_P_N;
                   B   : Boolean) return Boolean;

end C432001_2;

with Report;
package body C432001_2 is

   -- direct access to operator
   use type C432001_1.Periods;


   function Check (Rec : in N_N_N;
                   N   : in Natural;
                   E   : in C432001_0.Eras;
                   P   : in C432001_1.Periods;
                   B   : in Boolean) return Boolean is
   begin
      if not C432001_1.Check (C432001_1.N_N (Rec), N, E, P) then
         Report.Failed ("Conversion to parent " &
                        "nonprivate type extension " &
                        "failed");
      end if;
      return Rec.Sample_On_Loan = B;
   end Check;
   

   function Check (Rec : in N_P_N;
                   B   : Boolean) return Boolean is
   begin
      if not C432001_1.Check (C432001_1.N_P (Rec)) then
         Report.Failed ("Conversion to parent " &
                        "private type extension " &
                        "failed");
      end if;
      return Rec.Sample_On_Loan = B;
   end Check;

   function Check (Rec : in P_N_N;
                   P   : in C432001_1.Periods;
                   B   : Boolean) return Boolean is
   begin
      if not C432001_1.Check (C432001_1.P_N (Rec), P) then
         Report.Failed ("Conversion to parent " &
                        "nonprivate type extension " &
                        "failed");
      end if;
      return Rec.Sample_On_Loan = B;
   end Check;

   function Check (Rec : in P_P_N;
                   B   : Boolean) return Boolean is
   begin
      if not C432001_1.Check (C432001_1.P_P (Rec)) then
         Report.Failed ("Conversion to parent " &
                        "private type extension " &
                        "failed");
      end if;
      return Rec.Sample_On_Loan = B;
   end Check;

end C432001_2;


with C432001_0;
with C432001_1;
with C432001_2;
with Report;
procedure C432001 is

   N_Object : C432001_0.N := (How_Long_Ago => Report.Ident_Int(375),
                              Era          => C432001_0.Paleozoic);

   P_Object : C432001_0.P; -- default value is (150,
                           --                   C432001_0.Mesozoic)

   N_N_Object : C432001_1.N_N :=
      (N_Object with Period => C432001_1.Devonian);

   P_N_Object : C432001_1.P_N :=
      (P_Object with Period => C432001_1.Jurassic);

   N_P_Object : C432001_1.N_P; -- default is (1,
                               --             C432001_0.Cenozoic,
                               --             C432001_1.Quaternary)

   P_P_Object : C432001_1.P_P; -- default is (150,
                               --             C432001_0.Mesozoic,
                               --             C432001_1.Jurassic)

   P_P_Null_Ob:C432001_1.P_P_Null := (P_Object with null record);

   N_N_N_Object : C432001_2.N_N_N :=
      (N_N_Object with Sample_On_Loan => Report.Ident_Bool(True));

   N_P_N_Object : C432001_2.N_P_N :=
      (N_P_Object with Sample_On_Loan => Report.Ident_Bool(False));

   P_N_N_Object : C432001_2.P_N_N :=
      (P_N_Object with Sample_On_Loan => Report.Ident_Bool(True));

   P_P_N_Object : C432001_2.P_P_N :=
      (P_P_Object with Sample_On_Loan => Report.Ident_Bool(False));

   P_N_Object_2 : C432001_1.P_N := (C432001_0.P(P_N_N_Object)
                                    with C432001_1.Carboniferous);

   N_N_Object_2 : C432001_1.N_N := (C432001_0.N'(42,C432001_0.Precambrian)
                                    with C432001_1.Carboniferous);

begin

   Report.Test ("C432001", "Extension aggregates");

   -- check ultimate ancestor types

   if not C432001_0.Check (N_Object,
                           375,
                           C432001_0.Paleozoic) then
      Report.Failed ("Object of " &
                     "nonprivate type " &
                     "failed content check");
   end if;

   if not C432001_0.Check (P_Object) then
      Report.Failed ("Object of " &
                     "private type " &
                     "failed content check");
   end if;

   -- check direct type extensions

   if not C432001_1.Check (N_N_Object,
                           375,
                           C432001_0.Paleozoic,
                           C432001_1.Devonian) then
      Report.Failed ("Object of " &
                     "nonprivate extension of nonprivate type " &
                     "failed content check");
   end if;

   if not C432001_1.Check (N_P_Object) then
      Report.Failed ("Object of " &
                     "private extension of nonprivate type " &
                     "failed content check");
   end if;

   if not C432001_1.Check (P_N_Object,
                           C432001_1.Jurassic) then
      Report.Failed ("Object of " &
                     "nonprivate extension of private type " &
                     "failed content check");
   end if;

   if not C432001_1.Check (P_P_Object) then
      Report.Failed ("Object of " &
                     "private extension of private type " &
                     "failed content check");
   end if;

    if not C432001_1.Check (P_P_Null_Ob) then
      Report.Failed ("Object of " &
                     "private type " &
                     "failed content check");
   end if;


   -- check direct extensions of extensions

   if not C432001_2.Check (N_N_N_Object,
                           375,
                           C432001_0.Paleozoic,
                           C432001_1.Devonian,
                           True) then
      Report.Failed ("Object of " &
                     "nonprivate extension of nonprivate extension " &
                     "(of nonprivate parent) " &
                     "failed content check");
   end if;

   if not C432001_2.Check (N_P_N_Object, False) then
      Report.Failed ("Object of " &
                     "nonprivate extension of private extension " &
                     "(of nonprivate parent) " &
                     "failed content check");
   end if;

   if not C432001_2.Check (P_N_N_Object,
                           C432001_1.Jurassic,
                           True) then
      Report.Failed ("Object of " &
                     "nonprivate extension of nonprivate extension " &
                     "(of private parent) " &
                     "failed content check");
   end if;

   if not C432001_2.Check (P_P_N_Object, False) then
      Report.Failed ("Object of " &
                     "nonprivate extension of private extension " &
                     "(of private parent) " &
                     "failed content check");
   end if;

   -- check that the extension aggregate may specify an expression of
   -- a "grandparent" ancestor type

   -- types tested are derived through nonprivate extensions only
   -- (extension aggregates are not allowed if the path from the
   -- ancestor type wanders through a private extension)
   
   N_N_N_Object :=
      (N_Object with Period => C432001_1.Devonian,
                     Sample_On_Loan => Report.Ident_Bool(True));

   if not C432001_2.Check (N_N_N_Object,
                           375,
                           C432001_0.Paleozoic,
                           C432001_1.Devonian,
                           True) then
      Report.Failed ("Object of " &
                     "nonprivate extension " &
                     "of nonprivate ancestor " &
                     "failed content check");
   end if;

   P_N_N_Object :=
      (P_Object with Period => C432001_1.Jurassic,
                     Sample_On_Loan => Report.Ident_Bool(True));

   if not C432001_2.Check (P_N_N_Object,
                           C432001_1.Jurassic,
                           True) then
      Report.Failed ("Object of " &
                     "nonprivate extension " &
                     "of private ancestor " &
                     "failed content check");
   end if;

  -- Check additional cases
   if not C432001_1.Check (P_N_Object_2,
                           C432001_1.Carboniferous) then
      Report.Failed ("Additional Object of " &
                     "nonprivate extension of private type " &
                     "failed content check");
   end if;

   if not C432001_1.Check (N_N_Object_2,
                           42,
                           C432001_0.Precambrian,
                           C432001_1.Carboniferous) then
      Report.Failed ("Additional Object of " &
                     "nonprivate extension of nonprivate type " &
                     "failed content check");
   end if;

   Report.Result;

end C432001;