summaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats/tests/cd/cd10002.a
blob: fc56d4299dfa789cbee3ee1411d680e2c50af33e (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
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
-- CD10002.A
--
--                             Grant of Unlimited Rights
--
--     The Ada Conformity Assessment Authority (ACAA) holds unlimited
--     rights in the software and documentation contained herein. Unlimited
--     rights are the same as those granted by the U.S. Government for older
--     parts of the Ada Conformity Assessment Test Suite, and are defined
--     in DFAR 252.227-7013(a)(19). By making this public release, the ACAA
--     intends to confer upon all recipients unlimited rights equal to those
--     held by the ACAA. 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 operational items are allowed in some contexts where
--    representation items are not:
--
--       1 - Check that the name of an incompletely defined type can be used
--           when specifying an operational item. (RM95/TC1 7.3(5)).
--
--       2 - Check that operational items can be specified for a descendant of
--           a generic formal untagged type. (RM95/TC1 13.1(10)).
--
--       3 - Check that operational items can be specified for a derived
--           untagged type even if the parent type is a by-reference type or
--           has user-defined primitive subprograms. (RM95/TC1 13.1(11/1)).
--
--    (Defect Report 8652/0009, as reflected in Technical Corrigendum 1).
--
-- CHANGE HISTORY:
--    19 JAN 2001   PHL   Initial version.
--     3 DEC 2001   RLB   Reformatted for ACATS.
--     3 OCT 2002   RLB   Corrected incorrect type derivations.
--
--!
with Ada.Streams;
use Ada.Streams;
package CD10002_0 is

    type Kinds is (Read, Write, Input, Output);
    type Counts is array (Kinds) of Natural;

    generic
        type T is private;
    package Nonlimited_Stream_Ops is

        procedure Write (Stream : access Root_Stream_Type'Class; Item : T);
        function Input (Stream : access Root_Stream_Type'Class) return T;
        procedure Read (Stream : access Root_Stream_Type'Class; Item : out T);
        procedure Output (Stream : access Root_Stream_Type'Class; Item : T);

        function Get_Counts return Counts;

    end Nonlimited_Stream_Ops;

    generic
        type T (<>) is limited private; -- Should be self-initializing.
        C : in out T;
    package Limited_Stream_Ops is

        procedure Write (Stream : access Root_Stream_Type'Class; Item : T);
        function Input (Stream : access Root_Stream_Type'Class) return T;
        procedure Read (Stream : access Root_Stream_Type'Class; Item : out T);
        procedure Output (Stream : access Root_Stream_Type'Class; Item : T);

        function Get_Counts return Counts;

    end Limited_Stream_Ops;

end CD10002_0;


package body CD10002_0 is

    package body Nonlimited_Stream_Ops is
        Cnts : Counts := (others => 0);
        X : T; -- Initialized by Write/Output.

        procedure Write (Stream : access Root_Stream_Type'Class; Item : T) is
        begin
            X := Item;
            Cnts (Write) := Cnts (Write) + 1;
        end Write;

        function Input (Stream : access Root_Stream_Type'Class) return T is
        begin
            Cnts (Input) := Cnts (Input) + 1;
            return X;
        end Input;

        procedure Read (Stream : access Root_Stream_Type'Class; Item : out T) is
        begin
            Cnts (Read) := Cnts (Read) + 1;
            Item := X;
        end Read;

        procedure Output (Stream : access Root_Stream_Type'Class; Item : T) is
        begin
            X := Item;
            Cnts (Output) := Cnts (Output) + 1;
        end Output;

        function Get_Counts return Counts is
        begin
            return Cnts;
        end Get_Counts;

    end Nonlimited_Stream_Ops;

    package body Limited_Stream_Ops is
        Cnts : Counts := (others => 0);

        procedure Write (Stream : access Root_Stream_Type'Class; Item : T) is
        begin
            Cnts (Write) := Cnts (Write) + 1;
        end Write;

        function Input (Stream : access Root_Stream_Type'Class) return T is
        begin
            Cnts (Input) := Cnts (Input) + 1;
            return C;
        end Input;

        procedure Read (Stream : access Root_Stream_Type'Class; Item : out T) is
        begin
            Cnts (Read) := Cnts (Read) + 1;
        end Read;

        procedure Output (Stream : access Root_Stream_Type'Class; Item : T) is
        begin
            Cnts (Output) := Cnts (Output) + 1;
        end Output;

        function Get_Counts return Counts is
        begin
            return Cnts;
        end Get_Counts;

    end Limited_Stream_Ops;

end CD10002_0;


with Ada.Streams;
use Ada.Streams;
package CD10002_1 is

    type Dummy_Stream is new Root_Stream_Type with null record;
    procedure Read (Stream : in out Dummy_Stream;
                    Item : out Stream_Element_Array;
                    Last : out Stream_Element_Offset);
    procedure Write (Stream : in out Dummy_Stream;
                     Item : Stream_Element_Array);

end CD10002_1;


with Report;
use Report;
package body CD10002_1 is

    procedure Read (Stream : in out Dummy_Stream;
                    Item : out Stream_Element_Array;
                    Last : out Stream_Element_Offset) is
    begin
        Failed ("Unexpected call to the Read operation of Dummy_Stream");
    end Read;

    procedure Write (Stream : in out Dummy_Stream;
                     Item : Stream_Element_Array) is
    begin
        Failed ("Unexpected call to the Write operation of Dummy_Stream");
    end Write;

end CD10002_1;


with Ada.Streams;
use Ada.Streams;
with CD10002_0;
package CD10002_Deriv is

    -- Parent has user-defined subprograms.

    type T1 is new Boolean;
    function Is_Odd (X : Integer) return T1;

    type T2 is
        record
            F : Float;
        end record;
    procedure Print (X : T2);

    type T3 is array (Boolean) of Duration;
    function "+" (L, R : T3) return T3;

    -- Parent is by-reference.  No need to check the case where the parent
    -- is tagged, because the defect report only deals with untagged types.

    task type T4 is
    end T4;

    protected type T5 is
    end T5;

    type T6 (D : access Integer := new Integer'(2)) is limited null record;

    type T7 is array (Character) of T6;

    package P is
        type T8 is limited private;
    private
        type T8 is new T5;
    end P;

    type Nt1 is new T1;
    type Nt2 is new T2;
    type Nt3 is new T3;
    type Nt4 is new T4;
    type Nt5 is new T5;
    type Nt6 is new T6;
    type Nt7 is new T7;
    type Nt8 is new P.T8;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt1'Base);
    function Input (Stream : access Root_Stream_Type'Class) return Nt1'Base;
    procedure Read (Stream : access Root_Stream_Type'Class;
                    Item : out Nt1'Base);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt1'Base);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt2);
    function Input (Stream : access Root_Stream_Type'Class) return Nt2;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt2);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt2);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt3);
    function Input (Stream : access Root_Stream_Type'Class) return Nt3;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt3);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt3);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt4);
    function Input (Stream : access Root_Stream_Type'Class) return Nt4;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt4);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt4);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt5);
    function Input (Stream : access Root_Stream_Type'Class) return Nt5;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt5);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt5);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt6);
    function Input (Stream : access Root_Stream_Type'Class) return Nt6;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt6);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt6);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt7);
    function Input (Stream : access Root_Stream_Type'Class) return Nt7;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt7);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt7);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt8);
    function Input (Stream : access Root_Stream_Type'Class) return Nt8;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt8);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt8);

    for Nt1'Write use Write;
    for Nt1'Read use Read;
    for Nt1'Output use Output;
    for Nt1'Input use Input;

    for Nt2'Write use Write;
    for Nt2'Read use Read;
    for Nt2'Output use Output;
    for Nt2'Input use Input;

    for Nt3'Write use Write;
    for Nt3'Read use Read;
    for Nt3'Output use Output;
    for Nt3'Input use Input;

    for Nt4'Write use Write;
    for Nt4'Read use Read;
    for Nt4'Output use Output;
    for Nt4'Input use Input;

    for Nt5'Write use Write;
    for Nt5'Read use Read;
    for Nt5'Output use Output;
    for Nt5'Input use Input;

    for Nt6'Write use Write;
    for Nt6'Read use Read;
    for Nt6'Output use Output;
    for Nt6'Input use Input;

    for Nt7'Write use Write;
    for Nt7'Read use Read;
    for Nt7'Output use Output;
    for Nt7'Input use Input;

    for Nt8'Write use Write;
    for Nt8'Read use Read;
    for Nt8'Output use Output;
    for Nt8'Input use Input;

    -- All these variables are self-initializing.
    C4 : Nt4;
    C5 : Nt5;
    C6 : Nt6;
    C7 : Nt7;
    C8 : Nt8;

    package Nt1_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt1'Base);
    package Nt2_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt2);
    package Nt3_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt3);
    package Nt4_Ops is new CD10002_0.Limited_Stream_Ops (Nt4, C4);
    package Nt5_Ops is new CD10002_0.Limited_Stream_Ops (Nt5, C5);
    package Nt6_Ops is new CD10002_0.Limited_Stream_Ops (Nt6, C6);
    package Nt7_Ops is new CD10002_0.Limited_Stream_Ops (Nt7, C7);
    package Nt8_Ops is new CD10002_0.Limited_Stream_Ops (Nt8, C8);

end CD10002_Deriv;


package body CD10002_Deriv is

    function Is_Odd (X : Integer) return T1 is
    begin
        return True;
    end Is_Odd;
    procedure Print (X : T2) is
    begin
        null;
    end Print;
    function "+" (L, R : T3) return T3 is
    begin
        return (False => L (False) + R (True), True => L (True) + R (False));
    end "+";
    task body T4 is
    begin
        null;
    end T4;
    protected body T5 is
    end T5;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt1'Base)
       renames Nt1_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt1'Base
       renames Nt1_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt1'Base)
       renames Nt1_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt1'Base)
       renames Nt1_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt2)
       renames Nt2_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt2
       renames Nt2_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt2)
       renames Nt2_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt2)
       renames Nt2_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt3)
       renames Nt3_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt3
       renames Nt3_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt3)
       renames Nt3_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt3)
       renames Nt3_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt4)
       renames Nt4_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt4
       renames Nt4_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt4)
       renames Nt4_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt4)
       renames Nt4_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt5)
       renames Nt5_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt5
       renames Nt5_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt5)
       renames Nt5_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt5)
       renames Nt5_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt6)
       renames Nt6_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt6
       renames Nt6_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt6)
       renames Nt6_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt6)
       renames Nt6_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt7)
       renames Nt7_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt7
       renames Nt7_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt7)
       renames Nt7_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt7)
       renames Nt7_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt8)
       renames Nt8_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt8
       renames Nt8_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt8)
       renames Nt8_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt8)
       renames Nt8_Ops.Output;

end CD10002_Deriv;


with Ada.Streams;
use Ada.Streams;
with CD10002_0;
generic
    type T1 is (<>);
    type T2 is range <>;
    type T3 is mod <>;
    type T4 is digits <>;
    type T5 is delta <>;
    type T6 is delta <> digits <>;
    type T7 is access T3;
    type T8 is new Boolean;
    type T9 is private;
    type T10 (<>) is limited private; -- Should be self-initializing.
    C10 : in out T10;
    type T11 is array (T1) of T2;
package CD10002_Gen is

    -- Direct descendants.
    type Nt1 is new T1;
    type Nt2 is new T2;
    type Nt3 is new T3;
    type Nt4 is new T4;
    type Nt5 is new T5;
    type Nt6 is new T6;
    type Nt7 is new T7;
    type Nt8 is new T8;
    type Nt9 is new T9;
    type Nt10 is new T10;
    type Nt11 is new T11;

    -- Indirect descendants (only pick two, a limited one and a non-limited
    -- one).
    type Nt12 is new Nt10;
    type Nt13 is new Nt11;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt1'Base);
    function Input (Stream : access Root_Stream_Type'Class) return Nt1'Base;
    procedure Read (Stream : access Root_Stream_Type'Class;
                    Item : out Nt1'Base);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt1'Base);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt2'Base);
    function Input (Stream : access Root_Stream_Type'Class) return Nt2'Base;
    procedure Read (Stream : access Root_Stream_Type'Class;
                    Item : out Nt2'Base);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt2'Base);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt3'Base);
    function Input (Stream : access Root_Stream_Type'Class) return Nt3'Base;
    procedure Read (Stream : access Root_Stream_Type'Class;
                    Item : out Nt3'Base);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt3'Base);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt4'Base);
    function Input (Stream : access Root_Stream_Type'Class) return Nt4'Base;
    procedure Read (Stream : access Root_Stream_Type'Class;
                    Item : out Nt4'Base);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt4'Base);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt5'Base);
    function Input (Stream : access Root_Stream_Type'Class) return Nt5'Base;
    procedure Read (Stream : access Root_Stream_Type'Class;
                    Item : out Nt5'Base);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt5'Base);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt6'Base);
    function Input (Stream : access Root_Stream_Type'Class) return Nt6'Base;
    procedure Read (Stream : access Root_Stream_Type'Class;
                    Item : out Nt6'Base);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt6'Base);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt7);
    function Input (Stream : access Root_Stream_Type'Class) return Nt7;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt7);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt7);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt8'Base);
    function Input (Stream : access Root_Stream_Type'Class) return Nt8'Base;
    procedure Read (Stream : access Root_Stream_Type'Class;
                    Item : out Nt8'Base);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt8'Base);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt9);
    function Input (Stream : access Root_Stream_Type'Class) return Nt9;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt9);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt9);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt10);
    function Input (Stream : access Root_Stream_Type'Class) return Nt10;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt10);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt10);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt11);
    function Input (Stream : access Root_Stream_Type'Class) return Nt11;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt11);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt11);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt12);
    function Input (Stream : access Root_Stream_Type'Class) return Nt12;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt12);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt12);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt13);
    function Input (Stream : access Root_Stream_Type'Class) return Nt13;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt13);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt13);

    for Nt1'Write use Write;
    for Nt1'Read use Read;
    for Nt1'Output use Output;
    for Nt1'Input use Input;

    for Nt2'Write use Write;
    for Nt2'Read use Read;
    for Nt2'Output use Output;
    for Nt2'Input use Input;

    for Nt3'Write use Write;
    for Nt3'Read use Read;
    for Nt3'Output use Output;
    for Nt3'Input use Input;

    for Nt4'Write use Write;
    for Nt4'Read use Read;
    for Nt4'Output use Output;
    for Nt4'Input use Input;

    for Nt5'Write use Write;
    for Nt5'Read use Read;
    for Nt5'Output use Output;
    for Nt5'Input use Input;

    for Nt6'Write use Write;
    for Nt6'Read use Read;
    for Nt6'Output use Output;
    for Nt6'Input use Input;

    for Nt7'Write use Write;
    for Nt7'Read use Read;
    for Nt7'Output use Output;
    for Nt7'Input use Input;

    for Nt8'Write use Write;
    for Nt8'Read use Read;
    for Nt8'Output use Output;
    for Nt8'Input use Input;

    for Nt9'Write use Write;
    for Nt9'Read use Read;
    for Nt9'Output use Output;
    for Nt9'Input use Input;

    for Nt10'Write use Write;
    for Nt10'Read use Read;
    for Nt10'Output use Output;
    for Nt10'Input use Input;

    for Nt11'Write use Write;
    for Nt11'Read use Read;
    for Nt11'Output use Output;
    for Nt11'Input use Input;

    for Nt12'Write use Write;
    for Nt12'Read use Read;
    for Nt12'Output use Output;
    for Nt12'Input use Input;

    for Nt13'Write use Write;
    for Nt13'Read use Read;
    for Nt13'Output use Output;
    for Nt13'Input use Input;

    type Null_Record is null record;

    package Nt1_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt1'Base);
    package Nt2_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt2'Base);
    package Nt3_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt3'Base);
    package Nt4_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt4'Base);
    package Nt5_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt5'Base);
    package Nt6_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt6'Base);
    package Nt7_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt7);
    package Nt8_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt8'Base);
    package Nt9_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt9);
    package Nt11_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt11);
    package Nt13_Ops is new CD10002_0.Nonlimited_Stream_Ops (Nt13);

    function Get_Nt10_Counts return CD10002_0.Counts;
    function Get_Nt12_Counts return CD10002_0.Counts;

end CD10002_Gen;


package body CD10002_Gen is

    use CD10002_0;

    Nt10_Cnts : Counts := (others => 0);
    Nt12_Cnts : Counts := (others => 0);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt1'Base)
       renames Nt1_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt1'Base
       renames Nt1_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt1'Base)
       renames Nt1_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt1'Base)
       renames Nt1_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt2'Base)
       renames Nt2_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt2'Base
       renames Nt2_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt2'Base)
       renames Nt2_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt2'Base)
       renames Nt2_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt3'Base)
       renames Nt3_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt3'Base
       renames Nt3_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt3'Base)
       renames Nt3_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt3'Base)
       renames Nt3_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt4'Base)
       renames Nt4_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt4'Base
       renames Nt4_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt4'Base)
       renames Nt4_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt4'Base)
       renames Nt4_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt5'Base)
       renames Nt5_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt5'Base
       renames Nt5_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt5'Base)
       renames Nt5_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt5'Base)
       renames Nt5_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt6'Base)
       renames Nt6_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt6'Base
       renames Nt6_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt6'Base)
       renames Nt6_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt6'Base)
       renames Nt6_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt7)
       renames Nt7_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt7
       renames Nt7_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt7)
       renames Nt7_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt7)
       renames Nt7_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt8'Base)
       renames Nt8_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt8'Base
       renames Nt8_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt8'Base)
       renames Nt8_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt8'Base)
       renames Nt8_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt9)
       renames Nt9_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt9
       renames Nt9_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt9)
       renames Nt9_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt9)
       renames Nt9_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt10) is
    begin
        Nt10_Cnts (Write) := Nt10_Cnts (Write) + 1;
    end Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt10 is
    begin
        Nt10_Cnts (Input) := Nt10_Cnts (Input) + 1;
        return Nt10 (C10);
    end Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt10) is
    begin
        Nt10_Cnts (Read) := Nt10_Cnts (Read) + 1;
    end Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt10) is
    begin
        Nt10_Cnts (Output) := Nt10_Cnts (Output) + 1;
    end Output;
    function Get_Nt10_Counts return CD10002_0.Counts is
    begin
        return Nt10_Cnts;
    end Get_Nt10_Counts;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt11)
       renames Nt11_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt11
       renames Nt11_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt11)
       renames Nt11_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt11)
       renames Nt11_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt12) is
    begin
        Nt12_Cnts (Write) := Nt12_Cnts (Write) + 1;
    end Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt12 is
    begin
        Nt12_Cnts (Input) := Nt12_Cnts (Input) + 1;
        return Nt12 (C10);
    end Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt12) is
    begin
        Nt12_Cnts (Read) := Nt12_Cnts (Read) + 1;
    end Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt12) is
    begin
        Nt12_Cnts (Output) := Nt12_Cnts (Output) + 1;
    end Output;
    function Get_Nt12_Counts return CD10002_0.Counts is
    begin
        return Nt12_Cnts;
    end Get_Nt12_Counts;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : Nt13)
       renames Nt13_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return Nt13
       renames Nt13_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out Nt13)
       renames Nt13_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : Nt13)
       renames Nt13_Ops.Output;

end CD10002_Gen;


with Ada.Streams;
use Ada.Streams;
with CD10002_0;
package CD10002_Priv is

    External_Tag_1 : constant String := "Isaac Newton";
    External_Tag_2 : constant String := "Albert Einstein";

    type T1 is tagged private;
    type T2 is tagged
        record
            C : T1;
        end record;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : T1);
    function Input (Stream : access Root_Stream_Type'Class) return T1;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out T1);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : T1);

    procedure Write (Stream : access Root_Stream_Type'Class; Item : T2);
    function Input (Stream : access Root_Stream_Type'Class) return T2;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out T2);
    procedure Output (Stream : access Root_Stream_Type'Class; Item : T2);

    for T1'Write use Write;
    for T1'Input use Input;

    for T2'Read use Read;
    for T2'Output use Output;
    for T2'External_Tag use External_Tag_2;

    function Get_T1_Counts return CD10002_0.Counts;
    function Get_T2_Counts return CD10002_0.Counts;

private

    for T1'Read use Read;
    for T1'Output use Output;
    for T1'External_Tag use External_Tag_1;

    for T2'Write use Write;
    for T2'Input use Input;

    type T1 is tagged null record;

    package T1_Ops is new CD10002_0.Nonlimited_Stream_Ops (T1);
    package T2_Ops is new CD10002_0.Nonlimited_Stream_Ops (T2);

end CD10002_Priv;


package body CD10002_Priv is
    procedure Write (Stream : access Root_Stream_Type'Class; Item : T1)
       renames T1_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return T1
       renames T1_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out T1)
       renames T1_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : T1)
       renames T1_Ops.Output;

    procedure Write (Stream : access Root_Stream_Type'Class; Item : T2)
       renames T2_Ops.Write;
    function Input (Stream : access Root_Stream_Type'Class) return T2
       renames T2_Ops.Input;
    procedure Read (Stream : access Root_Stream_Type'Class; Item : out T2)
       renames T2_Ops.Read;
    procedure Output (Stream : access Root_Stream_Type'Class; Item : T2)
       renames T2_Ops.Output;

    function Get_T1_Counts return CD10002_0.Counts renames T1_Ops.Get_Counts;
    function Get_T2_Counts return CD10002_0.Counts renames T2_Ops.Get_Counts;
end CD10002_Priv;


with Ada.Streams;
use Ada.Streams;
with Report;
use Report;
with System;
with CD10002_0;
with CD10002_1;
with CD10002_Deriv;
with CD10002_Gen;
with CD10002_Priv;
procedure CD10002 is

    package Deriv renames CD10002_Deriv;
    generic package Gen renames CD10002_Gen;
    package Priv renames CD10002_Priv;

    type Stream_Ops is (Read, Write, Input, Output);
    type Counts is array (Stream_Ops) of Natural;

    S : aliased CD10002_1.Dummy_Stream;

begin
    Test ("CD10002",
          "Check that operational items are allowed in some contexts " &
             "where representation items are not");

    Test_Priv:
        declare
            X1 : Priv.T1;
            X2 : Priv.T2;
            use CD10002_0;
        begin
            Comment
               ("Check that the name of an incompletely defined type can be " &
                "used when specifying an operational item");

            -- Partial view of a private type.
            Priv.T1'Write (S'Access, X1);
            Priv.T1'Read (S'Access, X1);
            Priv.T1'Output (S'Access, X1);
            X1 := Priv.T1'Input (S'Access);

            if Priv.Get_T1_Counts /= (1, 1, 1, 1) then
                Failed ("Incorrect calls to the stream attributes for Priv.T1");
            elsif Priv.T1'External_Tag /= Priv.External_Tag_1 then
                Failed ("Incorrect external tag for Priv.T1");
            end if;

            -- Incompletely defined but not private.
            Priv.T2'Write (S'Access, X2);
            Priv.T2'Read (S'Access, X2);
            Priv.T2'Output (S'Access, X2);
            X2 := Priv.T2'Input (S'Access);

            if Priv.Get_T2_Counts /= (1, 1, 1, 1) then
                Failed ("Incorrect calls to the stream attributes for Priv.T2");
            elsif Priv.T2'External_Tag /= Priv.External_Tag_2 then
                Failed ("Incorrect external tag for Priv.T2");
            end if;

        end Test_Priv;

    Test_Gen:
        declare

            type Modular is mod System.Max_Binary_Modulus;
            type Decimal is delta 1.0 digits 1;
            type Access_Modular is access Modular;
            type R9 is null record;
            type R10 (D : access Integer) is limited null record;
            type Arr is array (Character) of Integer;

            C10 : R10 (new Integer'(19));

            package Inst is new Gen (T1 => Character,
                                     T2 => Integer,
                                     T3 => Modular,
                                     T4 => Float,
                                     T5 => Duration,
                                     T6 => Decimal,
                                     T7 => Access_Modular,
                                     T8 => Boolean,
                                     T9 => R9,
                                     T10 => R10,
                                     C10 => C10,
                                     T11 => Arr);

            X1 : Inst.Nt1 := 'a';
            X2 : Inst.Nt2 := 0;
            X3 : Inst.Nt3 := 0;
            X4 : Inst.Nt4 := 0.0;
            X5 : Inst.Nt5 := 0.0;
            X6 : Inst.Nt6 := 0.0;
            X7 : Inst.Nt7 := null;
            X8 : Inst.Nt8 := Inst.False;
            X9 : Inst.Nt9 := (null record);
            X10 : Inst.Nt10 (D => new Integer'(5));
            Y10 : Integer;
            X11 : Inst.Nt11 := (others => 0);
            X12 : Inst.Nt12 (D => new Integer'(7));
            Y12 : Integer;
            X13 : Inst.Nt13 := (others => 0);
            use CD10002_0;
        begin
            Comment ("Check that operational items can be specified for a " &
                     "descendant of a generic formal untagged type");

            Inst.Nt1'Write (S'Access, X1);
            Inst.Nt1'Read (S'Access, X1);
            Inst.Nt1'Output (S'Access, X1);
            X1 := Inst.Nt1'Input (S'Access);

            if Inst.Nt1_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt1");
            end if;

            Inst.Nt2'Write (S'Access, X2);
            Inst.Nt2'Read (S'Access, X2);
            Inst.Nt2'Output (S'Access, X2);
            X2 := Inst.Nt2'Input (S'Access);

            if Inst.Nt2_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt2");
            end if;

            Inst.Nt3'Write (S'Access, X3);
            Inst.Nt3'Read (S'Access, X3);
            Inst.Nt3'Output (S'Access, X3);
            X3 := Inst.Nt3'Input (S'Access);

            if Inst.Nt3_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt3");
            end if;

            Inst.Nt4'Write (S'Access, X4);
            Inst.Nt4'Read (S'Access, X4);
            Inst.Nt4'Output (S'Access, X4);
            X4 := Inst.Nt4'Input (S'Access);

            if Inst.Nt4_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt4");
            end if;

            Inst.Nt5'Write (S'Access, X5);
            Inst.Nt5'Read (S'Access, X5);
            Inst.Nt5'Output (S'Access, X5);
            X5 := Inst.Nt5'Input (S'Access);

            if Inst.Nt5_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt5");
            end if;

            Inst.Nt6'Write (S'Access, X6);
            Inst.Nt6'Read (S'Access, X6);
            Inst.Nt6'Output (S'Access, X6);
            X6 := Inst.Nt6'Input (S'Access);

            if Inst.Nt6_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt6");
            end if;

            Inst.Nt7'Write (S'Access, X7);
            Inst.Nt7'Read (S'Access, X7);
            Inst.Nt7'Output (S'Access, X7);
            X7 := Inst.Nt7'Input (S'Access);

            if Inst.Nt7_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt7");
            end if;

            Inst.Nt8'Write (S'Access, X8);
            Inst.Nt8'Read (S'Access, X8);
            Inst.Nt8'Output (S'Access, X8);
            X8 := Inst.Nt8'Input (S'Access);

            if Inst.Nt8_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt8");
            end if;

            Inst.Nt9'Write (S'Access, X9);
            Inst.Nt9'Read (S'Access, X9);
            Inst.Nt9'Output (S'Access, X9);
            X9 := Inst.Nt9'Input (S'Access);

            if Inst.Nt9_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt9");
            end if;

            Inst.Nt10'Write (S'Access, X10);
            Inst.Nt10'Read (S'Access, X10);
            Inst.Nt10'Output (S'Access, X10);
            Y10 := Inst.Nt10'Input (S'Access).D.all;

            if Inst.Get_Nt10_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt10");
            end if;

            Inst.Nt11'Write (S'Access, X11);
            Inst.Nt11'Read (S'Access, X11);
            Inst.Nt11'Output (S'Access, X11);
            X11 := Inst.Nt11'Input (S'Access);

            if Inst.Nt11_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt11");
            end if;

            Inst.Nt12'Write (S'Access, X12);
            Inst.Nt12'Read (S'Access, X12);
            Inst.Nt12'Output (S'Access, X12);
            Y12 := Inst.Nt12'Input (S'Access).D.all;

            if Inst.Get_Nt12_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt12");
            end if;

            Inst.Nt13'Write (S'Access, X13);
            Inst.Nt13'Read (S'Access, X13);
            Inst.Nt13'Output (S'Access, X13);
            X13 := Inst.Nt13'Input (S'Access);

            if Inst.Nt13_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Inst.Nt13");
            end if;
        end Test_Gen;

    Test_Deriv:
        declare
            X1 : Deriv.Nt1 := Deriv.False;
            X2 : Deriv.Nt2 := (others => 0.0);
            X3 : Deriv.Nt3 := (others => 0.0);
            X4 : Deriv.Nt4;
            Y4 : Boolean;
            X5 : Deriv.Nt5;
            Y5 : System.Address;
            X6 : Deriv.Nt6;
            Y6 : Integer;
            X7 : Deriv.Nt7;
            Y7 : Integer;
            X8 : Deriv.Nt8;
            Y8 : Integer;
            use CD10002_0;
        begin
            Comment ("Check that operational items can be specified for a " &
                     "derived untagged type even if the parent type is a " &
                     "by-reference type, or has user-defined primitive " &
                     "subprograms");

            Deriv.Nt1'Write (S'Access, X1);
            Deriv.Nt1'Read (S'Access, X1);
            Deriv.Nt1'Output (S'Access, X1);
            X1 := Deriv.Nt1'Input (S'Access);

            if Deriv.Nt1_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Deriv.Nt1");
            end if;

            Deriv.Nt2'Write (S'Access, X2);
            Deriv.Nt2'Read (S'Access, X2);
            Deriv.Nt2'Output (S'Access, X2);
            X2 := Deriv.Nt2'Input (S'Access);

            if Deriv.Nt2_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Deriv.Nt2");
            end if;

            Deriv.Nt3'Write (S'Access, X3);
            Deriv.Nt3'Read (S'Access, X3);
            Deriv.Nt3'Output (S'Access, X3);
            X3 := Deriv.Nt3'Input (S'Access);

            if Deriv.Nt3_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Deriv.Nt3");
            end if;

            Deriv.Nt4'Write (S'Access, X4);
            Deriv.Nt4'Read (S'Access, X4);
            Deriv.Nt4'Output (S'Access, X4);
            Y4 := Deriv.Nt4'Input (S'Access)'Terminated;

            if Deriv.Nt4_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Deriv.Nt4");
            end if;

            Deriv.Nt5'Write (S'Access, X5);
            Deriv.Nt5'Read (S'Access, X5);
            Deriv.Nt5'Output (S'Access, X5);
            Y5 := Deriv.Nt5'Input (S'Access)'Address;

            if Deriv.Nt5_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Deriv.Nt5");
            end if;

            Deriv.Nt6'Write (S'Access, X6);
            Deriv.Nt6'Read (S'Access, X6);
            Deriv.Nt6'Output (S'Access, X6);
            Y6 := Deriv.Nt6'Input (S'Access).D.all;

            if Deriv.Nt6_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Deriv.Nt6");
            end if;

            Deriv.Nt7'Write (S'Access, X7);
            Deriv.Nt7'Read (S'Access, X7);
            Deriv.Nt7'Output (S'Access, X7);
            Y7 := Deriv.Nt7'Input (S'Access) ('a').D.all;

            if Deriv.Nt7_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Deriv.Nt7");
            end if;

            Deriv.Nt8'Write (S'Access, X8);
            Deriv.Nt8'Read (S'Access, X8);
            Deriv.Nt8'Output (S'Access, X8);
            Y8 := Deriv.Nt8'Input (S'Access)'Size;

            if Deriv.Nt8_Ops.Get_Counts /= (1, 1, 1, 1) then
                Failed
                   ("Incorrect calls to the stream attributes for Deriv.Nt8");
            end if;
        end Test_Deriv;

    Result;
end CD10002;