annotate gcc/testsuite/ada/acats/tests/c3/c3a0009.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 -- C3A0009.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 subprogram references may be passed as parameters using
kono
parents:
diff changeset
28 -- access-to-subprogram types. Check that the passed subprograms may
kono
parents:
diff changeset
29 -- be invoked from within the called subprogram.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- TEST DESCRIPTION:
kono
parents:
diff changeset
32 -- Declare an access to procedure type in a package specification.
kono
parents:
diff changeset
33 -- Declare a root tagged type with the access to procedure type as a
kono
parents:
diff changeset
34 -- component. Declare three primitive procedures for the type that
kono
parents:
diff changeset
35 -- can be referred to by the access to procedure type. Use the access
kono
parents:
diff changeset
36 -- to procedure type to initialize the component of a record.
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- Extend the root type with a private extension in the same package
kono
parents:
diff changeset
39 -- specification. Declare two new primitive subprograms for the extension
kono
parents:
diff changeset
40 -- (in addition to its three inherited subprograms).
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 -- In the main program, declare an operation for the root tagged type
kono
parents:
diff changeset
43 -- which can be passed as an access value to change the initial value
kono
parents:
diff changeset
44 -- of the component. Call the inherited operations indirectly by
kono
parents:
diff changeset
45 -- de-referencing the access value to set value in the extension.
kono
parents:
diff changeset
46 -- Call the primitive function to modify the extension by passing
kono
parents:
diff changeset
47 -- the access value designating the primitive procedure as a parameter.
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 --
kono
parents:
diff changeset
50 -- CHANGE HISTORY:
kono
parents:
diff changeset
51 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 --!
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 package C3A0009_0 is -- Push_Buttons
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 type Button is tagged private;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 -- Type accesses to procedures Push and Default_Response
kono
parents:
diff changeset
60 type Button_Response_Ptr is access procedure
kono
parents:
diff changeset
61 (B : in out Button);
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 procedure Push (B : in out Button); -- to be inherited
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 procedure Set_Response (B : in out Button; -- to be inherited
kono
parents:
diff changeset
66 R : in Button_Response_Ptr);
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 procedure Default_Response (B : in out Button); -- to be inherited
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 type Alert_Button is new Button with private; -- private extension of
kono
parents:
diff changeset
71 -- root tagged type
kono
parents:
diff changeset
72 -- Inherits procedure Push from Button
kono
parents:
diff changeset
73 -- Inherits procedure Set_Response from Button
kono
parents:
diff changeset
74 -- Inherits procedure Default_Response from Button
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 procedure Replace_Action( B: in out Alert_Button );
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 -- type accesses to procedure Default_Action
kono
parents:
diff changeset
79 type Button_Action_Ptr is access procedure;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 -- The following function is needed to set value in the
kono
parents:
diff changeset
82 -- extension's private component.
kono
parents:
diff changeset
83 function Alert (B : in Alert_Button) return Button_Action_Ptr;
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 private
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 type Button is tagged -- root tagged type
kono
parents:
diff changeset
88 record
kono
parents:
diff changeset
89 Response : Button_Response_Ptr
kono
parents:
diff changeset
90 := Default_Response'Access;
kono
parents:
diff changeset
91 end record;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 procedure Default_Action;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 type Alert_Button is new Button with record
kono
parents:
diff changeset
96 Action : Button_Action_Ptr
kono
parents:
diff changeset
97 := Default_Action'Access;
kono
parents:
diff changeset
98 end record;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 end C3A0009_0;
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 -----------------------------------------------------------------------------
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 with TCTouch;
kono
parents:
diff changeset
107 package body C3A0009_0 is
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 procedure Push (B : in out Button) is
kono
parents:
diff changeset
110 begin
kono
parents:
diff changeset
111 TCTouch.Touch( 'P' ); --------------------------------------------- P
kono
parents:
diff changeset
112 -- Invoking subprogram designated by access value
kono
parents:
diff changeset
113 B.Response (B);
kono
parents:
diff changeset
114 end Push;
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 procedure Set_Response (B : in out Button;
kono
parents:
diff changeset
118 R : in Button_Response_Ptr) is
kono
parents:
diff changeset
119 begin
kono
parents:
diff changeset
120 TCTouch.Touch( 'S' ); --------------------------------------------- S
kono
parents:
diff changeset
121 -- Set procedure value in record
kono
parents:
diff changeset
122 B.Response := R;
kono
parents:
diff changeset
123 end Set_Response;
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 procedure Default_Response (B : in out Button) is
kono
parents:
diff changeset
127 begin
kono
parents:
diff changeset
128 TCTouch.Touch( 'D' ); --------------------------------------------- D
kono
parents:
diff changeset
129 end Default_Response;
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 procedure Default_Action is
kono
parents:
diff changeset
133 begin
kono
parents:
diff changeset
134 TCTouch.Touch( 'd' ); --------------------------------------------- d
kono
parents:
diff changeset
135 end Default_Action;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 procedure Replacement_Action is
kono
parents:
diff changeset
138 begin
kono
parents:
diff changeset
139 TCTouch.Touch( 'r' ); --------------------------------------------- r
kono
parents:
diff changeset
140 end Replacement_Action;
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 procedure Replace_Action( B: in out Alert_Button ) is
kono
parents:
diff changeset
143 begin
kono
parents:
diff changeset
144 TCTouch.Touch( 'R' ); --------------------------------------------- R
kono
parents:
diff changeset
145 B.Action := Replacement_Action'Access;
kono
parents:
diff changeset
146 end Replace_Action;
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 function Alert (B : in Alert_Button) return Button_Action_Ptr is
kono
parents:
diff changeset
149 begin
kono
parents:
diff changeset
150 TCTouch.Touch( 'A' ); --------------------------------------------- A
kono
parents:
diff changeset
151 return (B.Action);
kono
parents:
diff changeset
152 end Alert;
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 end C3A0009_0;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 -----------------------------------------------------------------------------
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 with C3A0009_0;
kono
parents:
diff changeset
159 package C3A0009_1 is -- Emergency_Items
kono
parents:
diff changeset
160 package Push_Buttons renames C3A0009_0;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 procedure Emergency (B : in out Push_Buttons.Button);
kono
parents:
diff changeset
163 end C3A0009_1;
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 with TCTouch;
kono
parents:
diff changeset
166 package body C3A0009_1 is -- Emergency_Items
kono
parents:
diff changeset
167 procedure Emergency (B : in out Push_Buttons.Button) is
kono
parents:
diff changeset
168 begin
kono
parents:
diff changeset
169 TCTouch.Touch( 'E' ); ------------------------------------------- E
kono
parents:
diff changeset
170 end Emergency;
kono
parents:
diff changeset
171 end C3A0009_1;
kono
parents:
diff changeset
172 -----------------------------------------------------------------------------
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 with Report;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 with C3A0009_0, C3A0009_1;
kono
parents:
diff changeset
177 with TCTouch;
kono
parents:
diff changeset
178 procedure C3A0009 is
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 package Push_Buttons renames C3A0009_0;
kono
parents:
diff changeset
181 package Emergency_Items renames C3A0009_1;
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 Black_Button : Push_Buttons.Alert_Button;
kono
parents:
diff changeset
184 Alert_Ptr : Push_Buttons.Button_Action_Ptr;
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 begin
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 Report.Test ("C3A0009", "Check that subprogram references may be passed "
kono
parents:
diff changeset
189 & "as parameters using access-to-subprogram types. "
kono
parents:
diff changeset
190 & "Check that the passed subprograms may be "
kono
parents:
diff changeset
191 & "invoked from within the called subprogram");
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 Push_Buttons.Push( Black_Button );
kono
parents:
diff changeset
195 Push_Buttons.Alert( Black_Button ).all;
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 TCTouch.Validate( "PDAd", "Default operation set" );
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 -- Call inherited operations Set_Response and Push to set
kono
parents:
diff changeset
200 -- Emergency value in the extension.
kono
parents:
diff changeset
201 Push_Buttons.Set_Response (Black_Button, Emergency_Items.Emergency'Access);
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 Push_Buttons.Push( Black_Button );
kono
parents:
diff changeset
205 Push_Buttons.Alert( Black_Button ).all;
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 TCTouch.Validate( "SPEAd", "Altered Response set" );
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 -- Call primitive operation to set action value in the extension.
kono
parents:
diff changeset
210 Push_Buttons.Replace_Action( Black_Button );
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 Push_Buttons.Push( Black_Button );
kono
parents:
diff changeset
214 Push_Buttons.Alert( Black_Button ).all;
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 TCTouch.Validate( "RPEAr", "Altered Action set" );
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 Report.Result;
kono
parents:
diff changeset
219 end C3A0009;