summaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats/tests/c6/c64201c.ada
blob: ac7fec806e6b898561655df62a97a13d7c039cc5 (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
-- C64201C.ADA

--                             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.
--*
-- CHECK THAT INITIALIZATION OF IN PARAMETERS OF A COMPOSITE
--   TYPE HAVING AT LEAST ONE COMPONENT (INCLUDING COMPONENTS
--   OF COMPONENTS) OF A TASK TYPE IS PERMITTED.
--  (SEE ALSO 7.4.4/T2 FOR TESTS OF LIMITED PRIVATE TYPES.)

-- CVP 5/14/81
-- ABW 7/1/82
-- BHS 7/9/84

WITH REPORT;
USE REPORT;
PROCEDURE C64201C IS


     GLOBAL : INTEGER := 10;


     TASK TYPE T IS
          ENTRY E (X : IN OUT INTEGER);
     END;

     TYPE REC_T IS
          RECORD
               TT : T;
               BB : BOOLEAN := TRUE;
          END RECORD;

     TYPE REC_REC_T IS
          RECORD
               RR : REC_T;
          END RECORD;

     TYPE ARR_T IS ARRAY (1 .. 2) OF T;

     TYPE ARR_REC_T IS ARRAY (1 .. 2) OF REC_T;

     RT1, RT2   : REC_T;
     RRT1, RRT2 : REC_REC_T;
     AT1, AT2   : ARR_T;
     ART1, ART2 : ARR_REC_T;

     
     TASK BODY T IS
     BEGIN
          ACCEPT E (X : IN OUT INTEGER) DO
               X := X - 1;
          END E;
          ACCEPT E (X : IN OUT INTEGER) DO
               X := X + 1;
          END E;
     END T;


     PROCEDURE PROC1A (P1X : REC_T := RT1) IS
     BEGIN
          IF P1X.BB THEN                 -- EXPECT RT2 PASSED.
               FAILED( "RECORD OF TASK NOT PASSED, DEFAULT EMPLOYED" );
          END IF;
     END PROC1A;

     PROCEDURE PROC1B (P1X : REC_T := RT1) IS
     BEGIN
          IF NOT P1X.BB THEN             -- EXPECT DEFAULT USED.
               FAILED( "DEFAULT RECORD OF TASK NOT EMPLOYED" );
          END IF;
     END PROC1B;


     PROCEDURE PROC2A (P2X : REC_REC_T := RRT1) IS
     BEGIN
          IF P2X.RR.BB THEN             -- EXPECT RRT2 PASSED.
               FAILED( "RECORD OF RECORD OF TASK NOT PASSED, " &
                       "DEFAULT EMPLOYED" );
          END IF;
     END PROC2A;

     PROCEDURE PROC2B (P2X : REC_REC_T := RRT1) IS
     BEGIN
          IF NOT P2X.RR.BB THEN         -- EXPECT DEFAULT USED.
               FAILED( "DEFAULT RECORD OF RECORD OF TASK " &
                       "NOT EMPLOYED" );
          END IF;
     END PROC2B;


     PROCEDURE PROC3 (P3X : ARR_T := AT1) IS
     BEGIN
          P3X(1).E (X => GLOBAL);        -- CALL TO AT2(1).E,
                                         -- GLOBAL => GLOBAL - 1.
     END PROC3;

     PROCEDURE PROC4 (P4X : ARR_T := AT1) IS
     BEGIN
          P4X(1).E (X => GLOBAL);     -- CALL TO DEFAULT AT1(1).E,
                                      -- GLOBAL => GLOBAL - 1.
          IF GLOBAL /= IDENT_INT(8) THEN
               FAILED( "ARRAY OF TASKS NOT PASSED " &
                       "CORRECTLY IN PROC3" );
          END IF;
     END PROC4;

     PROCEDURE PROC5 (P5X : ARR_REC_T := ART1) IS
     BEGIN
          P5X(1).TT.E (X => GLOBAL);      -- CALL TO ART2(1).TT.E,
                                          -- GLOBAL => GLOBAL - 1.
     END PROC5;

     PROCEDURE PROC6 (P6X : ARR_REC_T := ART1) IS
     BEGIN
          P6X(1).TT.E (X => GLOBAL);      -- CALL DEFAULT ART1(1).TT.E,
                                          -- GLOBAL => GLOBAL - 1.
          IF GLOBAL /= IDENT_INT(8) THEN
               FAILED( "ARRAY OF RECORDS OF TASKS NOT " &
                       "PASSED IN PROC5" );
          END IF;
     END PROC6;

     PROCEDURE TERM (TSK : T; NUM : CHARACTER) IS
     BEGIN
          IF NOT TSK'TERMINATED THEN
               ABORT TSK;
               COMMENT ("ABORTING TASK " & NUM);
          END IF;
     END TERM;


BEGIN

     TEST( "C64201C" , "CHECK THAT INITIALIZATION OF IN " &
                       "PARAMETERS OF A COMPOSITE TYPE " &
                       "IS PERMITTED" );

     RT2.BB := FALSE;
     RRT2.RR.BB := FALSE;

     PROC1A(RT2);                               -- NO ENTRY CALL
     PROC1B;                                    -- NO ENTRY CALL
     PROC2A(RRT2);                              -- NO ENTRY CALL
     PROC2B;                                    -- NO ENTRY CALL

     PROC3(AT2);                                -- CALL AT2(1).E
     IF GLOBAL /= 9 THEN
          FAILED ("INCORRECT GLOBAL VALUE AFTER PROC3");
     ELSE
          PROC4;                                -- CALL AT1(1).E
     END IF;

     GLOBAL := 10;
     PROC5(ART2);                              -- CALL ART2(1).TT.E
     IF GLOBAL /= 9 THEN
          FAILED ("INCORRECT GLOBAL VALUE AFTER PROC5");
     ELSE
          PROC6;                               -- CALL ART1(1).TT.E
     END IF;

-- MAKE SURE ALL TASKS TERMINATED
     TERM (RT1.TT, '1');
     TERM (RT2.TT, '2');
     TERM (RRT1.RR.TT, '3');
     TERM (RRT2.RR.TT, '4');
     TERM (AT1(1), '5');
     TERM (AT2(1), '6');
     TERM (AT1(2), '7');
     TERM (AT2(2), '8');
     TERM (ART1(1).TT, '9');
     TERM (ART2(1).TT, 'A');
     TERM (ART1(2).TT, 'B');
     TERM (ART2(2).TT, 'C');

     RESULT;

END C64201C;