annotate gcc/testsuite/ada/acats/tests/cc/cc30001.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 -- CC30001.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 if a non-overriding primitive subprogram is declared for
kono
parents:
diff changeset
28 -- a type derived from a formal derived tagged type, the copy of that
kono
parents:
diff changeset
29 -- subprogram in an instance can override a subprogram inherited from the
kono
parents:
diff changeset
30 -- actual type.
kono
parents:
diff changeset
31 --
kono
parents:
diff changeset
32 -- TEST DESCRIPTION:
kono
parents:
diff changeset
33 -- User writes program to handle both mail messages and system messages.
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- Mail messages are created by instantiating a generic "mail" package
kono
parents:
diff changeset
36 -- with a root message type. System messages are created by
kono
parents:
diff changeset
37 -- instantiating the generic with a system message type derived from the
kono
parents:
diff changeset
38 -- root in a separate package. The system message type has a primitive
kono
parents:
diff changeset
39 -- subprogram called Send.
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- Inside the generic, a "mail" type is derived from the generic formal
kono
parents:
diff changeset
42 -- derived type, and a "Send" operation is declared.
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 -- Declare a root tagged type T. Declare a generic package with a formal
kono
parents:
diff changeset
45 -- derived type using the root tagged type as ancestor. In the generic,
kono
parents:
diff changeset
46 -- derive a type from the formal derived type and declare a primitive
kono
parents:
diff changeset
47 -- subprogram for it. In a separate package, declare a derivative DT of
kono
parents:
diff changeset
48 -- the root tagged type T and declare a primitive subprogram which is
kono
parents:
diff changeset
49 -- type conformant with (and hence, overridable for) the primitive
kono
parents:
diff changeset
50 -- declared in the generic. Instantiate the generic for DT. Make both
kono
parents:
diff changeset
51 -- dispatching and non-dispatching calls to the primitive subprogram. In
kono
parents:
diff changeset
52 -- both cases the version of the subprogram in the instance should be
kono
parents:
diff changeset
53 -- called (since it overrides the implementation inherited from the
kono
parents:
diff changeset
54 -- actual).
kono
parents:
diff changeset
55 --
kono
parents:
diff changeset
56 --
kono
parents:
diff changeset
57 -- CHANGE HISTORY:
kono
parents:
diff changeset
58 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
59 -- 13 Apr 95 SAIC Replaced call involving instance for root tagged
kono
parents:
diff changeset
60 -- type with a dispatching call involving instance
kono
parents:
diff changeset
61 -- for derived type. Updated commentary. Moved
kono
parents:
diff changeset
62 -- instantiations (and related commentary) to
kono
parents:
diff changeset
63 -- library-level to avoid accessibility violation.
kono
parents:
diff changeset
64 -- Commented out instantiation for root tagged type.
kono
parents:
diff changeset
65 -- 27 Feb 97 PWB.CTA Added elaboration pragma.
kono
parents:
diff changeset
66 --!
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 package CC30001_0 is -- Root message type.
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 type Msg_Type is tagged record
kono
parents:
diff changeset
71 Text : String (1 .. 20);
kono
parents:
diff changeset
72 Message_Sent : Boolean;
kono
parents:
diff changeset
73 end record;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 end CC30001_0;
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 --==================================================================--
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 with CC30001_0; -- Root message type.
kono
parents:
diff changeset
82 generic -- Generic "mail" package.
kono
parents:
diff changeset
83 type Message is new CC30001_0.Msg_Type with private;
kono
parents:
diff changeset
84 package CC30001_1 is
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 type Mail_Type is new Message with record -- Derived from formal type.
kono
parents:
diff changeset
87 To : String (1 .. 8);
kono
parents:
diff changeset
88 end record;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 procedure Send (M : in out Mail_Type); -- For this test, this version
kono
parents:
diff changeset
91 -- of Send should be called in
kono
parents:
diff changeset
92 -- ... Other operations. -- all cases.
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 end CC30001_1;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 --==================================================================--
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 package body CC30001_1 is
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 procedure Send (M : in out Mail_Type) is
kono
parents:
diff changeset
103 begin
kono
parents:
diff changeset
104 -- ... Code to send message omitted for brevity.
kono
parents:
diff changeset
105 M.Message_Sent := True;
kono
parents:
diff changeset
106 end Send;
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 end CC30001_1;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 --==================================================================--
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 with CC30001_0; -- Root message type.
kono
parents:
diff changeset
115 package CC30001_2 is -- System message type and operations.
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 type Signal_Type is (Note, Warning, Error);
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 type Sys_Message is new CC30001_0.Msg_Type with record -- Derived from
kono
parents:
diff changeset
120 Signal : Signal_Type := Warning; -- root type.
kono
parents:
diff changeset
121 end record;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 procedure Send (Item : in out Sys_Message); -- For this test, this version
kono
parents:
diff changeset
124 -- of Send should never be
kono
parents:
diff changeset
125 -- ... Other operations. -- called (it will have been
kono
parents:
diff changeset
126 -- overridden).
kono
parents:
diff changeset
127 end CC30001_2;
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 --==================================================================--
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 package body CC30001_2 is
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 procedure Send (Item : in out Sys_Message) is
kono
parents:
diff changeset
136 begin
kono
parents:
diff changeset
137 -- ... Code to send message omitted for brevity.
kono
parents:
diff changeset
138 Item.Message_Sent := False; -- Ensure this procedure gives a different
kono
parents:
diff changeset
139 end Send; -- result than CC30001_1.Send.
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 end CC30001_2;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 --==================================================================--
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 -- User first sets up support for mail messages by instantiating the
kono
parents:
diff changeset
148 -- generic mail package for the root message type. An operation "Send" is
kono
parents:
diff changeset
149 -- declared for the mail message type in the instance.
kono
parents:
diff changeset
150 --
kono
parents:
diff changeset
151 -- with CC30001_0; -- Root message type.
kono
parents:
diff changeset
152 -- with CC30001_1; -- Generic "mail" package.
kono
parents:
diff changeset
153 -- package Mail_Messages is new CC30001_1 (CC30001_0.Msg_Type);
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 --==================================================================--
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 -- Next, the user sets up support for system messages by instantiating the
kono
parents:
diff changeset
160 -- generic mail package with the system message type. An operation "Send"
kono
parents:
diff changeset
161 -- is declared for the "system" mail message type in the instance. This
kono
parents:
diff changeset
162 -- operation overrides the "Send" operation inherited from the system
kono
parents:
diff changeset
163 -- message type actual (a situation the user may not have intended).
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 with CC30001_1; -- Generic "mail" package.
kono
parents:
diff changeset
166 with CC30001_2; -- System message type and operations.
kono
parents:
diff changeset
167 pragma Elaborate (CC30001_1);
kono
parents:
diff changeset
168 package CC30001_3 is new CC30001_1 (CC30001_2.Sys_Message);
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 --==================================================================--
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 with CC30001_2; -- System message type and operations.
kono
parents:
diff changeset
174 with CC30001_3; -- Instance with mail type and operations.
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 with Report;
kono
parents:
diff changeset
177 procedure CC30001 is
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 package System_Messages renames CC30001_3;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 Sys_Msg1 : System_Messages.Mail_Type := (Text => "System shutting down",
kono
parents:
diff changeset
183 Signal => CC30001_2.Warning,
kono
parents:
diff changeset
184 To => "AllUsers",
kono
parents:
diff changeset
185 Message_Sent => False);
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 Sys_Msg2 : System_Messages.Mail_Type'Class := Sys_Msg1;
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 use System_Messages, CC30001_2; -- All versions of "Send"
kono
parents:
diff changeset
191 -- directly visible.
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 begin
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 Report.Test ("CC30001", "Check that if a non-overriding primitive " &
kono
parents:
diff changeset
196 "subprogram is declared for a type derived from a formal " &
kono
parents:
diff changeset
197 "derived tagged type, the copy of that subprogram in an " &
kono
parents:
diff changeset
198 "instance can override a subprogram inherited from the " &
kono
parents:
diff changeset
199 "actual type");
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 Send (Sys_Msg1); -- Calls version declared in instance (version declared
kono
parents:
diff changeset
203 -- in CC30001_2 has been overridden).
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 if not Sys_Msg1.Message_Sent then
kono
parents:
diff changeset
206 Report.Failed ("Non-dispatching call: instance operation not called");
kono
parents:
diff changeset
207 end if;
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 Send (Sys_Msg2); -- Calls version declared in instance (version declared
kono
parents:
diff changeset
211 -- in CC30001_2 has been overridden).
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 if not Sys_Msg2.Message_Sent then
kono
parents:
diff changeset
214 Report.Failed ("Dispatching call: instance operation not called");
kono
parents:
diff changeset
215 end if;
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 Report.Result;
kono
parents:
diff changeset
219 end CC30001;