annotate gcc/testsuite/ada/acats/tests/c9/c940011.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- C940011.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that, in the body of a protected object created by the execution
kono
parents:
diff changeset
28 -- of an allocator, external calls to other protected objects via
kono
parents:
diff changeset
29 -- the access type are correctly performed
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- TEST DESCRIPTION:
kono
parents:
diff changeset
32 -- Use a subset of the simulation of the freeway on-ramp described in
kono
parents:
diff changeset
33 -- c940005. In this case an array of access types is built with pointers
kono
parents:
diff changeset
34 -- to successive ramps. The external calls within the protected
kono
parents:
diff changeset
35 -- objects are made via the index into the array. Routines which refer
kono
parents:
diff changeset
36 -- to the "previous" ramp and the "next" ramp are exercised. (Note: The
kono
parents:
diff changeset
37 -- first and last ramps are assumed to be dummies and no first/last
kono
parents:
diff changeset
38 -- condition code is included)
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- CHANGE HISTORY:
kono
parents:
diff changeset
42 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 --!
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 with Report;
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 procedure C940011 is
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 type Ramp;
kono
parents:
diff changeset
53 type acc_Ramp is access Ramp;
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 subtype Ramp_Index is integer range 1..4;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 -- Weighted load given to each potential problem area and accumulated
kono
parents:
diff changeset
59 type Load_Factor is range 0..8;
kono
parents:
diff changeset
60 Clear_Level : constant Load_Factor := 0;
kono
parents:
diff changeset
61 Moderate_Level : constant Load_Factor := 3;
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 --================================================================
kono
parents:
diff changeset
64 -- Only the Routines that are used in this test are shown
kono
parents:
diff changeset
65 --
kono
parents:
diff changeset
66 protected type Ramp is
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 procedure Set_Index (Index : Ramp_Index);
kono
parents:
diff changeset
69 procedure Set_Local_Overload (Sensor_Level : Load_Factor);
kono
parents:
diff changeset
70 function Local_Overload return Load_Factor;
kono
parents:
diff changeset
71 procedure Notify;
kono
parents:
diff changeset
72 function Next_Ramp_Overload return Load_Factor;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 private
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 This_Ramp : Ramp_Index;
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 Next_Ramp_Alert : Boolean := false; -- Next Ramp is in trouble?
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 -- Current state of the various Sample Points
kono
parents:
diff changeset
81 Local_State : Load_Factor := Clear_Level;
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 end Ramp;
kono
parents:
diff changeset
84 --================================================================
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 -- Build a set of Ramp objects and an array of pointers to them
kono
parents:
diff changeset
87 --
kono
parents:
diff changeset
88 Ramp_Array : array (Ramp_Index) of acc_Ramp := (Ramp_Index => new Ramp);
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 --================================================================
kono
parents:
diff changeset
91 protected body Ramp is
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 procedure Set_Index (Index : Ramp_Index) is
kono
parents:
diff changeset
94 begin
kono
parents:
diff changeset
95 This_Ramp := Index;
kono
parents:
diff changeset
96 end Set_Index;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 -- These Set/Clear routines are triggered by real-time sensors that
kono
parents:
diff changeset
99 -- reflect traffic state
kono
parents:
diff changeset
100 procedure Set_Local_Overload(Sensor_Level : Load_Factor) is
kono
parents:
diff changeset
101 begin
kono
parents:
diff changeset
102 if Local_State = Clear_Level then
kono
parents:
diff changeset
103 -- Notify "previous" ramp to check this one for current state.
kono
parents:
diff changeset
104 -- Subsequent changes in state will not send an alert
kono
parents:
diff changeset
105 -- When the situation clears another routine performs the
kono
parents:
diff changeset
106 -- all_clear notification. (not shown)
kono
parents:
diff changeset
107 -- EXTERNAL CALL OF PROCEDURE FROM PROCEDURE
kono
parents:
diff changeset
108 Ramp_Array(This_Ramp - 1).Notify; -- index to previous ramp
kono
parents:
diff changeset
109 end if;
kono
parents:
diff changeset
110 Local_State := Sensor_Level;
kono
parents:
diff changeset
111 null; --::::: Start local meter if not already started
kono
parents:
diff changeset
112 end Set_Local_Overload;
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 function Local_Overload return Load_Factor is
kono
parents:
diff changeset
115 begin
kono
parents:
diff changeset
116 return Local_State;
kono
parents:
diff changeset
117 end Local_Overload;
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 -- This is notification from the next ramp that it is in
kono
parents:
diff changeset
120 -- overload. With this provision we only need to sample the next
kono
parents:
diff changeset
121 -- ramp during adverse conditions.
kono
parents:
diff changeset
122 procedure Notify is
kono
parents:
diff changeset
123 begin
kono
parents:
diff changeset
124 Next_Ramp_Alert := true;
kono
parents:
diff changeset
125 end Notify;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 function Next_Ramp_Overload return Load_Factor is
kono
parents:
diff changeset
128 begin
kono
parents:
diff changeset
129 if Next_Ramp_Alert then
kono
parents:
diff changeset
130 -- EXTERNAL FUNCTION CALL FROM FUNCTION
kono
parents:
diff changeset
131 -- Get next ramp's current state
kono
parents:
diff changeset
132 return Ramp_Array(This_Ramp + 1).Local_Overload;
kono
parents:
diff changeset
133 else
kono
parents:
diff changeset
134 return Clear_Level;
kono
parents:
diff changeset
135 end if;
kono
parents:
diff changeset
136 end Next_Ramp_Overload;
kono
parents:
diff changeset
137 end Ramp;
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 --================================================================
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 begin
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 Report.Test ("C940011", "Protected Objects created by allocators: " &
kono
parents:
diff changeset
146 "external calls via access types");
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 -- Initialize each Ramp
kono
parents:
diff changeset
149 for i in Ramp_Index loop
kono
parents:
diff changeset
150 Ramp_Array(i).Set_Index (i);
kono
parents:
diff changeset
151 end loop;
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 -- Test driver. This is ALL test control code
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 -- Simulate calls to the protected functions and procedures
kono
parents:
diff changeset
156 -- external calls. (do not call the "dummy" end ramps)
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 -- Simple Call
kono
parents:
diff changeset
159 if Ramp_Array(2).Next_Ramp_Overload /= Clear_level then
kono
parents:
diff changeset
160 Report.Failed ("Primary call incorrect");
kono
parents:
diff changeset
161 end if;
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 -- Call which results in an external procedure call via the array
kono
parents:
diff changeset
164 -- index from within the protected object
kono
parents:
diff changeset
165 Ramp_Array(3).Set_Local_Overload (Moderate_Level);
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 -- Call which results in an external function call via the array
kono
parents:
diff changeset
168 -- index from within the protected object
kono
parents:
diff changeset
169 if Ramp_Array(2).Next_Ramp_Overload /= Moderate_level then
kono
parents:
diff changeset
170 Report.Failed ("Secondary call incorrect");
kono
parents:
diff changeset
171 end if;
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 Report.Result;
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 end C940011;