1-- C58004D.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 RETURN STATEMENT TERMINATES EXECUTION
26--    OF THE INNERMOST ENCLOSING SUBPROGRAM.
27
28-- CHECKS GENERIC SUBPROGRAMS.
29
30-- SPS 3/7/83
31-- JRK 1/31/84
32
33WITH REPORT;
34PROCEDURE C58004D IS
35
36     USE REPORT;
37
38     I1, I2 : INTEGER;
39
40     GENERIC
41     PROCEDURE ADDM (IA1 : IN OUT INTEGER; IA2 : IN INTEGER);
42
43     PROCEDURE ADDM (IA1 : IN OUT INTEGER; IA2 : IN INTEGER) IS
44
45          GENERIC
46          PROCEDURE MULT (IM1 : IN OUT INTEGER; IM2 : IN INTEGER);
47
48          PROCEDURE MULT (IM1 : IN OUT INTEGER; IM2 : IN INTEGER) IS
49          BEGIN
50               IM1 := IM1 * IM2;
51
52               IF IM1 > 0 THEN RETURN;
53               END IF;
54
55               IM1 := 0;
56          END MULT;
57
58          PROCEDURE MLT IS NEW MULT;
59
60     BEGIN
61          MLT (IA1, IA2);
62          IA1 := IA1 + IA2;
63
64          IF IA1 > 0 THEN RETURN;
65          END IF;
66
67          IA1 := 0;
68     END ADDM;
69
70     PROCEDURE ADM IS NEW ADDM;
71
72BEGIN
73     TEST ("C58004D","CHECK THAT RETURN TERMINATES EXECUTION OF ONLY" &
74           " THE INNERMOST ENCLOSING GENERIC SUBPROGRAM");
75
76     I1 := 2;
77     I2 := 3;
78     ADM (I1,I2);     -- SAME AS I1 := (I1 * I2) + I2
79
80     IF I1 = 0 THEN
81          FAILED ("RETURN DOES NOT TERMINATE SUBPROGRAM");
82     ELSIF I1 = 6 THEN
83          FAILED
84          ("RETURN TERMINATES ALL SUBPROGRAMS NOT JUST INNERMOST");
85     ELSIF I1 /= 9 THEN
86          FAILED ("RETURN STATEMENT NOT WORKING CORRECTLY");
87     END IF;
88
89     RESULT;
90END C58004D;
91