1-- C52009A.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 A RECORD VARIABLE DESIGNATED BY AN ACCESS VALUE CANNOT
26-- HAVE ITS DISCRIMINANT ALTERED, EVEN BY A COMPLETE RECORD
27-- ASSIGNMENT, AND EVEN THOUGH THE THE TARGET ACCESS VARIABLE IS NOT
28-- CONSTRAINED TO A SPECIFIC DISCRIMINANT VALUE.  ATTEMPTING TO
29-- CHANGE THE TARGET'S DISCRIMINANT RAISES CONSTRAINT_ERROR AND LEAVES
30-- THE TARGET RECORD UNALTERED.  THIS  TEST USES STATIC DISCRIMINANT
31-- VALUES.
32
33-- ASL 6/25/81
34-- SPS 10/26/82
35
36WITH REPORT;
37PROCEDURE C52009A IS
38
39     USE REPORT;
40
41     TYPE REC (DISC : INTEGER) IS
42          RECORD
43               COMP : INTEGER;
44          END RECORD;
45
46     TYPE REC_NAME IS ACCESS REC;
47
48     HR : REC_NAME := NEW REC'(5,0);
49
50BEGIN
51
52     TEST ("C52009A", "CANNOT CHANGE, THROUGH ASSIGNMENT, THE " &
53           "(STATIC) DISCRIMINANT VALUE OF A RECORD DESIGNATED " &
54           "BY AN ACCESS VALUE");
55
56     BEGIN
57          HR.ALL := (DISC => 5, COMP => 3);
58          IF HR.ALL /= (5,3) THEN
59               FAILED ("LEGAL ASSIGNMENT FAILED");
60          END IF;
61          HR.ALL := (DISC => 4, COMP => 2);
62          FAILED ("RECORD ASSIGNED VALUE WITH DIFFERENT DISCRIMINANT " &
63                  "VALUE");
64     EXCEPTION
65          WHEN CONSTRAINT_ERROR =>
66               IF HR.ALL /= (5,3) THEN
67                    FAILED ("TARGET RECORD VALUE ALTERED BY " &
68                            "ASSIGNMENT WITH A DIFFERENT " &
69                            "DISCRIMINANT VALUE EVEN AFTER " &
70                            "CONSTRAINT_ERROR RAISED");
71               END IF;
72          WHEN OTHERS => FAILED ("WRONG EXCEPTION");
73     END;
74
75     RESULT;
76
77END C52009A;
78