1-- C95085H.ADA
2
3--                             Grant of Unlimited Rights
4--
5--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7--     unlimited rights in the software and documentation contained herein.
8--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making
9--     this public release, the Government intends to confer upon all
10--     recipients unlimited rights  equal to those held by the Government.
11--     These rights include rights to use, duplicate, release or disclose the
12--     released technical data and computer software in whole or in part, in
13--     any manner and for any purpose whatsoever, and to have or permit others
14--     to do so.
15--
16--                                    DISCLAIMER
17--
18--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19--     DISCLOSED ARE AS IS.  THE GOVERNMENT 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.
24--*
25-- CHECK THAT CONSTRAINT_ERROR IS RAISED UNDER THE APPROPRIATE
26-- CIRCUMSTANCES FOR ACCESS PARAMETERS IN ENTRY CALLS, NAMELY WHEN
27-- THE ACTUAL INDEX BOUNDS OR DISCRIMINANTS ARE NOT EQUAL
28-- TO THE FORMAL CONSTRAINTS BEFORE THE CALL (FOR IN AND IN OUT
29-- MODES), AND WHEN THE FORMAL CONSTRAINTS ARE NOT EQUAL TO THE
30-- ACTUAL CONSTRAINTS UPON RETURN (FOR IN OUT AND OUT MODES).
31
32--       (E) AFTER RETURN, IN OUT MODE, STATIC LIMITED PRIVATE
33--           DISCRIMINANTS.
34
35-- JWC 10/23/85
36
37WITH REPORT; USE REPORT;
38PROCEDURE C95085H IS
39
40BEGIN
41     TEST ("C95085H", "CHECK THAT CONSTRAINT_ERROR IS RAISED " &
42                      "APPROPRIATELY FOR ACCESS PARAMETERS");
43
44     --------------------------------------------------
45
46     DECLARE
47
48          CALLED : BOOLEAN := FALSE;
49
50          PACKAGE PKG IS
51               SUBTYPE INT IS INTEGER RANGE 0..10;
52               SUBTYPE CHAR IS CHARACTER RANGE 'A' .. 'C';
53               TYPE T (I : INT := 0; C : CHAR := 'A') IS
54                    LIMITED PRIVATE;
55          PRIVATE
56               TYPE T (I : INT := 0; C : CHAR := 'A') IS
57                    RECORD
58                         J : INTEGER;
59                         CASE C IS
60                              WHEN 'A' =>
61                                   K : INTEGER;
62                              WHEN 'B' =>
63                                   S : STRING (1..I);
64                              WHEN OTHERS =>
65                                   NULL;
66                         END CASE;
67                    END RECORD;
68          END PKG;
69          USE PKG;
70
71          TYPE A IS ACCESS T;
72
73          V : A (2,'B') := NEW T (2,'B');
74
75          TASK TSK IS
76               ENTRY E (X : IN OUT A);
77          END TSK;
78
79          TASK BODY TSK IS
80          BEGIN
81               SELECT
82                    ACCEPT E (X : IN OUT A) DO
83                         CALLED := TRUE;
84                         X := NEW T (2,'A');
85                    END E;
86               OR
87                    TERMINATE;
88               END SELECT;
89          EXCEPTION
90               WHEN OTHERS =>
91                    FAILED ("EXCEPTION RAISED IN TASK BODY");
92          END TSK;
93
94     BEGIN
95
96          TSK.E (V);
97          FAILED ("EXCEPTION NOT RAISED AFTER RETURN");
98
99     EXCEPTION
100          WHEN CONSTRAINT_ERROR =>
101               IF NOT CALLED THEN
102                    FAILED ("EXCEPTION RAISED BEFORE CALL");
103               END IF;
104          WHEN OTHERS =>
105               FAILED ("WRONG EXCEPTION RAISED");
106     END;
107
108     --------------------------------------------------
109
110     RESULT;
111END C95085H;
112