3 -- Grant of Unlimited Rights
5 -- The Ada Conformity Assessment Authority (ACAA) holds unlimited
6 -- rights in the software and documentation contained herein. Unlimited
7 -- rights are the same as those granted by the U.S. Government for older
8 -- parts of the Ada Conformity Assessment Test Suite, and are defined
9 -- in DFAR 252.227-7013(a)(19). By making this public release, the ACAA
10 -- intends to confer upon all recipients unlimited rights equal to those
11 -- held by the ACAA. These rights include rights to use, duplicate,
12 -- release or disclose the released technical data and computer software
13 -- in whole or in part, in any manner and for any purpose whatsoever, and
14 -- to have or permit others to do so.
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE ACAA MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- Check that per-object expressions are evaluated as specified for entry
28 -- families and protected components. (Defect Report 8652/0002,
29 -- as reflected in Technical Corrigendum 1, RM95 3.6(22/1), 3.8(18/1), and
33 -- 9 FEB 2001 PHL Initial version.
34 -- 29 JUN 2002 RLB Readied for release.
41 type Rec
(D1
, D2
: Positive) is
48 function Chk
(Poe
: Integer; Value
: Integer; Message
: String)
52 Failed
(Message
& ": Poe is " & Integer'Image (Poe
));
57 function F1
return Integer is
59 F1_Poe
:= F1_Poe
- Ident_Int
(1);
64 type T
is limited private;
65 with function Is_Ok
(X
: T
;
68 Param3
: Integer) return Boolean;
76 Chk1
: Boolean := Chk
(F1_Poe
, 17, "F1 evaluated");
77 X
: Poe
; -- F1 evaluated
78 Y
: Poe
; -- F1 evaluated
79 Chk2
: Boolean := Chk
(F1_Poe
, 15, "F1 not evaluated");
81 if not Is_Ok
(T
(X
), 16, 16, 17) or
82 not Is_Ok
(T
(Y
), 15, 15, 17) then
83 Failed
("Discriminant values not correct - 0");
94 if not Is_Ok
(T
(X
), 14, 14, 17) then
95 Failed
("Discriminant values not correct - 1");
100 Failed
("Unexpected exception - 1");
104 type Acc_Poe
is access Poe
;
109 if not Is_Ok
(T
(X
.all), 13, 13, 17) then
110 Failed
("Discriminant values not correct - 2");
115 Failed
("Unexpected exception raised - 2");
122 if not Is_Ok
(T
(X
), 12, 12, 17) then
123 Failed
("Discriminant values not correct - 3");
127 Failed
("Unexpected exception raised - 3");
131 type Arr
is array (1 .. 2) of Poe
;
134 if Is_Ok
(T
(X
(1)), 11, 11, 17) and then
135 Is_Ok
(T
(X
(2)), 10, 10, 17) then
137 elsif Is_Ok
(T
(X
(2)), 11, 11, 17) and then
138 Is_Ok
(T
(X
(1)), 10, 10, 17) then
141 Failed
("Discriminant values not correct - 4");
145 Failed
("Unexpected exception raised - 4");
155 if Is_Ok
(T
(X
.C1
), 8, 8, 17) and then
156 Is_Ok
(T
(X
.C2
), 9, 9, 17) then
158 elsif Is_Ok
(T
(X
.C2
), 8, 8, 17) and then
159 Is_Ok
(T
(X
.C1
), 9, 9, 17) then
162 Failed
("Discriminant values not correct - 5");
166 Failed
("Unexpected exception raised - 5");
170 type Drec
is new Poe
;
173 if not Is_Ok
(T
(X
), 7, 7, 17) then
174 Failed
("Discriminant values not correct - 6");
178 Failed
("Unexpected exception raised - 6");
186 "Check evaluation of discriminant expressions " &
187 "when the constraint depends on a discriminant, " &
188 "and the discriminants have defaults - discriminant-dependent" &
189 "entry families and protected components");
192 Comment
("Discriminant-dependent entry families for task types");
197 task type Poe
(D3
: Positive := F1
) is
198 entry E
(D3
.. F1
); -- F1 evaluated
199 entry Is_Ok
(D3
: Integer;
208 accept Is_Ok
(D3
: Integer;
216 -- Can't think of a better way to check the
217 -- bounds of the entry family.
219 Cnt
:= E
(E_First
)'Count;
220 Cnt
:= E
(E_Last
)'Count;
222 when Constraint_Error
=>
227 Cnt
:= E
(E_First
- 1)'Count;
231 when Constraint_Error
=>
238 Cnt
:= E
(E_Last
+ 1)'Count;
242 when Constraint_Error
=>
262 (C
: Poe
; D3
: Integer; E_First
: Integer; E_Last
: Integer)
266 C
.Is_Ok
(D3
, E_First
, E_Last
, Ok
);
270 procedure Chk
is new Check
(Poe
, Is_Ok
);
277 Comment
("Discriminant-dependent entry families for protected types");
282 protected type Poe
(D3
: Integer := F1
) is
283 entry E
(D3
.. F1
); -- F1 evaluated
284 function Is_Ok
(D3
: Integer; E_First
: Integer; E_Last
: Integer)
287 protected body Poe
is
288 entry E
(for I
in D3
.. F1
) when True is
292 function Is_Ok
(D3
: Integer; E_First
: Integer; E_Last
: Integer)
297 -- Can't think of a better way to check the
298 -- bounds of the entry family.
300 Cnt
:= E
(E_First
)'Count;
301 Cnt
:= E
(E_Last
)'Count;
303 when Constraint_Error
=>
307 Cnt
:= E
(E_First
- 1)'Count;
310 when Constraint_Error
=>
316 Cnt
:= E
(E_Last
+ 1)'Count;
319 when Constraint_Error
=>
332 (C
: Poe
; D3
: Integer; E_First
: Integer; E_Last
: Integer)
335 return C
.Is_Ok
(D3
, E_First
, E_Last
);
338 procedure Chk
is new Check
(Poe
, Is_Ok
);
344 Comment
("Protected components");
349 protected type Poe
(D3
: Integer := F1
) is
350 function C1_D1
return Integer;
351 function C1_D2
return Integer;
353 C1
: Rec
(D3
, F1
); -- F1 evaluated
355 protected body Poe
is
356 function C1_D1
return Integer is
360 function C1_D2
return Integer is
366 function Is_Ok
(C
: Poe
; D3
: Integer; C1_D1
: Integer; C1_D2
: Integer)
369 return C
.D3
= D3
and C
.C1_D1
= C1_D1
and C
.C1_D2
= C1_D2
;
372 procedure Chk
is new Check
(Poe
, Is_Ok
);
382 Failed
("Unexpected exception");