1-- C43107A.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 AN EXPRESSION ASSOCIATED WITH MORE THAN ONE RECORD
26-- COMPONENT IS EVALUATED ONCE FOR EACH ASSOCIATED COMPONENT.
27
28-- EG  02/14/84
29
30WITH REPORT;
31
32PROCEDURE C43107A IS
33
34     USE REPORT;
35
36BEGIN
37
38     TEST("C43107A","CHECK THAT AN EXPRESSION WITH MORE THAN ONE " &
39                    "RECORD COMPONENT IS EVALUATED ONCE FOR EACH " &
40                    "ASSOCIATED COMPONENT");
41
42     BEGIN
43
44CASE_A :  DECLARE
45
46               TYPE T1 IS ARRAY(1 .. 2) OF INTEGER;
47               TYPE R1 IS
48                    RECORD
49                         A : T1;
50                         B : INTEGER;
51                         C : T1;
52                         D : INTEGER;
53                         E : INTEGER;
54                    END RECORD;
55
56               A1   : R1;
57               CNTR : INTEGER := 0;
58
59               FUNCTION FUN1 (A : T1) RETURN T1 IS
60               BEGIN
61                    CNTR := IDENT_INT(CNTR+1);
62                    RETURN A;
63               END FUN1;
64
65               FUNCTION FUN2 (A : INTEGER) RETURN INTEGER IS
66               BEGIN
67                    CNTR := CNTR+1;
68                    RETURN IDENT_INT(A);
69               END FUN2;
70
71          BEGIN
72
73               A1 := (A | C => FUN1((-1, -2)), OTHERS => FUN2(-3)+1);
74               IF CNTR /= 5 THEN
75                    FAILED ("CASE A : INCORRECT NUMBER OF EVALUATIONS" &
76                            " OF RECORD ASSOCIATED COMPONENTS");
77               END IF;
78               IF A1.A /= (-1, -2) OR A1.C /= (-1, -2) OR
79                  A1.B /= -2 OR A1.D /= -2 OR A1.E /= -2 THEN
80                    FAILED ("CASE A : INCORRECT VALUES IN RECORD");
81               END IF;
82
83          END CASE_A;
84
85CASE_B :  DECLARE
86
87               TYPE T2 IS ACCESS INTEGER;
88               TYPE R2 IS
89                    RECORD
90                         A : T2;
91                         B : INTEGER;
92                         C : T2;
93                         D : INTEGER;
94                         E : INTEGER;
95                    END RECORD;
96
97               B1   : R2;
98               CNTR : INTEGER := 0;
99
100               FUNCTION FUN3 RETURN INTEGER IS
101               BEGIN
102                    CNTR := CNTR+1;
103                    RETURN IDENT_INT(2);
104               END FUN3;
105
106          BEGIN
107
108               B1 := (A | C => NEW INTEGER'(-1),
109                      B | D | E => FUN3);
110               IF B1.A = B1.C OR CNTR /= 3 THEN
111                    FAILED ("CASE B : INCORRECT NUMBER OF EVALUATION" &
112                            " OF RECORD ASSOCIATED COMPONENTS");
113               END IF;
114               IF B1.B /= 2 OR B1.D /= 2 OR B1.E /= 2 OR
115                  B1.A = NULL OR B1.C = NULL OR B1.A = B1.C THEN
116                    FAILED ("CASE B : INCORRECT VALUES IN RECORD");
117               END IF;
118
119          END CASE_B;
120
121     END;
122
123     RESULT;
124
125END C43107A;
126