annotate gcc/ada/doc/gnat_ugn/elaboration_order_handling_in_gnat.rst @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 .. role:: switch(samp)
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 .. |with| replace:: *with*
kono
parents:
diff changeset
4 .. |withs| replace:: *with*\ s
kono
parents:
diff changeset
5 .. |withed| replace:: *with*\ ed
kono
parents:
diff changeset
6 .. |withing| replace:: *with*\ ing
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 .. -- Example: A |withing| unit has a |with| clause, it |withs| a |withed| unit
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 .. _Elaboration_Order_Handling_in_GNAT:
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 **********************************
kono
parents:
diff changeset
14 Elaboration Order Handling in GNAT
kono
parents:
diff changeset
15 **********************************
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 .. index:: Order of elaboration
kono
parents:
diff changeset
18 .. index:: Elaboration control
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 This appendix describes the handling of elaboration code in Ada and GNAT, and
kono
parents:
diff changeset
21 discusses how the order of elaboration of program units can be controlled in
kono
parents:
diff changeset
22 GNAT, either automatically or with explicit programming features.
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 .. _Elaboration_Code:
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 Elaboration Code
kono
parents:
diff changeset
27 ================
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 Ada defines the term *execution* as the process by which a construct achieves
kono
parents:
diff changeset
30 its run-time effect. This process is also referred to as **elaboration** for
kono
parents:
diff changeset
31 declarations and *evaluation* for expressions.
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 The execution model in Ada allows for certain sections of an Ada program to be
kono
parents:
diff changeset
34 executed prior to execution of the program itself, primarily with the intent of
kono
parents:
diff changeset
35 initializing data. These sections are referred to as **elaboration code**.
kono
parents:
diff changeset
36 Elaboration code is executed as follows:
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 * All partitions of an Ada program are executed in parallel with one another,
kono
parents:
diff changeset
39 possibly in a separate address space, and possibly on a separate computer.
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 * The execution of a partition involves running the environment task for that
kono
parents:
diff changeset
42 partition.
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 * The environment task executes all elaboration code (if available) for all
kono
parents:
diff changeset
45 units within that partition. This code is said to be executed at
kono
parents:
diff changeset
46 **elaboration time**.
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 * The environment task executes the Ada program (if available) for that
kono
parents:
diff changeset
49 partition.
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 In addition to the Ada terminology, this appendix defines the following terms:
kono
parents:
diff changeset
52
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
53 * *Invocation*
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
54
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
55 The act of calling a subprogram, instantiating a generic, or activating a
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
56 task.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
57
111
kono
parents:
diff changeset
58 * *Scenario*
kono
parents:
diff changeset
59
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
60 A construct that is elaborated or invoked by elaboration code is referred to
111
kono
parents:
diff changeset
61 as an *elaboration scenario* or simply a **scenario**. GNAT recognizes the
kono
parents:
diff changeset
62 following scenarios:
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 - ``'Access`` of entries, operators, and subprograms
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 - Activation of tasks
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 - Calls to entries, operators, and subprograms
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 - Instantiations of generic templates
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 * *Target*
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 A construct elaborated by a scenario is referred to as *elaboration target*
kono
parents:
diff changeset
75 or simply **target**. GNAT recognizes the following targets:
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 - For ``'Access`` of entries, operators, and subprograms, the target is the
kono
parents:
diff changeset
78 entry, operator, or subprogram being aliased.
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 - For activation of tasks, the target is the task body
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 - For calls to entries, operators, and subprograms, the target is the entry,
kono
parents:
diff changeset
83 operator, or subprogram being invoked.
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 - For instantiations of generic templates, the target is the generic template
kono
parents:
diff changeset
86 being instantiated.
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 Elaboration code may appear in two distinct contexts:
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 * *Library level*
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 A scenario appears at the library level when it is encapsulated by a package
kono
parents:
diff changeset
93 [body] compilation unit, ignoring any other package [body] declarations in
kono
parents:
diff changeset
94 between.
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 ::
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 with Server;
kono
parents:
diff changeset
99 package Client is
kono
parents:
diff changeset
100 procedure Proc;
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 package Nested is
kono
parents:
diff changeset
103 Val : ... := Server.Func;
kono
parents:
diff changeset
104 end Nested;
kono
parents:
diff changeset
105 end Client;
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 In the example above, the call to ``Server.Func`` is an elaboration scenario
kono
parents:
diff changeset
108 because it appears at the library level of package ``Client``. Note that the
kono
parents:
diff changeset
109 declaration of package ``Nested`` is ignored according to the definition
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
110 given above. As a result, the call to ``Server.Func`` will be invoked when
111
kono
parents:
diff changeset
111 the spec of unit ``Client`` is elaborated.
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 * *Package body statements*
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 A scenario appears within the statement sequence of a package body when it is
kono
parents:
diff changeset
116 bounded by the region starting from the ``begin`` keyword of the package body
kono
parents:
diff changeset
117 and ending at the ``end`` keyword of the package body.
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 ::
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 package body Client is
kono
parents:
diff changeset
122 procedure Proc is
kono
parents:
diff changeset
123 begin
kono
parents:
diff changeset
124 ...
kono
parents:
diff changeset
125 end Proc;
kono
parents:
diff changeset
126 begin
kono
parents:
diff changeset
127 Proc;
kono
parents:
diff changeset
128 end Client;
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 In the example above, the call to ``Proc`` is an elaboration scenario because
kono
parents:
diff changeset
131 it appears within the statement sequence of package body ``Client``. As a
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
132 result, the call to ``Proc`` will be invoked when the body of ``Client`` is
111
kono
parents:
diff changeset
133 elaborated.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 .. _Elaboration_Order:
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 Elaboration Order
kono
parents:
diff changeset
138 =================
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 The sequence by which the elaboration code of all units within a partition is
kono
parents:
diff changeset
141 executed is referred to as **elaboration order**.
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 Within a single unit, elaboration code is executed in sequential order.
kono
parents:
diff changeset
144
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
145 ::
111
kono
parents:
diff changeset
146
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
147 package body Client is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
148 Result : ... := Server.Func;
111
kono
parents:
diff changeset
149
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
150 procedure Proc is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
151 package Inst is new Server.Gen;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
152 begin
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
153 Inst.Eval (Result);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
154 end Proc;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
155 begin
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
156 Proc;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
157 end Client;
111
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 In the example above, the elaboration order within package body ``Client`` is
kono
parents:
diff changeset
160 as follows:
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 1. The object declaration of ``Result`` is elaborated.
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 * Function ``Server.Func`` is invoked.
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 2. The subprogram body of ``Proc`` is elaborated.
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 3. Procedure ``Proc`` is invoked.
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 * Generic unit ``Server.Gen`` is instantiated as ``Inst``.
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 * Instance ``Inst`` is elaborated.
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 * Procedure ``Inst.Eval`` is invoked.
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 The elaboration order of all units within a partition depends on the following
kono
parents:
diff changeset
177 factors:
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 * |withed| units
kono
parents:
diff changeset
180
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
181 * parent units
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
182
111
kono
parents:
diff changeset
183 * purity of units
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 * preelaborability of units
kono
parents:
diff changeset
186
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
187 * presence of elaboration-control pragmas
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
188
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
189 * invocations performed in elaboration code
111
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 A program may have several elaboration orders depending on its structure.
kono
parents:
diff changeset
192
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
193 ::
111
kono
parents:
diff changeset
194
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
195 package Server is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
196 function Func (Index : Integer) return Integer;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
197 end Server;
111
kono
parents:
diff changeset
198
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
199 ::
111
kono
parents:
diff changeset
200
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
201 package body Server is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
202 Results : array (1 .. 5) of Integer := (1, 2, 3, 4, 5);
111
kono
parents:
diff changeset
203
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
204 function Func (Index : Integer) return Integer is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
205 begin
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
206 return Results (Index);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
207 end Func;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
208 end Server;
111
kono
parents:
diff changeset
209
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
210 ::
111
kono
parents:
diff changeset
211
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
212 with Server;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
213 package Client is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
214 Val : constant Integer := Server.Func (3);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
215 end Client;
111
kono
parents:
diff changeset
216
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
217 ::
111
kono
parents:
diff changeset
218
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
219 with Client;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
220 procedure Main is begin null; end Main;
111
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 The following elaboration order exhibits a fundamental problem referred to as
kono
parents:
diff changeset
223 *access-before-elaboration* or simply **ABE**.
kono
parents:
diff changeset
224
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
225 ::
111
kono
parents:
diff changeset
226
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
227 spec of Server
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
228 spec of Client
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
229 body of Server
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
230 body of Main
111
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 The elaboration of ``Server``'s spec materializes function ``Func``, making it
kono
parents:
diff changeset
233 callable. The elaboration of ``Client``'s spec elaborates the declaration of
kono
parents:
diff changeset
234 ``Val``. This invokes function ``Server.Func``, however the body of
kono
parents:
diff changeset
235 ``Server.Func`` has not been elaborated yet because ``Server``'s body comes
kono
parents:
diff changeset
236 after ``Client``'s spec in the elaboration order. As a result, the value of
kono
parents:
diff changeset
237 constant ``Val`` is now undefined.
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 Without any guarantees from the language, an undetected ABE problem may hinder
kono
parents:
diff changeset
240 proper initialization of data, which in turn may lead to undefined behavior at
kono
parents:
diff changeset
241 run time. To prevent such ABE problems, Ada employs dynamic checks in the same
kono
parents:
diff changeset
242 vein as index or null exclusion checks. A failed ABE check raises exception
kono
parents:
diff changeset
243 ``Program_Error``.
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 The following elaboration order avoids the ABE problem and the program can be
kono
parents:
diff changeset
246 successfully elaborated.
kono
parents:
diff changeset
247
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
248 ::
111
kono
parents:
diff changeset
249
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
250 spec of Server
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
251 body of Server
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
252 spec of Client
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
253 body of Main
111
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 Ada states that a total elaboration order must exist, but it does not define
kono
parents:
diff changeset
256 what this order is. A compiler is thus tasked with choosing a suitable
kono
parents:
diff changeset
257 elaboration order which satisfies the dependencies imposed by |with| clauses,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
258 unit categorization, elaboration-control pragmas, and invocations performed in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
259 elaboration code. Ideally an order that avoids ABE problems should be chosen,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
260 however a compiler may not always find such an order due to complications with
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
261 respect to control and data flow.
111
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 .. _Checking_the_Elaboration_Order:
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 Checking the Elaboration Order
kono
parents:
diff changeset
266 ==============================
kono
parents:
diff changeset
267
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
268 To avoid placing the entire elaboration-order burden on the programmer, Ada
111
kono
parents:
diff changeset
269 provides three lines of defense:
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 * *Static semantics*
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 Static semantic rules restrict the possible choice of elaboration order. For
kono
parents:
diff changeset
274 instance, if unit Client |withs| unit Server, then the spec of Server is
kono
parents:
diff changeset
275 always elaborated prior to Client. The same principle applies to child units
kono
parents:
diff changeset
276 - the spec of a parent unit is always elaborated prior to the child unit.
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 * *Dynamic semantics*
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 Dynamic checks are performed at run time, to ensure that a target is
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
281 elaborated prior to a scenario that invokes it, thus avoiding ABE problems.
111
kono
parents:
diff changeset
282 A failed run-time check raises exception ``Program_Error``. The following
kono
parents:
diff changeset
283 restrictions apply:
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 - *Restrictions on calls*
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 An entry, operator, or subprogram can be called from elaboration code only
kono
parents:
diff changeset
288 when the corresponding body has been elaborated.
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 - *Restrictions on instantiations*
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 A generic unit can be instantiated by elaboration code only when the
kono
parents:
diff changeset
293 corresponding body has been elaborated.
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 - *Restrictions on task activation*
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 A task can be activated by elaboration code only when the body of the
kono
parents:
diff changeset
298 associated task type has been elaborated.
kono
parents:
diff changeset
299
kono
parents:
diff changeset
300 The restrictions above can be summarized by the following rule:
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 *If a target has a body, then this body must be elaborated prior to the
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
303 scenario that invokes the target.*
111
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 * *Elaboration control*
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 Pragmas are provided for the programmer to specify the desired elaboration
kono
parents:
diff changeset
308 order.
kono
parents:
diff changeset
309
kono
parents:
diff changeset
310 .. _Controlling_the_Elaboration_Order_in_Ada:
kono
parents:
diff changeset
311
kono
parents:
diff changeset
312 Controlling the Elaboration Order in Ada
kono
parents:
diff changeset
313 ========================================
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 Ada provides several idioms and pragmas to aid the programmer with specifying
kono
parents:
diff changeset
316 the desired elaboration order and avoiding ABE problems altogether.
kono
parents:
diff changeset
317
kono
parents:
diff changeset
318 * *Packages without a body*
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 A library package which does not require a completing body does not suffer
kono
parents:
diff changeset
321 from ABE problems.
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 ::
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 package Pack is
kono
parents:
diff changeset
326 generic
kono
parents:
diff changeset
327 type Element is private;
kono
parents:
diff changeset
328 package Containers is
kono
parents:
diff changeset
329 type Element_Array is array (1 .. 10) of Element;
kono
parents:
diff changeset
330 end Containers;
kono
parents:
diff changeset
331 end Pack;
kono
parents:
diff changeset
332
kono
parents:
diff changeset
333 In the example above, package ``Pack`` does not require a body because it
kono
parents:
diff changeset
334 does not contain any constructs which require completion in a body. As a
kono
parents:
diff changeset
335 result, generic ``Pack.Containers`` can be instantiated without encountering
kono
parents:
diff changeset
336 any ABE problems.
kono
parents:
diff changeset
337
kono
parents:
diff changeset
338 .. index:: pragma Pure
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 * *pragma Pure*
kono
parents:
diff changeset
341
kono
parents:
diff changeset
342 Pragma ``Pure`` places sufficient restrictions on a unit to guarantee that no
kono
parents:
diff changeset
343 scenario within the unit can result in an ABE problem.
kono
parents:
diff changeset
344
kono
parents:
diff changeset
345 .. index:: pragma Preelaborate
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 * *pragma Preelaborate*
kono
parents:
diff changeset
348
kono
parents:
diff changeset
349 Pragma ``Preelaborate`` is slightly less restrictive than pragma ``Pure``,
kono
parents:
diff changeset
350 but still strong enough to prevent ABE problems within a unit.
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 .. index:: pragma Elaborate_Body
kono
parents:
diff changeset
353
kono
parents:
diff changeset
354 * *pragma Elaborate_Body*
kono
parents:
diff changeset
355
kono
parents:
diff changeset
356 Pragma ``Elaborate_Body`` requires that the body of a unit is elaborated
kono
parents:
diff changeset
357 immediately after its spec. This restriction guarantees that no client
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
358 scenario can invoke a server target before the target body has been
111
kono
parents:
diff changeset
359 elaborated because the spec and body are effectively "glued" together.
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 ::
kono
parents:
diff changeset
362
kono
parents:
diff changeset
363 package Server is
kono
parents:
diff changeset
364 pragma Elaborate_Body;
kono
parents:
diff changeset
365
kono
parents:
diff changeset
366 function Func return Integer;
kono
parents:
diff changeset
367 end Server;
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369 ::
kono
parents:
diff changeset
370
kono
parents:
diff changeset
371 package body Server is
kono
parents:
diff changeset
372 function Func return Integer is
kono
parents:
diff changeset
373 begin
kono
parents:
diff changeset
374 ...
kono
parents:
diff changeset
375 end Func;
kono
parents:
diff changeset
376 end Server;
kono
parents:
diff changeset
377
kono
parents:
diff changeset
378 ::
kono
parents:
diff changeset
379
kono
parents:
diff changeset
380 with Server;
kono
parents:
diff changeset
381 package Client is
kono
parents:
diff changeset
382 Val : constant Integer := Server.Func;
kono
parents:
diff changeset
383 end Client;
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 In the example above, pragma ``Elaborate_Body`` guarantees the following
kono
parents:
diff changeset
386 elaboration order:
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 ::
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 spec of Server
kono
parents:
diff changeset
391 body of Server
kono
parents:
diff changeset
392 spec of Client
kono
parents:
diff changeset
393
kono
parents:
diff changeset
394 because the spec of ``Server`` must be elaborated prior to ``Client`` by
kono
parents:
diff changeset
395 virtue of the |with| clause, and in addition the body of ``Server`` must be
kono
parents:
diff changeset
396 elaborated immediately after the spec of ``Server``.
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 Removing pragma ``Elaborate_Body`` could result in the following incorrect
kono
parents:
diff changeset
399 elaboration order:
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 ::
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 spec of Server
kono
parents:
diff changeset
404 spec of Client
kono
parents:
diff changeset
405 body of Server
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 where ``Client`` invokes ``Server.Func``, but the body of ``Server.Func`` has
kono
parents:
diff changeset
408 not been elaborated yet.
kono
parents:
diff changeset
409
kono
parents:
diff changeset
410 The pragmas outlined above allow a server unit to guarantee safe elaboration
kono
parents:
diff changeset
411 use by client units. Thus it is a good rule to mark units as ``Pure`` or
kono
parents:
diff changeset
412 ``Preelaborate``, and if this is not possible, mark them as ``Elaborate_Body``.
kono
parents:
diff changeset
413
kono
parents:
diff changeset
414 There are however situations where ``Pure``, ``Preelaborate``, and
kono
parents:
diff changeset
415 ``Elaborate_Body`` are not applicable. Ada provides another set of pragmas for
kono
parents:
diff changeset
416 use by client units to help ensure the elaboration safety of server units they
kono
parents:
diff changeset
417 depend on.
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419 .. index:: pragma Elaborate (Unit)
kono
parents:
diff changeset
420
kono
parents:
diff changeset
421 * *pragma Elaborate (Unit)*
kono
parents:
diff changeset
422
kono
parents:
diff changeset
423 Pragma ``Elaborate`` can be placed in the context clauses of a unit, after a
kono
parents:
diff changeset
424 |with| clause. It guarantees that both the spec and body of its argument will
kono
parents:
diff changeset
425 be elaborated prior to the unit with the pragma. Note that other unrelated
kono
parents:
diff changeset
426 units may be elaborated in between the spec and the body.
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 ::
kono
parents:
diff changeset
429
kono
parents:
diff changeset
430 package Server is
kono
parents:
diff changeset
431 function Func return Integer;
kono
parents:
diff changeset
432 end Server;
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 ::
kono
parents:
diff changeset
435
kono
parents:
diff changeset
436 package body Server is
kono
parents:
diff changeset
437 function Func return Integer is
kono
parents:
diff changeset
438 begin
kono
parents:
diff changeset
439 ...
kono
parents:
diff changeset
440 end Func;
kono
parents:
diff changeset
441 end Server;
kono
parents:
diff changeset
442
kono
parents:
diff changeset
443 ::
kono
parents:
diff changeset
444
kono
parents:
diff changeset
445 with Server;
kono
parents:
diff changeset
446 pragma Elaborate (Server);
kono
parents:
diff changeset
447 package Client is
kono
parents:
diff changeset
448 Val : constant Integer := Server.Func;
kono
parents:
diff changeset
449 end Client;
kono
parents:
diff changeset
450
kono
parents:
diff changeset
451 In the example above, pragma ``Elaborate`` guarantees the following
kono
parents:
diff changeset
452 elaboration order:
kono
parents:
diff changeset
453
kono
parents:
diff changeset
454 ::
kono
parents:
diff changeset
455
kono
parents:
diff changeset
456 spec of Server
kono
parents:
diff changeset
457 body of Server
kono
parents:
diff changeset
458 spec of Client
kono
parents:
diff changeset
459
kono
parents:
diff changeset
460 Removing pragma ``Elaborate`` could result in the following incorrect
kono
parents:
diff changeset
461 elaboration order:
kono
parents:
diff changeset
462
kono
parents:
diff changeset
463 ::
kono
parents:
diff changeset
464
kono
parents:
diff changeset
465 spec of Server
kono
parents:
diff changeset
466 spec of Client
kono
parents:
diff changeset
467 body of Server
kono
parents:
diff changeset
468
kono
parents:
diff changeset
469 where ``Client`` invokes ``Server.Func``, but the body of ``Server.Func``
kono
parents:
diff changeset
470 has not been elaborated yet.
kono
parents:
diff changeset
471
kono
parents:
diff changeset
472 .. index:: pragma Elaborate_All (Unit)
kono
parents:
diff changeset
473
kono
parents:
diff changeset
474 * *pragma Elaborate_All (Unit)*
kono
parents:
diff changeset
475
kono
parents:
diff changeset
476 Pragma ``Elaborate_All`` is placed in the context clauses of a unit, after
kono
parents:
diff changeset
477 a |with| clause. It guarantees that both the spec and body of its argument
kono
parents:
diff changeset
478 will be elaborated prior to the unit with the pragma, as well as all units
kono
parents:
diff changeset
479 |withed| by the spec and body of the argument, recursively. Note that other
kono
parents:
diff changeset
480 unrelated units may be elaborated in between the spec and the body.
kono
parents:
diff changeset
481
kono
parents:
diff changeset
482 ::
kono
parents:
diff changeset
483
kono
parents:
diff changeset
484 package Math is
kono
parents:
diff changeset
485 function Factorial (Val : Natural) return Natural;
kono
parents:
diff changeset
486 end Math;
kono
parents:
diff changeset
487
kono
parents:
diff changeset
488 ::
kono
parents:
diff changeset
489
kono
parents:
diff changeset
490 package body Math is
kono
parents:
diff changeset
491 function Factorial (Val : Natural) return Natural is
kono
parents:
diff changeset
492 begin
kono
parents:
diff changeset
493 ...;
kono
parents:
diff changeset
494 end Factorial;
kono
parents:
diff changeset
495 end Math;
kono
parents:
diff changeset
496
kono
parents:
diff changeset
497 ::
kono
parents:
diff changeset
498
kono
parents:
diff changeset
499 package Computer is
kono
parents:
diff changeset
500 type Operation_Kind is (None, Op_Factorial);
kono
parents:
diff changeset
501
kono
parents:
diff changeset
502 function Compute
kono
parents:
diff changeset
503 (Val : Natural;
kono
parents:
diff changeset
504 Op : Operation_Kind) return Natural;
kono
parents:
diff changeset
505 end Computer;
kono
parents:
diff changeset
506
kono
parents:
diff changeset
507 ::
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509 with Math;
kono
parents:
diff changeset
510 package body Computer is
kono
parents:
diff changeset
511 function Compute
kono
parents:
diff changeset
512 (Val : Natural;
kono
parents:
diff changeset
513 Op : Operation_Kind) return Natural
kono
parents:
diff changeset
514 is
kono
parents:
diff changeset
515 if Op = Op_Factorial then
kono
parents:
diff changeset
516 return Math.Factorial (Val);
kono
parents:
diff changeset
517 end if;
kono
parents:
diff changeset
518
kono
parents:
diff changeset
519 return 0;
kono
parents:
diff changeset
520 end Compute;
kono
parents:
diff changeset
521 end Computer;
kono
parents:
diff changeset
522
kono
parents:
diff changeset
523 ::
kono
parents:
diff changeset
524
kono
parents:
diff changeset
525 with Computer;
kono
parents:
diff changeset
526 pragma Elaborate_All (Computer);
kono
parents:
diff changeset
527 package Client is
kono
parents:
diff changeset
528 Val : constant Natural :=
kono
parents:
diff changeset
529 Computer.Compute (123, Computer.Op_Factorial);
kono
parents:
diff changeset
530 end Client;
kono
parents:
diff changeset
531
kono
parents:
diff changeset
532 In the example above, pragma ``Elaborate_All`` can result in the following
kono
parents:
diff changeset
533 elaboration order:
kono
parents:
diff changeset
534
kono
parents:
diff changeset
535 ::
kono
parents:
diff changeset
536
kono
parents:
diff changeset
537 spec of Math
kono
parents:
diff changeset
538 body of Math
kono
parents:
diff changeset
539 spec of Computer
kono
parents:
diff changeset
540 body of Computer
kono
parents:
diff changeset
541 spec of Client
kono
parents:
diff changeset
542
kono
parents:
diff changeset
543 Note that there are several allowable suborders for the specs and bodies of
kono
parents:
diff changeset
544 ``Math`` and ``Computer``, but the point is that these specs and bodies will
kono
parents:
diff changeset
545 be elaborated prior to ``Client``.
kono
parents:
diff changeset
546
kono
parents:
diff changeset
547 Removing pragma ``Elaborate_All`` could result in the following incorrect
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
548 elaboration order:
111
kono
parents:
diff changeset
549
kono
parents:
diff changeset
550 ::
kono
parents:
diff changeset
551
kono
parents:
diff changeset
552 spec of Math
kono
parents:
diff changeset
553 spec of Computer
kono
parents:
diff changeset
554 body of Computer
kono
parents:
diff changeset
555 spec of Client
kono
parents:
diff changeset
556 body of Math
kono
parents:
diff changeset
557
kono
parents:
diff changeset
558 where ``Client`` invokes ``Computer.Compute``, which in turn invokes
kono
parents:
diff changeset
559 ``Math.Factorial``, but the body of ``Math.Factorial`` has not been
kono
parents:
diff changeset
560 elaborated yet.
kono
parents:
diff changeset
561
kono
parents:
diff changeset
562 All pragmas shown above can be summarized by the following rule:
kono
parents:
diff changeset
563
kono
parents:
diff changeset
564 *If a client unit elaborates a server target directly or indirectly, then if
kono
parents:
diff changeset
565 the server unit requires a body and does not have pragma Pure, Preelaborate,
kono
parents:
diff changeset
566 or Elaborate_Body, then the client unit should have pragma Elaborate or
kono
parents:
diff changeset
567 Elaborate_All for the server unit.*
kono
parents:
diff changeset
568
kono
parents:
diff changeset
569 If the rule outlined above is not followed, then a program may fall in one of
kono
parents:
diff changeset
570 the following states:
kono
parents:
diff changeset
571
kono
parents:
diff changeset
572 * *No elaboration order exists*
kono
parents:
diff changeset
573
kono
parents:
diff changeset
574 In this case a compiler must diagnose the situation, and refuse to build an
kono
parents:
diff changeset
575 executable program.
kono
parents:
diff changeset
576
kono
parents:
diff changeset
577 * *One or more incorrect elaboration orders exist*
kono
parents:
diff changeset
578
kono
parents:
diff changeset
579 In this case a compiler can build an executable program, but
kono
parents:
diff changeset
580 ``Program_Error`` will be raised when the program is run.
kono
parents:
diff changeset
581
kono
parents:
diff changeset
582 * *Several elaboration orders exist, some correct, some incorrect*
kono
parents:
diff changeset
583
kono
parents:
diff changeset
584 In this case the programmer has not controlled the elaboration order. As a
kono
parents:
diff changeset
585 result, a compiler may or may not pick one of the correct orders, and the
kono
parents:
diff changeset
586 program may or may not raise ``Program_Error`` when it is run. This is the
kono
parents:
diff changeset
587 worst possible state because the program may fail on another compiler, or
kono
parents:
diff changeset
588 even another version of the same compiler.
kono
parents:
diff changeset
589
kono
parents:
diff changeset
590 * *One or more correct orders exist*
kono
parents:
diff changeset
591
kono
parents:
diff changeset
592 In this case a compiler can build an executable program, and the program is
kono
parents:
diff changeset
593 run successfully. This state may be guaranteed by following the outlined
kono
parents:
diff changeset
594 rules, or may be the result of good program architecture.
kono
parents:
diff changeset
595
kono
parents:
diff changeset
596 Note that one additional advantage of using ``Elaborate`` and ``Elaborate_All``
kono
parents:
diff changeset
597 is that the program continues to stay in the last state (one or more correct
kono
parents:
diff changeset
598 orders exist) even if maintenance changes the bodies of targets.
kono
parents:
diff changeset
599
kono
parents:
diff changeset
600 .. _Controlling_the_Elaboration_Order_in_GNAT:
kono
parents:
diff changeset
601
kono
parents:
diff changeset
602 Controlling the Elaboration Order in GNAT
kono
parents:
diff changeset
603 =========================================
kono
parents:
diff changeset
604
kono
parents:
diff changeset
605 In addition to Ada semantics and rules synthesized from them, GNAT offers
kono
parents:
diff changeset
606 three elaboration models to aid the programmer with specifying the correct
kono
parents:
diff changeset
607 elaboration order and to diagnose elaboration problems.
kono
parents:
diff changeset
608
kono
parents:
diff changeset
609 .. index:: Dynamic elaboration model
kono
parents:
diff changeset
610
kono
parents:
diff changeset
611 * *Dynamic elaboration model*
kono
parents:
diff changeset
612
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
613 This is the most permissive of the three elaboration models and emulates the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
614 behavior specified by the Ada Reference Manual. When the dynamic model is in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
615 effect, GNAT makes the following assumptions:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
616
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
617 - All code within all units in a partition is considered to be elaboration
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
618 code.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
619
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
620 - Some of the invocations in elaboration code may not take place at run time
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
621 due to conditional execution.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
622
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
623 GNAT performs extensive diagnostics on a unit-by-unit basis for all scenarios
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
624 that invoke internal targets. In addition, GNAT generates run-time checks for
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
625 all external targets and for all scenarios that may exhibit ABE problems.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
626
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
627 The elaboration order is obtained by honoring all |with| clauses, purity and
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
628 preelaborability of units, and elaboration-control pragmas. The dynamic model
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
629 attempts to take all invocations in elaboration code into account. If an
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
630 invocation leads to a circularity, GNAT ignores the invocation based on the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
631 assumptions stated above. An order obtained using the dynamic model may fail
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
632 an ABE check at run time when GNAT ignored an invocation.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
633
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
634 The dynamic model is enabled with compiler switch :switch:`-gnatE`.
111
kono
parents:
diff changeset
635
kono
parents:
diff changeset
636 .. index:: Static elaboration model
kono
parents:
diff changeset
637
kono
parents:
diff changeset
638 * *Static elaboration model*
kono
parents:
diff changeset
639
kono
parents:
diff changeset
640 This is the middle ground of the three models. When the static model is in
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
641 effect, GNAT makes the following assumptions:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
642
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
643 - Only code at the library level and in package body statements within all
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
644 units in a partition is considered to be elaboration code.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
645
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
646 - All invocations in elaboration will take place at run time, regardless of
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
647 conditional execution.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
648
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
649 GNAT performs extensive diagnostics on a unit-by-unit basis for all scenarios
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
650 that invoke internal targets. In addition, GNAT generates run-time checks for
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
651 all external targets and for all scenarios that may exhibit ABE problems.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
652
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
653 The elaboration order is obtained by honoring all |with| clauses, purity and
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
654 preelaborability of units, presence of elaboration-control pragmas, and all
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
655 invocations in elaboration code. An order obtained using the static model is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
656 guaranteed to be ABE problem-free, excluding dispatching calls and
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
657 access-to-subprogram types.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
658
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
659 The static model is the default model in GNAT.
111
kono
parents:
diff changeset
660
kono
parents:
diff changeset
661 .. index:: SPARK elaboration model
kono
parents:
diff changeset
662
kono
parents:
diff changeset
663 * *SPARK elaboration model*
kono
parents:
diff changeset
664
kono
parents:
diff changeset
665 This is the most conservative of the three models and enforces the SPARK
kono
parents:
diff changeset
666 rules of elaboration as defined in the SPARK Reference Manual, section 7.7.
kono
parents:
diff changeset
667 The SPARK model is in effect only when a scenario and a target reside in a
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
668 region subject to ``SPARK_Mode On``, otherwise the dynamic or static model
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
669 is in effect.
111
kono
parents:
diff changeset
670
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
671 The SPARK model is enabled with compiler switch :switch:`-gnatd.v`.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
672
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
673 .. index:: Legacy elaboration models
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
674
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
675 * *Legacy elaboration models*
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
676
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
677 In addition to the three elaboration models outlined above, GNAT provides the
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
678 following legacy models:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
679
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
680 - `Legacy elaboration-checking model` available in pre-18.x versions of GNAT.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
681 This model is enabled with compiler switch :switch:`-gnatH`.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
682
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
683 - `Legacy elaboration-order model` available in pre-20.x versions of GNAT.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
684 This model is enabled with binder switch :switch:`-H`.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
685
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
686 .. index:: Relaxed elaboration mode
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
687
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
688 The dynamic, legacy, and static models can be relaxed using compiler switch
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
689 :switch:`-gnatJ`, making them more permissive. Note that in this mode, GNAT
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
690 may not diagnose certain elaboration issues or install run-time checks.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
691
111
kono
parents:
diff changeset
692 .. _Mixing_Elaboration_Models:
kono
parents:
diff changeset
693
kono
parents:
diff changeset
694 Mixing Elaboration Models
kono
parents:
diff changeset
695 =========================
kono
parents:
diff changeset
696
kono
parents:
diff changeset
697 It is possible to mix units compiled with a different elaboration model,
kono
parents:
diff changeset
698 however the following rules must be observed:
kono
parents:
diff changeset
699
kono
parents:
diff changeset
700 * A client unit compiled with the dynamic model can only |with| a server unit
kono
parents:
diff changeset
701 that meets at least one of the following criteria:
kono
parents:
diff changeset
702
kono
parents:
diff changeset
703 - The server unit is compiled with the dynamic model.
kono
parents:
diff changeset
704
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
705 - The server unit is a GNAT implementation unit from the ``Ada``, ``GNAT``,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
706 ``Interfaces``, or ``System`` hierarchies.
111
kono
parents:
diff changeset
707
kono
parents:
diff changeset
708 - The server unit has pragma ``Pure`` or ``Preelaborate``.
kono
parents:
diff changeset
709
kono
parents:
diff changeset
710 - The client unit has an explicit ``Elaborate_All`` pragma for the server
kono
parents:
diff changeset
711 unit.
kono
parents:
diff changeset
712
kono
parents:
diff changeset
713 These rules ensure that elaboration checks are not omitted. If the rules are
kono
parents:
diff changeset
714 violated, the binder emits a warning:
kono
parents:
diff changeset
715
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
716 ::
111
kono
parents:
diff changeset
717
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
718 warning: "x.ads" has dynamic elaboration checks and with's
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
719 warning: "y.ads" which has static elaboration checks
111
kono
parents:
diff changeset
720
kono
parents:
diff changeset
721 The warnings can be suppressed by binder switch :switch:`-ws`.
kono
parents:
diff changeset
722
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
723 .. _ABE_Diagnostics:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
724
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
725 ABE Diagnostics
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
726 ===============
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
727
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
728 GNAT performs extensive diagnostics on a unit-by-unit basis for all scenarios
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
729 that invoke internal targets, regardless of whether the dynamic, SPARK, or
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
730 static model is in effect.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
731
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
732 Note that GNAT emits warnings rather than hard errors whenever it encounters an
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
733 elaboration problem. This is because the elaboration model in effect may be too
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
734 conservative, or a particular scenario may not be invoked due conditional
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
735 execution. The warnings can be suppressed selectively with ``pragma Warnings
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
736 (Off)`` or globally with compiler switch :switch:`-gnatwL`.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
737
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
738 A *guaranteed ABE* arises when the body of a target is not elaborated early
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
739 enough, and causes *all* scenarios that directly invoke the target to fail.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
740
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
741 ::
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
742
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
743 package body Guaranteed_ABE is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
744 function ABE return Integer;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
745
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
746 Val : constant Integer := ABE;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
747
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
748 function ABE return Integer is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
749 begin
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
750 ...
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
751 end ABE;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
752 end Guaranteed_ABE;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
753
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
754 In the example above, the elaboration of ``Guaranteed_ABE``'s body elaborates
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
755 the declaration of ``Val``. This invokes function ``ABE``, however the body of
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
756 ``ABE`` has not been elaborated yet. GNAT emits the following diagnostic:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
757
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
758 ::
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
759
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
760 4. Val : constant Integer := ABE;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
761 |
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
762 >>> warning: cannot call "ABE" before body seen
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
763 >>> warning: Program_Error will be raised at run time
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
764
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
765 A *conditional ABE* arises when the body of a target is not elaborated early
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
766 enough, and causes *some* scenarios that directly invoke the target to fail.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
767
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
768 ::
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
769
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
770 1. package body Conditional_ABE is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
771 2. procedure Force_Body is null;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
772 3.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
773 4. generic
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
774 5. with function Func return Integer;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
775 6. package Gen is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
776 7. Val : constant Integer := Func;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
777 8. end Gen;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
778 9.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
779 10. function ABE return Integer;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
780 11.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
781 12. function Cause_ABE return Boolean is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
782 13. package Inst is new Gen (ABE);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
783 14. begin
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
784 15. ...
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
785 16. end Cause_ABE;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
786 17.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
787 18. Val : constant Boolean := Cause_ABE;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
788 19.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
789 20. function ABE return Integer is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
790 21. begin
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
791 22. ...
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
792 23. end ABE;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
793 24.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
794 25. Safe : constant Boolean := Cause_ABE;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
795 26. end Conditional_ABE;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
796
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
797 In the example above, the elaboration of package body ``Conditional_ABE``
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
798 elaborates the declaration of ``Val``. This invokes function ``Cause_ABE``,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
799 which instantiates generic unit ``Gen`` as ``Inst``. The elaboration of
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
800 ``Inst`` invokes function ``ABE``, however the body of ``ABE`` has not been
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
801 elaborated yet. GNAT emits the following diagnostic:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
802
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
803 ::
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
804
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
805 13. package Inst is new Gen (ABE);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
806 |
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
807 >>> warning: in instantiation at line 7
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
808 >>> warning: cannot call "ABE" before body seen
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
809 >>> warning: Program_Error may be raised at run time
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
810 >>> warning: body of unit "Conditional_ABE" elaborated
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
811 >>> warning: function "Cause_ABE" called at line 18
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
812 >>> warning: function "ABE" called at line 7, instance at line 13
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
813
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
814 Note that the same ABE problem does not occur with the elaboration of
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
815 declaration ``Safe`` because the body of function ``ABE`` has already been
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
816 elaborated at that point.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
817
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
818 .. _SPARK_Diagnostics:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
819
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
820 SPARK Diagnostics
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
821 =================
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
822
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
823 GNAT enforces the SPARK rules of elaboration as defined in the SPARK Reference
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
824 Manual section 7.7 when compiler switch :switch:`-gnatd.v` is in effect. Note
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
825 that GNAT emits hard errors whenever it encounters a violation of the SPARK
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
826 rules.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
827
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
828 ::
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
829
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
830 1. with Server;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
831 2. package body SPARK_Diagnostics with SPARK_Mode is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
832 3. Val : constant Integer := Server.Func;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
833 |
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
834 >>> call to "Func" during elaboration in SPARK
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
835 >>> unit "SPARK_Diagnostics" requires pragma "Elaborate_All" for "Server"
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
836 >>> body of unit "SPARK_Model" elaborated
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
837 >>> function "Func" called at line 3
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
838
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
839 4. end SPARK_Diagnostics;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
840
111
kono
parents:
diff changeset
841 .. _Elaboration_Circularities:
kono
parents:
diff changeset
842
kono
parents:
diff changeset
843 Elaboration Circularities
kono
parents:
diff changeset
844 =========================
kono
parents:
diff changeset
845
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
846 An **elaboration circularity** occurs whenever the elaboration of a set of
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
847 units enters a deadlocked state, where each unit is waiting for another unit
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
848 to be elaborated. This situation may be the result of improper use of |with|
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
849 clauses, elaboration-control pragmas, or invocations in elaboration code.
111
kono
parents:
diff changeset
850
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
851 The following example exhibits an elaboration circularity.
111
kono
parents:
diff changeset
852
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
853 ::
111
kono
parents:
diff changeset
854
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
855 with B; pragma Elaborate (B);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
856 package A is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
857 end A;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
858
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
859 ::
111
kono
parents:
diff changeset
860
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
861 package B is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
862 procedure Force_Body;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
863 end B;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
864
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
865 ::
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
866
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
867 with C;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
868 package body B is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
869 procedure Force_Body is null;
111
kono
parents:
diff changeset
870
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
871 Elab : constant Integer := C.Func;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
872 end B;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
873
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
874 ::
111
kono
parents:
diff changeset
875
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
876 package C is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
877 function Func return Integer;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
878 end C;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
879
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
880 ::
111
kono
parents:
diff changeset
881
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
882 with A;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
883 package body C is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
884 function Func return Integer is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
885 begin
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
886 ...
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
887 end Func;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
888 end C;
111
kono
parents:
diff changeset
889
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
890 The binder emits the following diagnostic:
111
kono
parents:
diff changeset
891
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
892 ::
111
kono
parents:
diff changeset
893
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
894 error: Elaboration circularity detected
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
895 info:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
896 info: Reason:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
897 info:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
898 info: unit "a (spec)" depends on its own elaboration
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
899 info:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
900 info: Circularity:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
901 info:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
902 info: unit "a (spec)" has with clause and pragma Elaborate for unit "b (spec)"
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
903 info: unit "b (body)" is in the closure of pragma Elaborate
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
904 info: unit "b (body)" invokes a construct of unit "c (body)" at elaboration time
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
905 info: unit "c (body)" has with clause for unit "a (spec)"
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
906 info:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
907 info: Suggestions:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
908 info:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
909 info: remove pragma Elaborate for unit "b (body)" in unit "a (spec)"
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
910 info: use the dynamic elaboration model (compiler switch -gnatE)
111
kono
parents:
diff changeset
911
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
912 The diagnostic consist of the following sections:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
913
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
914 * Reason
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
915
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
916 This section provides a short explanation describing why the set of units
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
917 could not be ordered.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
918
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
919 * Circularity
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
920
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
921 This section enumerates the units comprising the deadlocked set, along with
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
922 their interdependencies.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
923
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
924 * Suggestions
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
925
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
926 This section enumerates various tactics for eliminating the circularity.
111
kono
parents:
diff changeset
927
kono
parents:
diff changeset
928 .. _Resolving_Elaboration_Circularities:
kono
parents:
diff changeset
929
kono
parents:
diff changeset
930 Resolving Elaboration Circularities
kono
parents:
diff changeset
931 ===================================
kono
parents:
diff changeset
932
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
933 The most desirable option from the point of view of long-term maintenance is to
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
934 rearrange the program so that the elaboration problems are avoided. One useful
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
935 technique is to place the elaboration code into separate child packages.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
936 Another is to move some of the initialization code to explicitly invoked
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
937 subprograms, where the program controls the order of initialization explicitly.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
938 Although this is the most desirable option, it may be impractical and involve
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
939 too much modification, especially in the case of complex legacy code.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
940
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
941 When faced with an elaboration circularity, the programmer should also consider
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
942 the tactics given in the suggestions section of the circularity diagnostic.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
943 Depending on the units involved in the circularity, their |with| clauses,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
944 purity, preelaborability, presence of elaboration-control pragmas and
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
945 invocations at elaboration time, the binder may suggest one or more of the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
946 following tactics to eliminate the circularity:
111
kono
parents:
diff changeset
947
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
948 * Pragma Elaborate elimination
111
kono
parents:
diff changeset
949
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
950 ::
111
kono
parents:
diff changeset
951
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
952 remove pragma Elaborate for unit "..." in unit "..."
111
kono
parents:
diff changeset
953
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
954 This tactic is suggested when the binder has determined that pragma
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
955 ``Elaborate``:
111
kono
parents:
diff changeset
956
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
957 - Prevents a set of units from being elaborated.
111
kono
parents:
diff changeset
958
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
959 - The removal of the pragma will not eliminate the semantic effects of the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
960 pragma. In other words, the argument of the pragma will still be elaborated
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
961 prior to the unit containing the pragma.
111
kono
parents:
diff changeset
962
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
963 - The removal of the pragma will enable the successful ordering of the units.
111
kono
parents:
diff changeset
964
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
965 The programmer should remove the pragma as advised, and rebuild the program.
111
kono
parents:
diff changeset
966
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
967 * Pragma Elaborate_All elimination
111
kono
parents:
diff changeset
968
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
969 ::
111
kono
parents:
diff changeset
970
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
971 remove pragma Elaborate_All for unit "..." in unit "..."
111
kono
parents:
diff changeset
972
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
973 This tactic is suggested when the binder has determined that pragma
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
974 ``Elaborate_All``:
111
kono
parents:
diff changeset
975
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
976 - Prevents a set of units from being elaborated.
111
kono
parents:
diff changeset
977
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
978 - The removal of the pragma will not eliminate the semantic effects of the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
979 pragma. In other words, the argument of the pragma along with its |with|
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
980 closure will still be elaborated prior to the unit containing the pragma.
111
kono
parents:
diff changeset
981
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
982 - The removal of the pragma will enable the successful ordering of the units.
111
kono
parents:
diff changeset
983
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
984 The programmer should remove the pragma as advised, and rebuild the program.
111
kono
parents:
diff changeset
985
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
986 * Pragma Elaborate_All downgrade
111
kono
parents:
diff changeset
987
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
988 ::
111
kono
parents:
diff changeset
989
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
990 change pragma Elaborate_All for unit "..." to Elaborate in unit "..."
111
kono
parents:
diff changeset
991
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
992 This tactic is always suggested with the pragma ``Elaborate_All`` elimination
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
993 tactic. It offers a different alernative of guaranteeing that the argument of
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
994 the pragma will still be elaborated prior to the unit containing the pragma.
111
kono
parents:
diff changeset
995
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
996 The programmer should update the pragma as advised, and rebuild the program.
111
kono
parents:
diff changeset
997
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
998 * Pragma Elaborate_Body elimination
111
kono
parents:
diff changeset
999
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1000 ::
111
kono
parents:
diff changeset
1001
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1002 remove pragma Elaborate_Body in unit "..."
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1003
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1004 This tactic is suggested when the binder has determined that pragma
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1005 ``Elaborate_Body``:
111
kono
parents:
diff changeset
1006
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1007 - Prevents a set of units from being elaborated.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1008
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1009 - The removal of the pragma will enable the successful ordering of the units.
111
kono
parents:
diff changeset
1010
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1011 Note that the binder cannot determine whether the pragma is required for
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1012 other purposes, such as guaranteeing the initialization of a variable
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1013 declared in the spec by elaboration code in the body.
111
kono
parents:
diff changeset
1014
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1015 The programmer should remove the pragma as advised, and rebuild the program.
111
kono
parents:
diff changeset
1016
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1017 * Use of pragma Restrictions
111
kono
parents:
diff changeset
1018
kono
parents:
diff changeset
1019 ::
kono
parents:
diff changeset
1020
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1021 use pragma Restrictions (No_Entry_Calls_In_Elaboration_Code)
111
kono
parents:
diff changeset
1022
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1023 This tactic is suggested when the binder has determined that a task
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1024 activation at elaboration time:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1025
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1026 - Prevents a set of units from being elaborated.
111
kono
parents:
diff changeset
1027
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1028 Note that the binder cannot determine with certainty whether the task will
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1029 block at elaboration time.
111
kono
parents:
diff changeset
1030
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1031 The programmer should create a configuration file, place the pragma within,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1032 update the general compilation arguments, and rebuild the program.
111
kono
parents:
diff changeset
1033
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1034 * Use of dynamic elaboration model
111
kono
parents:
diff changeset
1035
kono
parents:
diff changeset
1036 ::
kono
parents:
diff changeset
1037
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1038 use the dynamic elaboration model (compiler switch -gnatE)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1039
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1040 This tactic is suggested when the binder has determined that an invocation at
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1041 elaboration time:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1042
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1043 - Prevents a set of units from being elaborated.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1044
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1045 - The use of the dynamic model will enable the successful ordering of the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1046 units.
111
kono
parents:
diff changeset
1047
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1048 The programmer has two options:
111
kono
parents:
diff changeset
1049
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1050 - Determine the units involved in the invocation using the detailed
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1051 invocation information, and add compiler switch :switch:`-gnatE` to the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1052 compilation arguments of selected files only. This approach will yield
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1053 safer elaboration orders compared to the other option because it will
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1054 minimize the opportunities presented to the dynamic model for ignoring
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1055 invocations.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1056
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1057 - Add compiler switch :switch:`-gnatE` to the general compilation arguments.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1058
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1059 * Use of detailed invocation information
111
kono
parents:
diff changeset
1060
kono
parents:
diff changeset
1061 ::
kono
parents:
diff changeset
1062
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1063 use detailed invocation information (compiler switch -gnatd_F)
111
kono
parents:
diff changeset
1064
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1065 This tactic is always suggested with the use of the dynamic model tactic. It
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1066 causes the circularity section of the circularity diagnostic to describe the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1067 flow of elaboration code from a unit to a unit, enumerating all such paths in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1068 the process.
111
kono
parents:
diff changeset
1069
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1070 The programmer should analyze this information to determine which units
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1071 should be compiled with the dynamic model.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1072
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1073 * Forced-dependency elimination
111
kono
parents:
diff changeset
1074
kono
parents:
diff changeset
1075 ::
kono
parents:
diff changeset
1076
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1077 remove the dependency of unit "..." on unit "..." from the argument of switch -f
111
kono
parents:
diff changeset
1078
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1079 This tactic is suggested when the binder has determined that a dependency
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1080 present in the forced-elaboration-order file indicated by binder switch
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1081 :switch:`-f`:
111
kono
parents:
diff changeset
1082
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1083 - Prevents a set of units from being elaborated.
111
kono
parents:
diff changeset
1084
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1085 - The removal of the dependency will enable the successful ordering of the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1086 units.
111
kono
parents:
diff changeset
1087
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1088 The programmer should edit the forced-elaboration-order file, remove the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1089 dependency, and rebind the program.
111
kono
parents:
diff changeset
1090
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1091 * All forced-dependency elimination
111
kono
parents:
diff changeset
1092
kono
parents:
diff changeset
1093 ::
kono
parents:
diff changeset
1094
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1095 remove switch -f
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1096
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1097 This tactic is suggested in case editing the forced-elaboration-order file is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1098 not an option.
111
kono
parents:
diff changeset
1099
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1100 The programmer should remove binder switch :switch:`-f` from the binder
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1101 arguments, and rebind.
111
kono
parents:
diff changeset
1102
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1103 * Multiple-circularities diagnostic
111
kono
parents:
diff changeset
1104
kono
parents:
diff changeset
1105 ::
kono
parents:
diff changeset
1106
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1107 diagnose all circularities (binder switch -d_C)
111
kono
parents:
diff changeset
1108
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1109 By default, the binder will diagnose only the highest-precedence circularity.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1110 If the program contains multiple circularities, the binder will suggest the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1111 use of binder switch :switch:`-d_C` in order to obtain the diagnostics of all
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1112 circularities.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1113
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1114 The programmer should add binder switch :switch:`-d_C` to the binder
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1115 arguments, and rebind.
111
kono
parents:
diff changeset
1116
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1117 If none of the tactics suggested by the binder eliminate the elaboration
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1118 circularity, the programmer should consider using one of the legacy elaboration
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1119 models, in the following order:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1120
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1121 * Use the pre-20.x legacy elaboration-order model, with binder switch
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1122 :switch:`-H`.
111
kono
parents:
diff changeset
1123
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1124 * Use both pre-18.x and pre-20.x legacy elaboration models, with compiler
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1125 switch :switch:`-gnatH` and binder switch :switch:`-H`.
111
kono
parents:
diff changeset
1126
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1127 * Use the relaxed static-elaboration model, with compiler switches
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1128 :switch:`-gnatH` :switch:`-gnatJ` and binder switch :switch:`-H`.
111
kono
parents:
diff changeset
1129
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1130 * Use the relaxed dynamic-elaboration model, with compiler switches
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1131 :switch:`-gnatH` :switch:`-gnatJ` :switch:`-gnatE` and binder switch
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1132 :switch:`-H`.
111
kono
parents:
diff changeset
1133
kono
parents:
diff changeset
1134 .. _Elaboration_Related_Compiler_Switches:
kono
parents:
diff changeset
1135
kono
parents:
diff changeset
1136 Elaboration-related Compiler Switches
kono
parents:
diff changeset
1137 =====================================
kono
parents:
diff changeset
1138
kono
parents:
diff changeset
1139 GNAT has several switches that affect the elaboration model and consequently
kono
parents:
diff changeset
1140 the elaboration order chosen by the binder.
kono
parents:
diff changeset
1141
kono
parents:
diff changeset
1142 .. index:: -gnatE (gnat)
kono
parents:
diff changeset
1143
kono
parents:
diff changeset
1144 :switch:`-gnatE`
kono
parents:
diff changeset
1145 Dynamic elaboration checking mode enabled
kono
parents:
diff changeset
1146
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1147 When this switch is in effect, GNAT activates the dynamic model.
111
kono
parents:
diff changeset
1148
kono
parents:
diff changeset
1149 .. index:: -gnatel (gnat)
kono
parents:
diff changeset
1150
kono
parents:
diff changeset
1151 :switch:`-gnatel`
kono
parents:
diff changeset
1152 Turn on info messages on generated Elaborate[_All] pragmas
kono
parents:
diff changeset
1153
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1154 This switch is only applicable to the pre-20.x legacy elaboration models.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1155 The post-20.x elaboration model no longer relies on implicitly generated
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1156 ``Elaborate`` and ``Elaborate_All`` pragmas to order units.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1157
111
kono
parents:
diff changeset
1158 When this switch is in effect, GNAT will emit the following supplementary
kono
parents:
diff changeset
1159 information depending on the elaboration model in effect.
kono
parents:
diff changeset
1160
kono
parents:
diff changeset
1161 - *Dynamic model*
kono
parents:
diff changeset
1162
kono
parents:
diff changeset
1163 GNAT will indicate missing ``Elaborate`` and ``Elaborate_All`` pragmas for
kono
parents:
diff changeset
1164 all library-level scenarios within the partition.
kono
parents:
diff changeset
1165
kono
parents:
diff changeset
1166 - *Static model*
kono
parents:
diff changeset
1167
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1168 GNAT will indicate all scenarios invoked during elaboration. In addition,
111
kono
parents:
diff changeset
1169 it will provide detailed traceback when an implicit ``Elaborate`` or
kono
parents:
diff changeset
1170 ``Elaborate_All`` pragma is generated.
kono
parents:
diff changeset
1171
kono
parents:
diff changeset
1172 - *SPARK model*
kono
parents:
diff changeset
1173
kono
parents:
diff changeset
1174 GNAT will indicate how an elaboration requirement is met by the context of
kono
parents:
diff changeset
1175 a unit. This diagnostic requires compiler switch :switch:`-gnatd.v`.
kono
parents:
diff changeset
1176
kono
parents:
diff changeset
1177 ::
kono
parents:
diff changeset
1178
kono
parents:
diff changeset
1179 1. with Server; pragma Elaborate_All (Server);
kono
parents:
diff changeset
1180 2. package Client with SPARK_Mode is
kono
parents:
diff changeset
1181 3. Val : constant Integer := Server.Func;
kono
parents:
diff changeset
1182 |
kono
parents:
diff changeset
1183 >>> info: call to "Func" during elaboration in SPARK
kono
parents:
diff changeset
1184 >>> info: "Elaborate_All" requirement for unit "Server" met by pragma at line 1
kono
parents:
diff changeset
1185
kono
parents:
diff changeset
1186 4. end Client;
kono
parents:
diff changeset
1187
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1188 .. index:: -gnatH (gnat)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1189
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1190 :switch:`-gnatH`
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1191 Legacy elaboration checking mode enabled
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1192
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1193 When this switch is in effect, GNAT will utilize the pre-18.x elaboration
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1194 model.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1195
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1196 .. index:: -gnatJ (gnat)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1197
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1198 :switch:`-gnatJ`
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1199 Relaxed elaboration checking mode enabled
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1200
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1201 When this switch is in effect, GNAT will not process certain scenarios,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1202 resulting in a more permissive elaboration model. Note that this may
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1203 eliminate some diagnostics and run-time checks.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1204
111
kono
parents:
diff changeset
1205 .. index:: -gnatw.f (gnat)
kono
parents:
diff changeset
1206
kono
parents:
diff changeset
1207 :switch:`-gnatw.f`
kono
parents:
diff changeset
1208 Turn on warnings for suspicious Subp'Access
kono
parents:
diff changeset
1209
kono
parents:
diff changeset
1210 When this switch is in effect, GNAT will treat ``'Access`` of an entry,
kono
parents:
diff changeset
1211 operator, or subprogram as a potential call to the target and issue warnings:
kono
parents:
diff changeset
1212
kono
parents:
diff changeset
1213 ::
kono
parents:
diff changeset
1214
kono
parents:
diff changeset
1215 1. package body Attribute_Call is
kono
parents:
diff changeset
1216 2. function Func return Integer;
kono
parents:
diff changeset
1217 3. type Func_Ptr is access function return Integer;
kono
parents:
diff changeset
1218 4.
kono
parents:
diff changeset
1219 5. Ptr : constant Func_Ptr := Func'Access;
kono
parents:
diff changeset
1220 |
kono
parents:
diff changeset
1221 >>> warning: "Access" attribute of "Func" before body seen
kono
parents:
diff changeset
1222 >>> warning: possible Program_Error on later references
kono
parents:
diff changeset
1223 >>> warning: body of unit "Attribute_Call" elaborated
kono
parents:
diff changeset
1224 >>> warning: "Access" of "Func" taken at line 5
kono
parents:
diff changeset
1225
kono
parents:
diff changeset
1226 6.
kono
parents:
diff changeset
1227 7. function Func return Integer is
kono
parents:
diff changeset
1228 8. begin
kono
parents:
diff changeset
1229 9. ...
kono
parents:
diff changeset
1230 10. end Func;
kono
parents:
diff changeset
1231 11. end Attribute_Call;
kono
parents:
diff changeset
1232
kono
parents:
diff changeset
1233 In the example above, the elaboration of declaration ``Ptr`` is assigned
kono
parents:
diff changeset
1234 ``Func'Access`` before the body of ``Func`` has been elaborated.
kono
parents:
diff changeset
1235
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1236 .. index:: -gnatwl (gnat)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1237
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1238 :switch:`-gnatwl`
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1239 Turn on warnings for elaboration problems
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1240
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1241 When this switch is in effect, GNAT emits diagnostics in the form of warnings
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1242 concerning various elaboration problems. The warnings are enabled by default.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1243 The switch is provided in case all warnings are suppressed, but elaboration
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1244 warnings are still desired.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1245
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1246 :switch:`-gnatwL`
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1247 Turn off warnings for elaboration problems
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1248
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1249 When this switch is in effect, GNAT no longer emits any diagnostics in the
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1250 form of warnings. Selective suppression of elaboration problems is possible
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1251 using ``pragma Warnings (Off)``.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1252
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1253 ::
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1254
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1255 1. package body Selective_Suppression is
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1256 2. function ABE return Integer;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1257 3.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1258 4. Val_1 : constant Integer := ABE;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1259 |
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1260 >>> warning: cannot call "ABE" before body seen
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1261 >>> warning: Program_Error will be raised at run time
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1262
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1263 5.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1264 6. pragma Warnings (Off);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1265 7. Val_2 : constant Integer := ABE;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1266 8. pragma Warnings (On);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1267 9.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1268 10. function ABE return Integer is
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1269 11. begin
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1270 12. ...
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1271 13. end ABE;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1272 14. end Selective_Suppression;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1273
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1274 Note that suppressing elaboration warnings does not eliminate run-time
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1275 checks. The example above will still fail at run time with an ABE.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1276
111
kono
parents:
diff changeset
1277 .. _Summary_of_Procedures_for_Elaboration_Control:
kono
parents:
diff changeset
1278
kono
parents:
diff changeset
1279 Summary of Procedures for Elaboration Control
kono
parents:
diff changeset
1280 =============================================
kono
parents:
diff changeset
1281
kono
parents:
diff changeset
1282 A programmer should first compile the program with the default options, using
kono
parents:
diff changeset
1283 none of the binder or compiler switches. If the binder succeeds in finding an
kono
parents:
diff changeset
1284 elaboration order, then apart from possible cases involing dispatching calls
kono
parents:
diff changeset
1285 and access-to-subprogram types, the program is free of elaboration errors.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1286
111
kono
parents:
diff changeset
1287 If it is important for the program to be portable to compilers other than GNAT,
kono
parents:
diff changeset
1288 then the programmer should use compiler switch :switch:`-gnatel` and consider
kono
parents:
diff changeset
1289 the messages about missing or implicitly created ``Elaborate`` and
kono
parents:
diff changeset
1290 ``Elaborate_All`` pragmas.
kono
parents:
diff changeset
1291
kono
parents:
diff changeset
1292 If the binder reports an elaboration circularity, the programmer has several
kono
parents:
diff changeset
1293 options:
kono
parents:
diff changeset
1294
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1295 * Ensure that elaboration warnings are enabled. This will allow the static
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1296 model to output trace information of elaboration issues. The trace
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1297 information could shed light on previously unforeseen dependencies, as well
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1298 as their origins. Elaboration warnings are enabled with compiler switch
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1299 :switch:`-gnatwl`.
111
kono
parents:
diff changeset
1300
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1301 * Cosider the tactics given in the suggestions section of the circularity
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1302 diagnostic.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1303
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1304 * If none of the steps outlined above resolve the circularity, use a more
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1305 permissive elaboration model, in the following order:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1306
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1307 - Use the pre-20.x legacy elaboration-order model, with binder switch
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1308 :switch:`-H`.
111
kono
parents:
diff changeset
1309
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1310 - Use both pre-18.x and pre-20.x legacy elaboration models, with compiler
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1311 switch :switch:`-gnatH` and binder switch :switch:`-H`.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1312
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1313 - Use the relaxed static elaboration model, with compiler switches
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1314 :switch:`-gnatH` :switch:`-gnatJ` and binder switch :switch:`-H`.
111
kono
parents:
diff changeset
1315
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1316 - Use the relaxed dynamic elaboration model, with compiler switches
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1317 :switch:`-gnatH` :switch:`-gnatJ` :switch:`-gnatE` and binder switch
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1318 :switch:`-H`.
111
kono
parents:
diff changeset
1319
kono
parents:
diff changeset
1320 .. _Inspecting_the_Chosen_Elaboration_Order:
kono
parents:
diff changeset
1321
kono
parents:
diff changeset
1322 Inspecting the Chosen Elaboration Order
kono
parents:
diff changeset
1323 =======================================
kono
parents:
diff changeset
1324
kono
parents:
diff changeset
1325 To see the elaboration order chosen by the binder, inspect the contents of file
kono
parents:
diff changeset
1326 `b~xxx.adb`. On certain targets, this file appears as `b_xxx.adb`. The
kono
parents:
diff changeset
1327 elaboration order appears as a sequence of calls to ``Elab_Body`` and
kono
parents:
diff changeset
1328 ``Elab_Spec``, interspersed with assignments to `Exxx` which indicates that a
kono
parents:
diff changeset
1329 particular unit is elaborated. For example:
kono
parents:
diff changeset
1330
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1331 ::
111
kono
parents:
diff changeset
1332
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1333 System.Soft_Links'Elab_Body;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1334 E14 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1335 System.Secondary_Stack'Elab_Body;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1336 E18 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1337 System.Exception_Table'Elab_Body;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1338 E24 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1339 Ada.Io_Exceptions'Elab_Spec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1340 E67 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1341 Ada.Tags'Elab_Spec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1342 Ada.Streams'Elab_Spec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1343 E43 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1344 Interfaces.C'Elab_Spec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1345 E69 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1346 System.Finalization_Root'Elab_Spec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1347 E60 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1348 System.Os_Lib'Elab_Body;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1349 E71 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1350 System.Finalization_Implementation'Elab_Spec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1351 System.Finalization_Implementation'Elab_Body;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1352 E62 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1353 Ada.Finalization'Elab_Spec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1354 E58 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1355 Ada.Finalization.List_Controller'Elab_Spec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1356 E76 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1357 System.File_Control_Block'Elab_Spec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1358 E74 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1359 System.File_Io'Elab_Body;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1360 E56 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1361 Ada.Tags'Elab_Body;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1362 E45 := True;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1363 Ada.Text_Io'Elab_Spec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1364 Ada.Text_Io'Elab_Body;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1365 E07 := True;
111
kono
parents:
diff changeset
1366
kono
parents:
diff changeset
1367 Note also binder switch :switch:`-l`, which outputs the chosen elaboration
kono
parents:
diff changeset
1368 order and provides a more readable form of the above:
kono
parents:
diff changeset
1369
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1370 ::
111
kono
parents:
diff changeset
1371
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1372 ada (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1373 interfaces (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1374 system (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1375 system.case_util (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1376 system.case_util (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1377 system.concat_2 (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1378 system.concat_2 (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1379 system.concat_3 (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1380 system.concat_3 (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1381 system.htable (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1382 system.parameters (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1383 system.parameters (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1384 system.crtl (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1385 interfaces.c_streams (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1386 interfaces.c_streams (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1387 system.restrictions (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1388 system.restrictions (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1389 system.standard_library (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1390 system.exceptions (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1391 system.exceptions (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1392 system.storage_elements (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1393 system.storage_elements (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1394 system.secondary_stack (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1395 system.stack_checking (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1396 system.stack_checking (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1397 system.string_hash (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1398 system.string_hash (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1399 system.htable (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1400 system.strings (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1401 system.strings (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1402 system.traceback (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1403 system.traceback (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1404 system.traceback_entries (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1405 system.traceback_entries (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1406 ada.exceptions (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1407 ada.exceptions.last_chance_handler (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1408 system.soft_links (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1409 system.soft_links (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1410 ada.exceptions.last_chance_handler (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1411 system.secondary_stack (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1412 system.exception_table (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1413 system.exception_table (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1414 ada.io_exceptions (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1415 ada.tags (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1416 ada.streams (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1417 interfaces.c (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1418 interfaces.c (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1419 system.finalization_root (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1420 system.finalization_root (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1421 system.memory (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1422 system.memory (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1423 system.standard_library (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1424 system.os_lib (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1425 system.os_lib (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1426 system.unsigned_types (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1427 system.stream_attributes (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1428 system.stream_attributes (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1429 system.finalization_implementation (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1430 system.finalization_implementation (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1431 ada.finalization (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1432 ada.finalization (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1433 ada.finalization.list_controller (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1434 ada.finalization.list_controller (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1435 system.file_control_block (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1436 system.file_io (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1437 system.file_io (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1438 system.val_uns (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1439 system.val_util (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1440 system.val_util (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1441 system.val_uns (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1442 system.wch_con (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1443 system.wch_con (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1444 system.wch_cnv (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1445 system.wch_jis (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1446 system.wch_jis (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1447 system.wch_cnv (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1448 system.wch_stw (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1449 system.wch_stw (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1450 ada.tags (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1451 ada.exceptions (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1452 ada.text_io (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1453 ada.text_io (body)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1454 text_io (spec)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1455 gdbstr (body)