summaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats/tests/c4/c432002.a
blob: 5de821b3052e41b0dd5794a8241d6237bc3e9cc1 (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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
-- C432002.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 if an extension aggregate specifies a value for a record 
--      extension and the ancestor expression has discriminants that are
--      inherited by the record extension, then a check is made that each
--      discriminant has the value specified.
--
--      Check that if an extension aggregate specifies a value for a record 
--      extension and the ancestor expression has discriminants that are not
--      inherited by the record extension, then a check is made that each
--      such discriminant has the value specified for the corresponding
--      discriminant.
--
--      Check that the corresponding discriminant value may be specified
--      in the record component association list or in the derived type
--      definition for an ancestor.
--
--      Check the case of ancestors that are several generations removed.
--      Check the case where the value of the discriminant(s) in question
--      is supplied several generations removed.
--
--      Check the case of multiple discriminants.
--
--      Check that Constraint_Error is raised if the check fails.
--
-- TEST DESCRIPTION:
--      A hierarchy of tagged types is declared from a discriminated
--      root type. Each level declares two kinds of types: (1) a type
--      extension which constrains the discriminant of its parent to
--      the value of an expression and (2) a type extension that
--      constrains the discriminant of its parent to equal a new discriminant
--      of the type extension (These are the two categories of noninherited
--      discriminants).
--
--      Values for each type are declared within nested blocks. This is
--      done so that the instances that produce Constraint_Error may
--      be dealt with cleanly without forcing the program to exit.
--
--      Success and failure cases (which should raise Constraint_Error)
--      are set up for each kind of type. Additionally, for the first
--      level of the hierarchy, separate tests are done for ancestor
--      expressions specified by aggregates and those specified by
--      variables. Later tests are performed using variables only.
--
--      Additionally, the cases tested consist of the following kinds of
--      types:
--
--         Extensions of extensions, using both the parent and grandparent
--         types for the ancestor expression,
--
--         Ancestor expressions which are several generations removed
--         from the type of the aggregate,
--
--         Extensions of types with multiple discriminants, where the
--         extension declares a new discriminant which corresponds to
--         more than one discriminant of the ancestor types.
--
--
--
-- CHANGE HISTORY:
--      06 Dec 94   SAIC    ACVC 2.0
--      19 Dec 94   SAIC    Removed RM references from objective text.
--      20 Dec 94   SAIC    Repair confusion WRT overridden discriminants
--
--!

package C432002_0 is

   subtype Length is Natural range 0..256;
   type Discriminant (L : Length) is tagged
      record
         S1 : String (1..L);
      end record;

   procedure Do_Something (Rec : in out Discriminant);
   -- inherited by all type extensions

   -- Aggregates of Discriminant are of the form
   --    (L, S1) where L= S1'Length

   -- Discriminant of parent constrained to value of an expression
   type Constrained_Discriminant_Extension is
      new Discriminant (L => 10)
      with record
         S2 : String (1..20);
      end record;

   -- Aggregates of Constrained_Discriminant_Extension are of the form
   --    (L, S1, S2), where L = S1'Length = 10, S2'Length = 20

   type Once_Removed is new Constrained_Discriminant_Extension
      with record
         S3 : String (1..3);
      end record;

   type Twice_Removed is new Once_Removed
      with record
         S4 : String (1..8);
      end record;

   -- Aggregates of Twice_Removed are of the form
   --    (L, S1, S2, S3, S4), where L = S1'Length = 10,
   --                               S2'Length = 20,
   --                               S3'Length = 3,
   --                               S4'Length = 8

   -- Discriminant of parent constrained to equal new discriminant
   type New_Discriminant_Extension (N : Length) is
      new Discriminant (L => N) with
      record
         S2 : String (1..N);
      end record;

   -- Aggregates of New_Discriminant_Extension are of the form
   --   (N, S1, S2), where N = S1'Length = S2'Length

   -- Discriminant of parent extension constrained to the value of
   -- an expression
   type Constrained_Extension_Extension is
      new New_Discriminant_Extension (N => 20)
      with record
         S3 : String (1..5);
      end record;

   -- Aggregates of Constrained_Extension_Extension are of the form
   --   (N, S1, S2, S3), where N = S1'Length = S2'Length = 20,
   --                             S3'Length = 5

   -- Discriminant of parent extension constrained to equal a new
   -- discriminant
   type New_Extension_Extension (I : Length) is
      new New_Discriminant_Extension (N => I)
      with record
         S3 : String (1..I);
      end record;

   -- Aggregates of New_Extension_Extension are of the form
   --    (I, S1, 2, S3), where
   --       I = S1'Length = S2'Length = S3'Length

   type Multiple_Discriminants (A, B : Length) is tagged
      record
         S1 : String (1..A);
         S2 : String (1..B);
      end record;

   procedure Do_Something (Rec : in out Multiple_Discriminants);
   -- inherited by type extension

   -- Aggregates of Multiple_Discriminants are of the form
   --    (A, B, S1, S2), where A = S1'Length, B = S2'Length

   type Multiple_Discriminant_Extension (C : Length) is
      new Multiple_Discriminants (A => C, B => C)
      with record
         S3 : String (1..C);
      end record;

   -- Aggregates of Multiple_Discriminant_Extension are of the form
   --    (A, B, S1, S2, C, S3), where
   --       A = B = C = S1'Length = S2'Length = S3'Length

end C432002_0;

with Report;
package body C432002_0 is

   S : String (1..20) := "12345678901234567890";

   procedure Do_Something (Rec : in out Discriminant) is
   begin
      Rec.S1 := Report.Ident_Str (S (1..Rec.L));
   end Do_Something;

   procedure Do_Something (Rec : in out Multiple_Discriminants) is
   begin
      Rec.S1 := Report.Ident_Str (S (1..Rec.A));
   end Do_Something;

end C432002_0;


with C432002_0;
with Report;
procedure C432002 is

   -- Various different-sized strings for variety
   String_3  : String (1..3)  := Report.Ident_Str("123");
   String_5  : String (1..5)  := Report.Ident_Str("12345");
   String_8  : String (1..8)  := Report.Ident_Str("12345678");
   String_10 : String (1..10) := Report.Ident_Str("1234567890");
   String_11 : String (1..11) := Report.Ident_Str("12345678901");
   String_20 : String (1..20) := Report.Ident_Str("12345678901234567890");

begin

   Report.Test ("C432002",
                "Extension aggregates for discriminated types");

   --------------------------------------------------------------------
   -- Extension constrains parent's discriminant to value of expression
   --------------------------------------------------------------------

   -- Successful cases - value matches corresponding discriminant value

   CD_Matched_Aggregate:
   begin
      declare
         CD : C432002_0.Constrained_Discriminant_Extension :=
            (C432002_0.Discriminant'(L  => 10,
                                     S1 => String_10)
               with S2 => String_20);
      begin
         C432002_0.Do_Something(CD); -- success
      end;
   exception
      when Constraint_Error =>
         Report.Comment ("Ancestor expression is an aggregate");
         Report.Failed ("Aggregate of extension " &
                        "with discriminant constrained: " &
                        "Constraint_Error was incorrectly raised " &
                        "for value that matches corresponding " &
                        "discriminant");
   end CD_Matched_Aggregate;
   
   CD_Matched_Variable:
   begin
      declare
         D : C432002_0.Discriminant(L => 10) :=
            C432002_0.Discriminant'(L  => 10,
                                    S1 => String_10);

         CD : C432002_0.Constrained_Discriminant_Extension :=
            (D with S2 => String_20);
      begin
         C432002_0.Do_Something(CD); -- success
      end;
   exception
      when Constraint_Error =>
         Report.Comment ("Ancestor expression is a variable");
         Report.Failed ("Aggregate of extension " &
                        "with discriminant constrained: " &
                        "Constraint_Error was incorrectly raised " &
                        "for value that matches corresponding " &
                        "discriminant");
   end CD_Matched_Variable;

   
   -- Unsuccessful cases - value does not match value of corresponding
   --                      discriminant. Constraint_Error should be
   --                      raised.

   CD_Unmatched_Aggregate:
   begin
      declare
         CD : C432002_0.Constrained_Discriminant_Extension :=
            (C432002_0.Discriminant'(L  => 5,
                                     S1 => String_5)
               with S2 => String_20);
      begin
         Report.Comment ("Ancestor expression is an aggregate");
         Report.Failed ("Aggregate of extension " &
                        "with discriminant constrained: " &
                        "Constraint_Error was not raised " &
                        "for discriminant value that does not match " &
                        "corresponding discriminant");
         C432002_0.Do_Something(CD); -- disallow unused var optimization
      end;
   exception
      when Constraint_Error =>
         null; -- raise of Constraint_Error is expected
   end CD_Unmatched_Aggregate;
   
   CD_Unmatched_Variable:
   begin
      declare
         D : C432002_0.Discriminant(L => 5) :=
            C432002_0.Discriminant'(L  => 5,
                                    S1 => String_5);

         CD : C432002_0.Constrained_Discriminant_Extension :=
            (D with S2 => String_20);
      begin
         Report.Comment ("Ancestor expression is an variable");
         Report.Failed ("Aggregate of extension " &
                        "with discriminant constrained: " &
                        "Constraint_Error was not raised " &
                        "for discriminant value that does not match " &
                        "corresponding discriminant");
         C432002_0.Do_Something(CD); -- disallow unused var optimization
      end;
   exception
      when Constraint_Error =>
         null; -- raise of Constraint_Error is expected
   end CD_Unmatched_Variable;

   -----------------------------------------------------------------------
   -- Extension constrains parent's discriminant to equal new discriminant
   -----------------------------------------------------------------------

   -- Successful cases - value matches corresponding discriminant value

   ND_Matched_Aggregate:
   begin
      declare
         ND : C432002_0.New_Discriminant_Extension (N => 8) :=
            (C432002_0.Discriminant'(L  => 8,
                                     S1 => String_8)
               with N  => 8,
                    S2 => String_8);
      begin
         C432002_0.Do_Something(ND); -- success
      end;
   exception
      when Constraint_Error =>
         Report.Comment ("Ancestor expression is an aggregate");
         Report.Failed ("Aggregate of extension " &
                        "with new discriminant: " &
                        "Constraint_Error was incorrectly raised " &
                        "for value that matches corresponding " &
                        "discriminant");
   end ND_Matched_Aggregate;
   
   ND_Matched_Variable:
   begin
      declare
         D : C432002_0.Discriminant(L => 3) :=
            C432002_0.Discriminant'(L  => 3,
                                    S1 => String_3);

         ND : C432002_0.New_Discriminant_Extension (N => 3) :=
            (D with N  => 3,
                    S2 => String_3);
      begin
         C432002_0.Do_Something(ND); -- success
      end;
   exception
      when Constraint_Error =>
         Report.Comment ("Ancestor expression is an variable");
         Report.Failed ("Aggregate of extension " &
                        "with new discriminant: " &
                        "Constraint_Error was incorrectly raised " &
                        "for value that matches corresponding " &
                        "discriminant");
   end ND_Matched_Variable;

   
   -- Unsuccessful cases - value does not match value of corresponding
   --                      discriminant. Constraint_Error should be
   --                      raised.
   
   ND_Unmatched_Aggregate:
   begin
      declare
         ND : C432002_0.New_Discriminant_Extension (N => 20) :=
            (C432002_0.Discriminant'(L  => 11,
                                     S1 => String_11)
               with N  => 20,
                    S2 => String_20);
      begin
         Report.Comment ("Ancestor expression is an aggregate");
         Report.Failed ("Aggregate of extension " &
                        "with new discriminant: " &
                        "Constraint_Error was not raised " &
                        "for discriminant value that does not match " &
                        "corresponding discriminant");
         C432002_0.Do_Something(ND); -- disallow unused var optimization
      end;
   exception
      when Constraint_Error =>
         null; -- raise is expected
   end ND_Unmatched_Aggregate;
   
   ND_Unmatched_Variable:
   begin
      declare
         D : C432002_0.Discriminant(L => 5) :=
            C432002_0.Discriminant'(L  => 5,
                                    S1 => String_5);

         ND : C432002_0.New_Discriminant_Extension (N => 20) :=
            (D with N  => 20,
                    S2 => String_20);
      begin
         Report.Comment ("Ancestor expression is an variable");
         Report.Failed ("Aggregate of extension " &
                        "with new discriminant: " &
                        "Constraint_Error was not raised " &
                        "for discriminant value that does not match " &
                        "corresponding discriminant");
         C432002_0.Do_Something(ND); -- disallow unused var optimization
      end;
   exception
      when Constraint_Error =>
         null; -- raise is expected
   end ND_Unmatched_Variable;

   --------------------------------------------------------------------
   -- Extension constrains parent's discriminant to value of expression
   -- Parent is a discriminant extension
   --------------------------------------------------------------------

   -- Successful cases - value matches corresponding discriminant value

   CE_Matched_Aggregate:
   begin
      declare
         CE : C432002_0.Constrained_Extension_Extension :=
            (C432002_0.Discriminant'(L  => 20,
                                     S1 => String_20)
               with N => 20,
                    S2 => String_20,
                    S3 => String_5);
      begin
         C432002_0.Do_Something(CE); -- success
      end;
   exception
      when Constraint_Error =>
         Report.Comment ("Ancestor expression is an aggregate");
         Report.Failed ("Aggregate of extension (of extension) " &
                        "with discriminant constrained: " &
                        "Constraint_Error was incorrectly raised " &
                        "for value that matches corresponding " &
                        "discriminant");
   end CE_Matched_Aggregate;
   
   CE_Matched_Variable:
   begin
      declare
         ND : C432002_0.New_Discriminant_Extension (N => 20) :=
            C432002_0.New_Discriminant_Extension'
               (N  => 20,
                S1 => String_20,
                S2 => String_20);

         CE : C432002_0.Constrained_Extension_Extension :=
            (ND with S3 => String_5);
      begin
         C432002_0.Do_Something(CE); -- success
      end;
   exception
      when Constraint_Error =>
         Report.Comment ("Ancestor expression is a variable");
         Report.Failed ("Aggregate of extension (of extension) " &
                        "with discriminant constrained: " &
                        "Constraint_Error was incorrectly raised " &
                        "for value that matches corresponding " &
                        "discriminant");
   end CE_Matched_Variable;

   
   -- Unsuccessful cases - value does not match value of corresponding
   --                      discriminant. Constraint_Error should be
   --                      raised.

   CE_Unmatched_Aggregate:
   begin
      declare
         CE : C432002_0.Constrained_Extension_Extension :=
            (C432002_0.New_Discriminant_Extension'
               (N  => 11,
                S1 => String_11,
                S2 => String_11)
            with S3 => String_5);
      begin
         Report.Comment ("Ancestor expression is an aggregate");
         Report.Failed ("Aggregate of extension (of extension) " &
                        "Constraint_Error was not raised " &
                        "with discriminant constrained: " &
                        "for discriminant value that does not match " &
                        "corresponding discriminant");
         C432002_0.Do_Something(CE); -- disallow unused var optimization
      end;
   exception
      when Constraint_Error =>
         null; -- raise of Constraint_Error is expected
   end CE_Unmatched_Aggregate;
   
   CE_Unmatched_Variable:
   begin
      declare
         D : C432002_0.Discriminant(L => 8) :=
            C432002_0.Discriminant'(L  => 8,
                                    S1 => String_8);

         CE : C432002_0.Constrained_Extension_Extension :=
            (D with N  => 8,
                    S2 => String_8,
                    S3 => String_5);
      begin
         Report.Comment ("Ancestor expression is a variable");
         Report.Failed ("Aggregate of extension (of extension) " &
                        "with discriminant constrained: " &
                        "Constraint_Error was not raised " &
                        "for discriminant value that does not match " &
                        "corresponding discriminant");
         C432002_0.Do_Something(CE); -- disallow unused var optimization
      end;
   exception
      when Constraint_Error =>
         null; -- raise of Constraint_Error is expected
   end CE_Unmatched_Variable;

   -----------------------------------------------------------------------
   -- Extension constrains parent's discriminant to equal new discriminant
   -- Parent is a discriminant extension
   -----------------------------------------------------------------------

   -- Successful cases - value matches corresponding discriminant value

   NE_Matched_Aggregate:
   begin
      declare
         NE : C432002_0.New_Extension_Extension (I => 8) :=
            (C432002_0.Discriminant'(L  => 8,
                                     S1 => String_8)
               with I  => 8,
                    S2 => String_8,
                    S3 => String_8);
      begin
         C432002_0.Do_Something(NE); -- success
      end;
   exception
      when Constraint_Error =>
         Report.Comment ("Ancestor expression is an aggregate");
         Report.Failed ("Aggregate of extension (of extension) " &
                        "with new discriminant: " &
                        "Constraint_Error was incorrectly raised " &
                        "for value that matches corresponding " &
                        "discriminant");
   end NE_Matched_Aggregate;
   
   NE_Matched_Variable:
   begin
      declare
         ND : C432002_0.New_Discriminant_Extension (N => 3) :=
            C432002_0.New_Discriminant_Extension'
               (N  => 3,
                S1 => String_3,
                S2 => String_3);

         NE : C432002_0.New_Extension_Extension (I => 3) :=
            (ND with I  => 3,
                     S3 => String_3);
      begin
         C432002_0.Do_Something(NE); -- success
      end;
   exception
      when Constraint_Error =>
         Report.Comment ("Ancestor expression is a variable");
         Report.Failed ("Aggregate of extension (of extension) " &
                        "with new discriminant: " &
                        "Constraint_Error was incorrectly raised " &
                        "for value that matches corresponding " &
                        "discriminant");
   end NE_Matched_Variable;

   
   -- Unsuccessful cases - value does not match value of corresponding
   --                      discriminant. Constraint_Error should be
   --                      raised.

   NE_Unmatched_Aggregate:
   begin
      declare
         NE : C432002_0.New_Extension_Extension (I => 8) :=
            (C432002_0.New_Discriminant_Extension'
               (C432002_0.Discriminant'(L  => 11,
                                        S1 => String_11)
                with N  => 11,
                     S2 => String_11)
            with I  => 8,
                 S3 => String_8);
      begin
         Report.Comment ("Ancestor expression is an extension aggregate");
         Report.Failed ("Aggregate of extension (of extension) " &
                        "with new discriminant: " &
                        "Constraint_Error was not raised " &
                        "for discriminant value that does not match " &
                        "corresponding discriminant");
         C432002_0.Do_Something(NE); -- disallow unused var optimization
      end;
   exception
      when Constraint_Error =>
         null; -- raise is expected
   end NE_Unmatched_Aggregate;
   
   NE_Unmatched_Variable:
   begin
      declare
         D : C432002_0.Discriminant(L => 5) :=
            C432002_0.Discriminant'(L  => 5,
                                    S1 => String_5);

         NE : C432002_0.New_Extension_Extension (I => 20) :=
            (D with I  => 5,
                    S2 => String_5,
                    S3 => String_20);
      begin
         Report.Comment ("Ancestor expression is a variable");
         Report.Failed ("Aggregate of extension (of extension) " &
                        "with new discriminant: " &
                        "Constraint_Error was not raised " &
                        "for discriminant value that does not match " &
                        "corresponding discriminant");
         C432002_0.Do_Something(NE); -- disallow unused var optimization
      end;
   exception
      when Constraint_Error =>
         null; -- raise is expected
   end NE_Unmatched_Variable;

   -----------------------------------------------------------------------
   -- Corresponding discriminant is two levels deeper than aggregate
   -----------------------------------------------------------------------

   -- Successful case - value matches corresponding discriminant value

   TR_Matched_Variable:
   begin
      declare
         D : C432002_0.Discriminant (L => 10) :=
            C432002_0.Discriminant'(L  => 10,
                                    S1 => String_10);

         TR : C432002_0.Twice_Removed :=
            C432002_0.Twice_Removed'(D with S2 => String_20,
                                            S3 => String_3,
                                            S4 => String_8);
         -- N is constrained to a value in the derived_type_definition
         -- of Constrained_Discriminant_Extension. Its omission from
         -- the above record_component_association_list is allowed by
         -- 4.3.2(6).

      begin
         C432002_0.Do_Something(TR); -- success
      end;
   exception
      when Constraint_Error =>
         Report.Failed ("Aggregate of far-removed extension " &
                        "with discriminant constrained: " &
                        "Constraint_Error was incorrectly raised " &
                        "for value that matches corresponding " &
                        "discriminant");
   end TR_Matched_Variable;
   
   
   -- Unsuccessful case - value does not match value of corresponding
   --                      discriminant. Constraint_Error should be
   --                      raised.

   TR_Unmatched_Variable:
   begin
      declare
         D : C432002_0.Discriminant (L => 5) :=
            C432002_0.Discriminant'(L  => 5,
                                    S1 => String_5);

         TR : C432002_0.Twice_Removed :=
            C432002_0.Twice_Removed'(D with S2 => String_20,
                                            S3 => String_3,
                                            S4 => String_8);

      begin
         Report.Failed ("Aggregate of far-removed extension " &
                        "with discriminant constrained: " &
                        "Constraint_Error was not raised " &
                        "for discriminant value that does not match " &
                        "corresponding discriminant");
         C432002_0.Do_Something(TR); -- disallow unused var optimization
      end;
   exception
      when Constraint_Error =>
         null; -- raise is expected
   end TR_Unmatched_Variable;
   
   ------------------------------------------------------------------------
   -- Parent has multiple discriminants.
   -- Discriminant in extension corresponds to both parental discriminants.
   ------------------------------------------------------------------------

   -- Successful case - value matches corresponding discriminant value

   MD_Matched_Variable:
   begin
      declare
         MD : C432002_0.Multiple_Discriminants (A => 10, B => 10) :=
            C432002_0.Multiple_Discriminants'(A  => 10,
                                              B  => 10,
                                              S1 => String_10,
                                              S2 => String_10);
         MDE : C432002_0.Multiple_Discriminant_Extension (C => 10) :=
            (MD with C  => 10,
                     S3 => String_10);

      begin
         C432002_0.Do_Something(MDE); -- success
      end;
   exception
      when Constraint_Error =>
         Report.Failed ("Aggregate of extension " &
                        "of multiply-discriminated parent: " &
                        "Constraint_Error was incorrectly raised " &
                        "for value that matches corresponding " &
                        "discriminant");
   end MD_Matched_Variable;

   
   -- Unsuccessful case - value does not match value of corresponding
   --                      discriminant. Constraint_Error should be
   --                      raised.

   MD_Unmatched_Variable:
   begin
      declare
         MD : C432002_0.Multiple_Discriminants (A => 10, B => 8) :=
            C432002_0.Multiple_Discriminants'(A  => 10,
                                              B  => 8,
                                              S1 => String_10,
                                              S2 => String_8);
         MDE : C432002_0.Multiple_Discriminant_Extension (C => 10) :=
            (MD with C  => 10,
                     S3 => String_10);

      begin
         Report.Failed ("Aggregate of extension " &
                        "of multiply-discriminated parent: " &
                        "Constraint_Error was not raised " &
                        "for discriminant value that does not match " &
                        "corresponding discriminant");
         C432002_0.Do_Something(MDE); -- disallow unused var optimization
      end;
   exception
      when Constraint_Error =>
         null; -- raise is expected
   end MD_Unmatched_Variable;

   Report.Result;

end C432002;