annotate gcc/ada/sem.ads @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S E M --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 --------------------------------------
kono
parents:
diff changeset
27 -- Semantic Analysis: General Model --
kono
parents:
diff changeset
28 --------------------------------------
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 -- Semantic processing involves 3 phases which are highly intertwined
kono
parents:
diff changeset
31 -- (i.e. mutually recursive):
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 -- Analysis implements the bulk of semantic analysis such as
kono
parents:
diff changeset
34 -- name analysis and type resolution for declarations,
kono
parents:
diff changeset
35 -- instructions and expressions. The main routine
kono
parents:
diff changeset
36 -- driving this process is procedure Analyze given below.
kono
parents:
diff changeset
37 -- This analysis phase is really a bottom up pass that is
kono
parents:
diff changeset
38 -- achieved during the recursive traversal performed by the
kono
parents:
diff changeset
39 -- Analyze_... procedures implemented in the sem_* packages.
kono
parents:
diff changeset
40 -- For expressions this phase determines unambiguous types
kono
parents:
diff changeset
41 -- and collects sets of possible types where the
kono
parents:
diff changeset
42 -- interpretation is potentially ambiguous.
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 -- Resolution is carried out only for expressions to finish type
kono
parents:
diff changeset
45 -- resolution that was initiated but not necessarily
kono
parents:
diff changeset
46 -- completed during analysis (because of overloading
kono
parents:
diff changeset
47 -- ambiguities). Specifically, after completing the bottom
kono
parents:
diff changeset
48 -- up pass carried out during analysis for expressions, the
kono
parents:
diff changeset
49 -- Resolve routine (see the spec of sem_res for more info)
kono
parents:
diff changeset
50 -- is called to perform a top down resolution with
kono
parents:
diff changeset
51 -- recursive calls to itself to resolve operands.
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 -- Expansion if we are not generating code this phase is a no-op.
kono
parents:
diff changeset
54 -- otherwise this phase expands, i.e. transforms, original
kono
parents:
diff changeset
55 -- declaration, expressions or instructions into simpler
kono
parents:
diff changeset
56 -- structures that can be handled by the back-end. This
kono
parents:
diff changeset
57 -- phase is also in charge of generating code which is
kono
parents:
diff changeset
58 -- implicit in the original source (for instance for
kono
parents:
diff changeset
59 -- default initializations, controlled types, etc.)
kono
parents:
diff changeset
60 -- There are two separate instances where expansion is
kono
parents:
diff changeset
61 -- invoked. For declarations and instructions, expansion is
kono
parents:
diff changeset
62 -- invoked just after analysis since no resolution needs
kono
parents:
diff changeset
63 -- to be performed. For expressions, expansion is done just
kono
parents:
diff changeset
64 -- after resolution. In both cases expansion is done from the
kono
parents:
diff changeset
65 -- bottom up just before the end of Analyze for instructions
kono
parents:
diff changeset
66 -- and declarations or the call to Resolve for expressions.
kono
parents:
diff changeset
67 -- The main routine driving expansion is Expand.
kono
parents:
diff changeset
68 -- See the spec of Expander for more details.
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 -- To summarize, in normal code generation mode we recursively traverse the
kono
parents:
diff changeset
71 -- abstract syntax tree top-down performing semantic analysis bottom
kono
parents:
diff changeset
72 -- up. For instructions and declarations, before the call to the Analyze
kono
parents:
diff changeset
73 -- routine completes we perform expansion since at that point we have all
kono
parents:
diff changeset
74 -- semantic information needed. For expression nodes, after the call to
kono
parents:
diff changeset
75 -- Analysis terminates we invoke the Resolve routine to transmit top-down
kono
parents:
diff changeset
76 -- the type that was gathered by Analyze which will resolve possible
kono
parents:
diff changeset
77 -- ambiguities in the expression. Just before the call to Resolve
kono
parents:
diff changeset
78 -- terminates, the expression can be expanded since all the semantic
kono
parents:
diff changeset
79 -- information is available at that point.
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 -- If we are not generating code then the expansion phase is a no-op
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 -- When generating code there are a number of exceptions to the basic
kono
parents:
diff changeset
84 -- Analysis-Resolution-Expansion model for expressions. The most prominent
kono
parents:
diff changeset
85 -- examples are the handling of default expressions and aggregates.
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 -----------------------------------------------------------------------
kono
parents:
diff changeset
88 -- Handling of Default and Per-Object Expressions (Spec-Expressions) --
kono
parents:
diff changeset
89 -----------------------------------------------------------------------
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 -- The default expressions in component declarations and in procedure
kono
parents:
diff changeset
92 -- specifications (but not the ones in object declarations) are quite tricky
kono
parents:
diff changeset
93 -- to handle. The problem is that some processing is required at the point
kono
parents:
diff changeset
94 -- where the expression appears:
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 -- visibility analysis (including user defined operators)
kono
parents:
diff changeset
97 -- freezing of static expressions
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 -- but other processing must be deferred until the enclosing entity (record or
kono
parents:
diff changeset
100 -- procedure specification) is frozen:
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 -- freezing of any other types in the expression expansion
kono
parents:
diff changeset
103 -- generation of code
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 -- A similar situation occurs with the argument of priority and interrupt
kono
parents:
diff changeset
106 -- priority pragmas that appear in task and protected definition specs and
kono
parents:
diff changeset
107 -- other cases of per-object expressions (see RM 3.8(18)).
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 -- Another similar case is the conditions in precondition and postcondition
kono
parents:
diff changeset
110 -- pragmas that appear with subprogram specifications rather than in the body.
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 -- Collectively we call these Spec_Expressions. The routine that performs the
kono
parents:
diff changeset
113 -- special analysis is called Analyze_Spec_Expression.
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 -- Expansion has to be deferred since you can't generate code for expressions
kono
parents:
diff changeset
116 -- that reference types that have not been frozen yet. As an example, consider
kono
parents:
diff changeset
117 -- the following:
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 -- type x is delta 0.5 range -10.0 .. +10.0;
kono
parents:
diff changeset
120 -- ...
kono
parents:
diff changeset
121 -- type q is record
kono
parents:
diff changeset
122 -- xx : x := y * z;
kono
parents:
diff changeset
123 -- end record;
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 -- for x'small use 0.25;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 -- The expander is in charge of dealing with fixed-point, and of course the
kono
parents:
diff changeset
128 -- small declaration, which is not too late, since the declaration of type q
kono
parents:
diff changeset
129 -- does *not* freeze type x, definitely affects the expanded code.
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 -- Another reason that we cannot expand early is that expansion can generate
kono
parents:
diff changeset
132 -- range checks. These range checks need to be inserted not at the point of
kono
parents:
diff changeset
133 -- definition but at the point of use. The whole point here is that the value
kono
parents:
diff changeset
134 -- of the expression cannot be obtained at the point of declaration, only at
kono
parents:
diff changeset
135 -- the point of use.
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 -- Generally our model is to combine analysis resolution and expansion, but
kono
parents:
diff changeset
138 -- this is the one case where this model falls down. Here is how we patch
kono
parents:
diff changeset
139 -- it up without causing too much distortion to our basic model.
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 -- A switch (In_Spec_Expression) is set to show that we are in the initial
kono
parents:
diff changeset
142 -- occurrence of a default expression. The analyzer is then called on this
kono
parents:
diff changeset
143 -- expression with the switch set true. Analysis and resolution proceed almost
kono
parents:
diff changeset
144 -- as usual, except that Freeze_Expression will not freeze non-static
kono
parents:
diff changeset
145 -- expressions if this switch is set, and the call to Expand at the end of
kono
parents:
diff changeset
146 -- resolution is skipped. This also skips the code that normally sets the
kono
parents:
diff changeset
147 -- Analyzed flag to True. The result is that when we are done the tree is
kono
parents:
diff changeset
148 -- still marked as unanalyzed, but all types for static expressions are frozen
kono
parents:
diff changeset
149 -- as required, and all entities of variables have been recorded. We then turn
kono
parents:
diff changeset
150 -- off the switch, and later on reanalyze the expression with the switch off.
kono
parents:
diff changeset
151 -- The effect is that this second analysis freezes the rest of the types as
kono
parents:
diff changeset
152 -- required, and generates code but visibility analysis is not repeated since
kono
parents:
diff changeset
153 -- all the entities are marked.
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 -- The second analysis (the one that generates code) is in the context
kono
parents:
diff changeset
156 -- where the code is required. For a record field default, this is in the
kono
parents:
diff changeset
157 -- initialization procedure for the record and for a subprogram default
kono
parents:
diff changeset
158 -- parameter, it is at the point the subprogram is frozen. For a priority or
kono
parents:
diff changeset
159 -- storage size pragma it is in the context of the Init_Proc for the task or
kono
parents:
diff changeset
160 -- protected object. For a pre/postcondition pragma it is in the body when
kono
parents:
diff changeset
161 -- code for the pragma is generated.
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 ------------------
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
164 -- Preanalysis --
111
kono
parents:
diff changeset
165 ------------------
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 -- For certain kind of expressions, such as aggregates, we need to defer
kono
parents:
diff changeset
168 -- expansion of the aggregate and its inner expressions until after the whole
kono
parents:
diff changeset
169 -- set of expressions appearing inside the aggregate have been analyzed.
kono
parents:
diff changeset
170 -- Consider, for instance the following example:
kono
parents:
diff changeset
171 --
kono
parents:
diff changeset
172 -- (1 .. 100 => new Thing (Function_Call))
kono
parents:
diff changeset
173 --
kono
parents:
diff changeset
174 -- The normal Analysis-Resolution-Expansion mechanism where expansion of the
kono
parents:
diff changeset
175 -- children is performed before expansion of the parent does not work if the
kono
parents:
diff changeset
176 -- code generated for the children by the expander needs to be evaluated
kono
parents:
diff changeset
177 -- repeatedly (for instance in the above aggregate "new Thing (Function_Call)"
kono
parents:
diff changeset
178 -- needs to be called 100 times.)
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 -- The reason this mechanism does not work is that the expanded code for the
kono
parents:
diff changeset
181 -- children is typically inserted above the parent and thus when the father
kono
parents:
diff changeset
182 -- gets expanded no re-evaluation takes place. For instance in the case of
kono
parents:
diff changeset
183 -- aggregates if "new Thing (Function_Call)" is expanded before the aggregate
kono
parents:
diff changeset
184 -- the expanded code will be placed outside of the aggregate and when
kono
parents:
diff changeset
185 -- expanding the aggregate the loop from 1 to 100 will not surround the
kono
parents:
diff changeset
186 -- expanded code for "new Thing (Function_Call)".
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 -- To remedy this situation we introduce a flag that signals whether we want a
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
189 -- full analysis (i.e. expansion is enabled) or a preanalysis which performs
111
kono
parents:
diff changeset
190 -- Analysis and Resolution but no expansion.
kono
parents:
diff changeset
191
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
192 -- After the complete preanalysis of an expression has been carried out we
111
kono
parents:
diff changeset
193 -- can transform the expression and then carry out the full three stage
kono
parents:
diff changeset
194 -- (Analyze-Resolve-Expand) cycle on the transformed expression top-down so
kono
parents:
diff changeset
195 -- that the expansion of inner expressions happens inside the newly generated
kono
parents:
diff changeset
196 -- node for the parent expression.
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 -- Note that the difference between processing of default expressions and
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
199 -- preanalysis of other expressions is that we do carry out freezing in
111
kono
parents:
diff changeset
200 -- the latter but not in the former (except for static scalar expressions).
kono
parents:
diff changeset
201 -- The routine that performs preanalysis and corresponding resolution is
kono
parents:
diff changeset
202 -- called Preanalyze_And_Resolve and is in Sem_Res.
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 with Alloc;
kono
parents:
diff changeset
205 with Einfo; use Einfo;
kono
parents:
diff changeset
206 with Opt; use Opt;
kono
parents:
diff changeset
207 with Table;
kono
parents:
diff changeset
208 with Types; use Types;
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 package Sem is
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 -----------------------------
kono
parents:
diff changeset
213 -- Semantic Analysis Flags --
kono
parents:
diff changeset
214 -----------------------------
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 Full_Analysis : Boolean := True;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
217 -- Switch to indicate if we are doing a full analysis or a preanalysis.
111
kono
parents:
diff changeset
218 -- In normal analysis mode (Analysis-Expansion for instructions or
kono
parents:
diff changeset
219 -- declarations) or (Analysis-Resolution-Expansion for expressions) this
kono
parents:
diff changeset
220 -- flag is set. Note that if we are not generating code the expansion phase
kono
parents:
diff changeset
221 -- merely sets the Analyzed flag to True in this case. If we are in
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
222 -- Preanalysis mode (see above) this flag is set to False then the
111
kono
parents:
diff changeset
223 -- expansion phase is skipped.
kono
parents:
diff changeset
224 --
kono
parents:
diff changeset
225 -- When this flag is False the flag Expander_Active is also False (the
kono
parents:
diff changeset
226 -- Expander_Active flag defined in the spec of package Expander tells you
kono
parents:
diff changeset
227 -- whether expansion is currently enabled). You should really regard this
kono
parents:
diff changeset
228 -- as a read only flag.
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 In_Spec_Expression : Boolean := False;
kono
parents:
diff changeset
231 -- Switch to indicate that we are in a spec-expression, as described
kono
parents:
diff changeset
232 -- above. Note that this must be recursively saved on a Semantics call
kono
parents:
diff changeset
233 -- since it is possible for the analysis of an expression to result in a
kono
parents:
diff changeset
234 -- recursive call (e.g. to get the entity for System.Address as part of the
kono
parents:
diff changeset
235 -- processing of an Address attribute reference). When this switch is True
kono
parents:
diff changeset
236 -- then Full_Analysis above must be False. You should really regard this as
kono
parents:
diff changeset
237 -- a read only flag.
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 In_Deleted_Code : Boolean := False;
kono
parents:
diff changeset
240 -- If the condition in an if-statement is statically known, the branch
kono
parents:
diff changeset
241 -- that is not taken is analyzed with expansion disabled, and the tree
kono
parents:
diff changeset
242 -- is deleted after analysis. Itypes generated in deleted code must be
kono
parents:
diff changeset
243 -- frozen from start, because the tree on which they depend will not
kono
parents:
diff changeset
244 -- be available at the freeze point.
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 In_Assertion_Expr : Nat := 0;
kono
parents:
diff changeset
247 -- This is set non-zero if we are within the expression of an assertion
kono
parents:
diff changeset
248 -- pragma or aspect. It is a counter which is incremented at the start of
kono
parents:
diff changeset
249 -- expanding such an expression, and decremented on completion of expanding
kono
parents:
diff changeset
250 -- that expression. Probably a boolean would be good enough, since we think
kono
parents:
diff changeset
251 -- that such expressions cannot nest, but that might not be true in the
kono
parents:
diff changeset
252 -- future (e.g. if let expressions are added to Ada) so we prepare for that
kono
parents:
diff changeset
253 -- future possibility by making it a counter. As with In_Spec_Expression,
kono
parents:
diff changeset
254 -- it must be recursively saved and restored for a Semantics call.
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 In_Compile_Time_Warning_Or_Error : Boolean := False;
kono
parents:
diff changeset
257 -- Switch to indicate that we are validating a pragma Compile_Time_Warning
kono
parents:
diff changeset
258 -- or Compile_Time_Error after the back end has been called (to check these
kono
parents:
diff changeset
259 -- pragmas for size and alignment appropriateness).
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 In_Default_Expr : Boolean := False;
kono
parents:
diff changeset
262 -- Switch to indicate that we are analyzing a default component expression.
kono
parents:
diff changeset
263 -- As with In_Spec_Expression, it must be recursively saved and restored
kono
parents:
diff changeset
264 -- for a Semantics call.
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 In_Inlined_Body : Boolean := False;
kono
parents:
diff changeset
267 -- Switch to indicate that we are analyzing and resolving an inlined body.
kono
parents:
diff changeset
268 -- Type checking is disabled in this context, because types are known to be
kono
parents:
diff changeset
269 -- compatible. This avoids problems with private types whose full view is
kono
parents:
diff changeset
270 -- derived from private types.
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 Inside_A_Generic : Boolean := False;
kono
parents:
diff changeset
273 -- This flag is set if we are processing a generic specification, generic
kono
parents:
diff changeset
274 -- definition, or generic body. When this flag is True the Expander_Active
kono
parents:
diff changeset
275 -- flag is False to disable any code expansion (see package Expander). Only
kono
parents:
diff changeset
276 -- the generic processing can modify the status of this flag, any other
kono
parents:
diff changeset
277 -- client should regard it as read-only.
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 Inside_Freezing_Actions : Nat := 0;
kono
parents:
diff changeset
280 -- Flag indicating whether we are within a call to Expand_N_Freeze_Actions.
kono
parents:
diff changeset
281 -- Non-zero means we are inside (it is actually a level counter to deal
kono
parents:
diff changeset
282 -- with nested calls). Used to avoid traversing the tree each time a
kono
parents:
diff changeset
283 -- subprogram call is processed to know if we must not clear all constant
kono
parents:
diff changeset
284 -- indications from entities in the current scope. Only the expansion of
kono
parents:
diff changeset
285 -- freezing nodes can modify the status of this flag, any other client
kono
parents:
diff changeset
286 -- should regard it as read-only.
kono
parents:
diff changeset
287
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
288 Inside_Preanalysis_Without_Freezing : Nat := 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
289 -- Flag indicating whether we are preanalyzing an expression performing no
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
290 -- freezing. Non-zero means we are inside (it is actually a level counter
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
291 -- to deal with nested calls).
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
292
111
kono
parents:
diff changeset
293 Unloaded_Subunits : Boolean := False;
kono
parents:
diff changeset
294 -- This flag is set True if we have subunits that are not loaded. This
kono
parents:
diff changeset
295 -- occurs when the main unit is a subunit, and contains lower level
kono
parents:
diff changeset
296 -- subunits that are not loaded. We use this flag to suppress warnings
kono
parents:
diff changeset
297 -- about unused variables, since these warnings are unreliable in this
kono
parents:
diff changeset
298 -- case. We could perhaps do a more accurate job and retain some of the
kono
parents:
diff changeset
299 -- warnings, but it is quite a tricky job.
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 -----------------------------------
kono
parents:
diff changeset
302 -- Handling of Check Suppression --
kono
parents:
diff changeset
303 -----------------------------------
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 -- There are two kinds of suppress checks: scope based suppress checks,
kono
parents:
diff changeset
306 -- and entity based suppress checks.
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 -- Scope based suppress checks for the predefined checks (from initial
kono
parents:
diff changeset
309 -- command line arguments, or from Suppress pragmas not including an entity
kono
parents:
diff changeset
310 -- name) are recorded in the Sem.Scope_Suppress variable, and all that
kono
parents:
diff changeset
311 -- is necessary is to save the state of this variable on scope entry, and
kono
parents:
diff changeset
312 -- restore it on scope exit. This mechanism allows for fast checking of the
kono
parents:
diff changeset
313 -- scope suppress state without needing complex data structures.
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 -- Entity based checks, from Suppress/Unsuppress pragmas giving an
kono
parents:
diff changeset
316 -- Entity_Id and scope based checks for non-predefined checks (introduced
kono
parents:
diff changeset
317 -- using pragma Check_Name), are handled as follows. If a suppress or
kono
parents:
diff changeset
318 -- unsuppress pragma is encountered for a given entity, then the flag
kono
parents:
diff changeset
319 -- Checks_May_Be_Suppressed is set in the entity and an entry is made in
kono
parents:
diff changeset
320 -- either the Local_Entity_Suppress stack (case of pragma that appears in
kono
parents:
diff changeset
321 -- other than a package spec), or in the Global_Entity_Suppress stack (case
kono
parents:
diff changeset
322 -- of pragma that appears in a package spec, which is by the rule of RM
kono
parents:
diff changeset
323 -- 11.5(7) applicable throughout the life of the entity). Similarly, a
kono
parents:
diff changeset
324 -- Suppress/Unsuppress pragma for a non-predefined check which does not
kono
parents:
diff changeset
325 -- specify an entity is also stored in one of these stacks.
kono
parents:
diff changeset
326
kono
parents:
diff changeset
327 -- If the Checks_May_Be_Suppressed flag is set in an entity then the
kono
parents:
diff changeset
328 -- procedure is to search first the local and then the global suppress
kono
parents:
diff changeset
329 -- stacks (we search these in reverse order, top element first). The only
kono
parents:
diff changeset
330 -- other point is that we have to make sure that we have proper nested
kono
parents:
diff changeset
331 -- interaction between such specific pragmas and locally applied general
kono
parents:
diff changeset
332 -- pragmas applying to all entities. This is achieved by including in the
kono
parents:
diff changeset
333 -- Local_Entity_Suppress table dummy entries with an empty Entity field
kono
parents:
diff changeset
334 -- that are applicable to all entities. A similar search is needed for any
kono
parents:
diff changeset
335 -- non-predefined check even if no specific entity is involved.
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 Scope_Suppress : Suppress_Record;
kono
parents:
diff changeset
338 -- This variable contains the current scope based settings of the suppress
kono
parents:
diff changeset
339 -- switches. It is initialized from Suppress_Options in Gnat1drv, and then
kono
parents:
diff changeset
340 -- modified by pragma Suppress. On entry to each scope, the current setting
kono
parents:
diff changeset
341 -- is saved on the scope stack, and then restored on exit from the scope.
kono
parents:
diff changeset
342 -- This record may be rapidly checked to determine the current status of
kono
parents:
diff changeset
343 -- a check if no specific entity is involved or if the specific entity
kono
parents:
diff changeset
344 -- involved is one for which no specific Suppress/Unsuppress pragma has
kono
parents:
diff changeset
345 -- been set (as indicated by the Checks_May_Be_Suppressed flag being set).
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 -- This scheme is a little complex, but serves the purpose of enabling
kono
parents:
diff changeset
348 -- a very rapid check in the common case where no entity specific pragma
kono
parents:
diff changeset
349 -- applies, and gives the right result when such pragmas are used even
kono
parents:
diff changeset
350 -- in complex cases of nested Suppress and Unsuppress pragmas.
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 -- The Local_Entity_Suppress and Global_Entity_Suppress stacks are handled
kono
parents:
diff changeset
353 -- using dynamic allocation and linked lists. We do not often use this
kono
parents:
diff changeset
354 -- approach in the compiler (preferring to use extensible tables instead).
kono
parents:
diff changeset
355 -- The reason we do it here is that scope stack entries save a pointer to
kono
parents:
diff changeset
356 -- the current local stack top, which is also saved and restored on scope
kono
parents:
diff changeset
357 -- exit. Furthermore for processing of generics we save pointers to the
kono
parents:
diff changeset
358 -- top of the stack, so that the local stack is actually a tree of stacks
kono
parents:
diff changeset
359 -- rather than a single stack, a structure that is easy to represent using
kono
parents:
diff changeset
360 -- linked lists, but impossible to represent using a single table. Note
kono
parents:
diff changeset
361 -- that because of the generic issue, we never release entries in these
kono
parents:
diff changeset
362 -- stacks, but that's no big deal, since we are unlikely to have a huge
kono
parents:
diff changeset
363 -- number of Suppress/Unsuppress entries in a single compilation.
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 type Suppress_Stack_Entry;
kono
parents:
diff changeset
366 type Suppress_Stack_Entry_Ptr is access all Suppress_Stack_Entry;
kono
parents:
diff changeset
367
kono
parents:
diff changeset
368 type Suppress_Stack_Entry is record
kono
parents:
diff changeset
369 Entity : Entity_Id;
kono
parents:
diff changeset
370 -- Entity to which the check applies, or Empty for a check that has
kono
parents:
diff changeset
371 -- no entity name (and thus applies to all entities).
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 Check : Check_Id;
kono
parents:
diff changeset
374 -- Check which is set (can be All_Checks for the All_Checks case)
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 Suppress : Boolean;
kono
parents:
diff changeset
377 -- Set True for Suppress, and False for Unsuppress
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 Prev : Suppress_Stack_Entry_Ptr;
kono
parents:
diff changeset
380 -- Pointer to previous entry on stack
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 Next : Suppress_Stack_Entry_Ptr;
kono
parents:
diff changeset
383 -- All allocated Suppress_Stack_Entry records are chained together in
kono
parents:
diff changeset
384 -- a linked list whose head is Suppress_Stack_Entries, and the Next
kono
parents:
diff changeset
385 -- field is used as a forward pointer (null ends the list). This is
kono
parents:
diff changeset
386 -- used to free all entries in Sem.Init (which will be important if
kono
parents:
diff changeset
387 -- we ever setup the compiler to be reused).
kono
parents:
diff changeset
388 end record;
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 Suppress_Stack_Entries : Suppress_Stack_Entry_Ptr := null;
kono
parents:
diff changeset
391 -- Pointer to linked list of records (see comments for Next above)
kono
parents:
diff changeset
392
kono
parents:
diff changeset
393 Local_Suppress_Stack_Top : Suppress_Stack_Entry_Ptr;
kono
parents:
diff changeset
394 -- Pointer to top element of local suppress stack. This is the entry that
kono
parents:
diff changeset
395 -- is saved and restored in the scope stack, and also saved for generic
kono
parents:
diff changeset
396 -- body expansion.
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 Global_Suppress_Stack_Top : Suppress_Stack_Entry_Ptr;
kono
parents:
diff changeset
399 -- Pointer to top element of global suppress stack
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 procedure Push_Local_Suppress_Stack_Entry
kono
parents:
diff changeset
402 (Entity : Entity_Id;
kono
parents:
diff changeset
403 Check : Check_Id;
kono
parents:
diff changeset
404 Suppress : Boolean);
kono
parents:
diff changeset
405 -- Push a new entry on to the top of the local suppress stack, updating
kono
parents:
diff changeset
406 -- the value in Local_Suppress_Stack_Top;
kono
parents:
diff changeset
407
kono
parents:
diff changeset
408 procedure Push_Global_Suppress_Stack_Entry
kono
parents:
diff changeset
409 (Entity : Entity_Id;
kono
parents:
diff changeset
410 Check : Check_Id;
kono
parents:
diff changeset
411 Suppress : Boolean);
kono
parents:
diff changeset
412 -- Push a new entry on to the top of the global suppress stack, updating
kono
parents:
diff changeset
413 -- the value in Global_Suppress_Stack_Top;
kono
parents:
diff changeset
414
kono
parents:
diff changeset
415 -----------------
kono
parents:
diff changeset
416 -- Scope Stack --
kono
parents:
diff changeset
417 -----------------
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419 -- The scope stack indicates the declarative regions that are currently
kono
parents:
diff changeset
420 -- being processed (analyzed and/or expanded). The scope stack is one of
kono
parents:
diff changeset
421 -- the basic visibility structures in the compiler: entities that are
kono
parents:
diff changeset
422 -- declared in a scope that is currently on the scope stack are immediately
kono
parents:
diff changeset
423 -- visible (leaving aside issues of hiding and overloading).
kono
parents:
diff changeset
424
kono
parents:
diff changeset
425 -- Initially, the scope stack only contains an entry for package Standard.
kono
parents:
diff changeset
426 -- When a compilation unit, subprogram unit, block or declarative region
kono
parents:
diff changeset
427 -- is being processed, the corresponding entity is pushed on the scope
kono
parents:
diff changeset
428 -- stack. It is removed after the processing step is completed. A given
kono
parents:
diff changeset
429 -- entity can be placed several times on the scope stack, for example
kono
parents:
diff changeset
430 -- when processing derived type declarations, freeze nodes, etc. The top
kono
parents:
diff changeset
431 -- of the scope stack is the innermost scope currently being processed.
kono
parents:
diff changeset
432 -- It is obtained through function Current_Scope. After a compilation unit
kono
parents:
diff changeset
433 -- has been processed, the scope stack must contain only Standard.
kono
parents:
diff changeset
434 -- The predicate In_Open_Scopes specifies whether a scope is currently
kono
parents:
diff changeset
435 -- on the scope stack.
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 -- This model is complicated by the need to compile units on the fly, in
kono
parents:
diff changeset
438 -- the middle of the compilation of other units. This arises when compiling
kono
parents:
diff changeset
439 -- instantiations, and when compiling run-time packages obtained through
kono
parents:
diff changeset
440 -- rtsfind. Given that the scope stack is a single static and global
kono
parents:
diff changeset
441 -- structure (not originally designed for the recursive processing required
kono
parents:
diff changeset
442 -- by rtsfind for example) additional machinery is needed to indicate what
kono
parents:
diff changeset
443 -- is currently being compiled. As a result, the scope stack holds several
kono
parents:
diff changeset
444 -- contiguous sections that correspond to the compilation of a given
kono
parents:
diff changeset
445 -- compilation unit. These sections are separated by distinct occurrences
kono
parents:
diff changeset
446 -- of package Standard. The currently active section of the scope stack
kono
parents:
diff changeset
447 -- goes from the current scope to the first (innermost) occurrence of
kono
parents:
diff changeset
448 -- Standard, which is additionally marked with flag Is_Active_Stack_Base.
kono
parents:
diff changeset
449 -- The basic visibility routine (Find_Direct_Name, in Sem_Ch8) uses this
kono
parents:
diff changeset
450 -- contiguous section of the scope stack to determine whether a given
kono
parents:
diff changeset
451 -- entity is or is not visible at a point. In_Open_Scopes only examines
kono
parents:
diff changeset
452 -- the currently active section of the scope stack.
kono
parents:
diff changeset
453
kono
parents:
diff changeset
454 -- Similar complications arise when processing child instances. These
kono
parents:
diff changeset
455 -- must be compiled in the context of parent instances, and therefore the
kono
parents:
diff changeset
456 -- parents must be pushed on the stack before compiling the child, and
kono
parents:
diff changeset
457 -- removed afterwards. Routines Save_Scope_Stack and Restore_Scope_Stack
kono
parents:
diff changeset
458 -- are used to set/reset the visibility of entities declared in scopes
kono
parents:
diff changeset
459 -- that are currently on the scope stack, and are used when compiling
kono
parents:
diff changeset
460 -- instance bodies on the fly.
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462 -- It is clear in retrospect that all semantic processing and visibility
kono
parents:
diff changeset
463 -- structures should have been fully recursive. The rtsfind mechanism,
kono
parents:
diff changeset
464 -- and the complexities brought about by subunits and by generic child
kono
parents:
diff changeset
465 -- units and their instantiations, have led to a hybrid model that carries
kono
parents:
diff changeset
466 -- more state than one would wish.
kono
parents:
diff changeset
467
kono
parents:
diff changeset
468 type Scope_Action_Kind is (Before, After, Cleanup);
kono
parents:
diff changeset
469 type Scope_Actions is array (Scope_Action_Kind) of List_Id;
kono
parents:
diff changeset
470 -- Transient blocks have three associated actions list, to be inserted
kono
parents:
diff changeset
471 -- before and after the block's statements, and as cleanup actions.
kono
parents:
diff changeset
472
kono
parents:
diff changeset
473 Configuration_Component_Alignment : Component_Alignment_Kind :=
kono
parents:
diff changeset
474 Calign_Default;
kono
parents:
diff changeset
475 -- Used for handling the pragma Component_Alignment in the context of a
kono
parents:
diff changeset
476 -- configuration file.
kono
parents:
diff changeset
477
kono
parents:
diff changeset
478 type Scope_Stack_Entry is record
kono
parents:
diff changeset
479 Entity : Entity_Id;
kono
parents:
diff changeset
480 -- Entity representing the scope
kono
parents:
diff changeset
481
kono
parents:
diff changeset
482 Last_Subprogram_Name : String_Ptr;
kono
parents:
diff changeset
483 -- Pointer to name of last subprogram body in this scope. Used for
kono
parents:
diff changeset
484 -- testing proper alpha ordering of subprogram bodies in scope.
kono
parents:
diff changeset
485
kono
parents:
diff changeset
486 Save_Scope_Suppress : Suppress_Record;
kono
parents:
diff changeset
487 -- Save contents of Scope_Suppress on entry
kono
parents:
diff changeset
488
kono
parents:
diff changeset
489 Save_Local_Suppress_Stack_Top : Suppress_Stack_Entry_Ptr;
kono
parents:
diff changeset
490 -- Save contents of Local_Suppress_Stack on entry to restore on exit
kono
parents:
diff changeset
491
kono
parents:
diff changeset
492 Save_Check_Policy_List : Node_Id;
kono
parents:
diff changeset
493 -- Save contents of Check_Policy_List on entry to restore on exit. The
kono
parents:
diff changeset
494 -- Check_Policy pragmas are chained with Check_Policy_List pointing to
kono
parents:
diff changeset
495 -- the most recent entry. This list is searched starting here, so that
kono
parents:
diff changeset
496 -- the search finds the most recent appicable entry. When we restore
kono
parents:
diff changeset
497 -- Check_Policy_List on exit from the scope, the effect is to remove
kono
parents:
diff changeset
498 -- all entries set in the scope being exited.
kono
parents:
diff changeset
499
kono
parents:
diff changeset
500 Save_Default_Storage_Pool : Node_Id;
kono
parents:
diff changeset
501 -- Save contents of Default_Storage_Pool on entry to restore on exit
kono
parents:
diff changeset
502
kono
parents:
diff changeset
503 Save_SPARK_Mode : SPARK_Mode_Type;
kono
parents:
diff changeset
504 -- Setting of SPARK_Mode on entry to restore on exit
kono
parents:
diff changeset
505
kono
parents:
diff changeset
506 Save_SPARK_Mode_Pragma : Node_Id;
kono
parents:
diff changeset
507 -- Setting of SPARK_Mode_Pragma on entry to restore on exit
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509 Save_No_Tagged_Streams : Node_Id;
kono
parents:
diff changeset
510 -- Setting of No_Tagged_Streams to restore on exit
kono
parents:
diff changeset
511
kono
parents:
diff changeset
512 Save_Default_SSO : Character;
kono
parents:
diff changeset
513 -- Setting of Default_SSO on entry to restore on exit
kono
parents:
diff changeset
514
kono
parents:
diff changeset
515 Save_Uneval_Old : Character;
kono
parents:
diff changeset
516 -- Setting of Uneval_Old on entry to restore on exit
kono
parents:
diff changeset
517
kono
parents:
diff changeset
518 Is_Transient : Boolean;
kono
parents:
diff changeset
519 -- Marks transient scopes (see Exp_Ch7 body for details)
kono
parents:
diff changeset
520
kono
parents:
diff changeset
521 Previous_Visibility : Boolean;
kono
parents:
diff changeset
522 -- Used when installing the parent(s) of the current compilation unit.
kono
parents:
diff changeset
523 -- The parent may already be visible because of an ongoing compilation,
kono
parents:
diff changeset
524 -- and the proper visibility must be restored on exit. The flag is
kono
parents:
diff changeset
525 -- typically needed when the context of a child unit requires
kono
parents:
diff changeset
526 -- compilation of a sibling. In other cases the flag is set to False.
kono
parents:
diff changeset
527 -- See Sem_Ch10 (Install_Parents, Remove_Parents).
kono
parents:
diff changeset
528
kono
parents:
diff changeset
529 Node_To_Be_Wrapped : Node_Id;
kono
parents:
diff changeset
530 -- Only used in transient scopes. Records the node which will be wrapped
kono
parents:
diff changeset
531 -- by the transient block.
kono
parents:
diff changeset
532
kono
parents:
diff changeset
533 Actions_To_Be_Wrapped : Scope_Actions;
kono
parents:
diff changeset
534 -- Actions that have to be inserted at the start, at the end, or as
kono
parents:
diff changeset
535 -- cleanup actions of a transient block. Used to temporarily hold these
kono
parents:
diff changeset
536 -- actions until the block is created, at which time the actions are
kono
parents:
diff changeset
537 -- moved to the block.
kono
parents:
diff changeset
538
kono
parents:
diff changeset
539 Pending_Freeze_Actions : List_Id;
kono
parents:
diff changeset
540 -- Used to collect freeze entity nodes and associated actions that are
kono
parents:
diff changeset
541 -- generated in an inner context but need to be analyzed outside, such
kono
parents:
diff changeset
542 -- as records and initialization procedures. On exit from the scope,
kono
parents:
diff changeset
543 -- this list of actions is inserted before the scope construct and
kono
parents:
diff changeset
544 -- analyzed to generate the corresponding freeze processing and
kono
parents:
diff changeset
545 -- elaboration of other associated actions.
kono
parents:
diff changeset
546
kono
parents:
diff changeset
547 First_Use_Clause : Node_Id;
kono
parents:
diff changeset
548 -- Head of list of Use_Clauses in current scope. The list is built when
kono
parents:
diff changeset
549 -- the declarations in the scope are processed. The list is traversed
kono
parents:
diff changeset
550 -- on scope exit to undo the effect of the use clauses.
kono
parents:
diff changeset
551
kono
parents:
diff changeset
552 Component_Alignment_Default : Component_Alignment_Kind;
kono
parents:
diff changeset
553 -- Component alignment to be applied to any record or array types that
kono
parents:
diff changeset
554 -- are declared for which a specific component alignment pragma does not
kono
parents:
diff changeset
555 -- set the alignment.
kono
parents:
diff changeset
556
kono
parents:
diff changeset
557 Is_Active_Stack_Base : Boolean;
kono
parents:
diff changeset
558 -- Set to true only when entering the scope for Standard_Standard from
kono
parents:
diff changeset
559 -- from within procedure Semantics. Indicates the base of the current
kono
parents:
diff changeset
560 -- active set of scopes. Needed by In_Open_Scopes to handle cases where
kono
parents:
diff changeset
561 -- Standard_Standard can be pushed anew on the scope stack to start a
kono
parents:
diff changeset
562 -- new active section (see comment above).
kono
parents:
diff changeset
563
kono
parents:
diff changeset
564 Locked_Shared_Objects : Elist_Id;
kono
parents:
diff changeset
565 -- List of shared passive protected objects that have been locked in
kono
parents:
diff changeset
566 -- this transient scope (always No_Elist for non-transient scopes).
kono
parents:
diff changeset
567 end record;
kono
parents:
diff changeset
568
kono
parents:
diff changeset
569 package Scope_Stack is new Table.Table (
kono
parents:
diff changeset
570 Table_Component_Type => Scope_Stack_Entry,
kono
parents:
diff changeset
571 Table_Index_Type => Int,
kono
parents:
diff changeset
572 Table_Low_Bound => 0,
kono
parents:
diff changeset
573 Table_Initial => Alloc.Scope_Stack_Initial,
kono
parents:
diff changeset
574 Table_Increment => Alloc.Scope_Stack_Increment,
kono
parents:
diff changeset
575 Table_Name => "Sem.Scope_Stack");
kono
parents:
diff changeset
576
kono
parents:
diff changeset
577 -----------------
kono
parents:
diff changeset
578 -- Subprograms --
kono
parents:
diff changeset
579 -----------------
kono
parents:
diff changeset
580
kono
parents:
diff changeset
581 procedure Initialize;
kono
parents:
diff changeset
582 -- Initialize internal tables
kono
parents:
diff changeset
583
kono
parents:
diff changeset
584 procedure Lock;
kono
parents:
diff changeset
585 -- Lock internal tables before calling back end
kono
parents:
diff changeset
586
kono
parents:
diff changeset
587 procedure Unlock;
kono
parents:
diff changeset
588 -- Unlock internal tables
kono
parents:
diff changeset
589
kono
parents:
diff changeset
590 procedure Semantics (Comp_Unit : Node_Id);
kono
parents:
diff changeset
591 -- This procedure is called to perform semantic analysis on the specified
kono
parents:
diff changeset
592 -- node which is the N_Compilation_Unit node for the unit.
kono
parents:
diff changeset
593
kono
parents:
diff changeset
594 procedure Analyze (N : Node_Id);
kono
parents:
diff changeset
595 procedure Analyze (N : Node_Id; Suppress : Check_Id);
kono
parents:
diff changeset
596 -- This is the recursive procedure that is applied to individual nodes of
kono
parents:
diff changeset
597 -- the tree, starting at the top level node (compilation unit node) and
kono
parents:
diff changeset
598 -- then moving down the tree in a top down traversal. It calls individual
kono
parents:
diff changeset
599 -- routines with names Analyze_xxx to analyze node xxx. Each of these
kono
parents:
diff changeset
600 -- routines is responsible for calling Analyze on the components of the
kono
parents:
diff changeset
601 -- subtree.
kono
parents:
diff changeset
602 --
kono
parents:
diff changeset
603 -- Note: In the case of expression components (nodes whose Nkind is in
kono
parents:
diff changeset
604 -- N_Subexpr), the call to Analyze does not complete the semantic analysis
kono
parents:
diff changeset
605 -- of the node, since the type resolution cannot be completed until the
kono
parents:
diff changeset
606 -- complete context is analyzed. The completion of the type analysis occurs
kono
parents:
diff changeset
607 -- in the corresponding Resolve routine (see Sem_Res).
kono
parents:
diff changeset
608 --
kono
parents:
diff changeset
609 -- Note: for integer and real literals, the analyzer sets the flag to
kono
parents:
diff changeset
610 -- indicate that the result is a static expression. If the expander
kono
parents:
diff changeset
611 -- generates a literal that does NOT correspond to a static expression,
kono
parents:
diff changeset
612 -- e.g. by folding an expression whose value is known at compile time,
kono
parents:
diff changeset
613 -- but is not technically static, then the caller should reset the
kono
parents:
diff changeset
614 -- Is_Static_Expression flag after analyzing but before resolving.
kono
parents:
diff changeset
615 --
kono
parents:
diff changeset
616 -- If the Suppress argument is present, then the analysis is done
kono
parents:
diff changeset
617 -- with the specified check suppressed (can be All_Checks to suppress
kono
parents:
diff changeset
618 -- all checks).
kono
parents:
diff changeset
619
kono
parents:
diff changeset
620 procedure Analyze_List (L : List_Id);
kono
parents:
diff changeset
621 procedure Analyze_List (L : List_Id; Suppress : Check_Id);
kono
parents:
diff changeset
622 -- Analyzes each element of a list. If the Suppress argument is present,
kono
parents:
diff changeset
623 -- then the analysis is done with the specified check suppressed (can
kono
parents:
diff changeset
624 -- be All_Checks to suppress all checks).
kono
parents:
diff changeset
625
kono
parents:
diff changeset
626 procedure Copy_Suppress_Status
kono
parents:
diff changeset
627 (C : Check_Id;
kono
parents:
diff changeset
628 From : Entity_Id;
kono
parents:
diff changeset
629 To : Entity_Id);
kono
parents:
diff changeset
630 -- If From is an entity for which check C is explicitly suppressed
kono
parents:
diff changeset
631 -- then also explicitly suppress the corresponding check in To.
kono
parents:
diff changeset
632
kono
parents:
diff changeset
633 procedure Insert_List_After_And_Analyze
kono
parents:
diff changeset
634 (N : Node_Id; L : List_Id);
kono
parents:
diff changeset
635 -- Inserts list L after node N using Nlists.Insert_List_After, and then,
kono
parents:
diff changeset
636 -- after this insertion is complete, analyzes all the nodes in the list,
kono
parents:
diff changeset
637 -- including any additional nodes generated by this analysis. If the list
kono
parents:
diff changeset
638 -- is empty or No_List, the call has no effect.
kono
parents:
diff changeset
639
kono
parents:
diff changeset
640 procedure Insert_List_Before_And_Analyze
kono
parents:
diff changeset
641 (N : Node_Id; L : List_Id);
kono
parents:
diff changeset
642 -- Inserts list L before node N using Nlists.Insert_List_Before, and then,
kono
parents:
diff changeset
643 -- after this insertion is complete, analyzes all the nodes in the list,
kono
parents:
diff changeset
644 -- including any additional nodes generated by this analysis. If the list
kono
parents:
diff changeset
645 -- is empty or No_List, the call has no effect.
kono
parents:
diff changeset
646
kono
parents:
diff changeset
647 procedure Insert_After_And_Analyze
kono
parents:
diff changeset
648 (N : Node_Id; M : Node_Id);
kono
parents:
diff changeset
649 procedure Insert_After_And_Analyze
kono
parents:
diff changeset
650 (N : Node_Id; M : Node_Id; Suppress : Check_Id);
kono
parents:
diff changeset
651 -- Inserts node M after node N and then after the insertion is complete,
kono
parents:
diff changeset
652 -- analyzes the inserted node and all nodes that are generated by
kono
parents:
diff changeset
653 -- this analysis. If the node is empty, the call has no effect. If the
kono
parents:
diff changeset
654 -- Suppress argument is present, then the analysis is done with the
kono
parents:
diff changeset
655 -- specified check suppressed (can be All_Checks to suppress all checks).
kono
parents:
diff changeset
656
kono
parents:
diff changeset
657 procedure Insert_Before_And_Analyze
kono
parents:
diff changeset
658 (N : Node_Id; M : Node_Id);
kono
parents:
diff changeset
659 procedure Insert_Before_And_Analyze
kono
parents:
diff changeset
660 (N : Node_Id; M : Node_Id; Suppress : Check_Id);
kono
parents:
diff changeset
661 -- Inserts node M before node N and then after the insertion is complete,
kono
parents:
diff changeset
662 -- analyzes the inserted node and all nodes that could be generated by
kono
parents:
diff changeset
663 -- this analysis. If the node is empty, the call has no effect. If the
kono
parents:
diff changeset
664 -- Suppress argument is present, then the analysis is done with the
kono
parents:
diff changeset
665 -- specified check suppressed (can be All_Checks to suppress all checks).
kono
parents:
diff changeset
666
kono
parents:
diff changeset
667 function External_Ref_In_Generic (E : Entity_Id) return Boolean;
kono
parents:
diff changeset
668 -- Return True if we are in the context of a generic and E is
kono
parents:
diff changeset
669 -- external (more global) to it.
kono
parents:
diff changeset
670
kono
parents:
diff changeset
671 procedure Enter_Generic_Scope (S : Entity_Id);
kono
parents:
diff changeset
672 -- Called each time a Generic subprogram or package scope is entered. S is
kono
parents:
diff changeset
673 -- the entity of the scope.
kono
parents:
diff changeset
674 --
kono
parents:
diff changeset
675 -- ??? At the moment, only called for package specs because this mechanism
kono
parents:
diff changeset
676 -- is only used for avoiding freezing of external references in generics
kono
parents:
diff changeset
677 -- and this can only be an issue if the outer generic scope is a package
kono
parents:
diff changeset
678 -- spec (otherwise all external entities are already frozen)
kono
parents:
diff changeset
679
kono
parents:
diff changeset
680 procedure Exit_Generic_Scope (S : Entity_Id);
kono
parents:
diff changeset
681 -- Called each time a Generic subprogram or package scope is exited. S is
kono
parents:
diff changeset
682 -- the entity of the scope.
kono
parents:
diff changeset
683 --
kono
parents:
diff changeset
684 -- ??? At the moment, only called for package specs exit.
kono
parents:
diff changeset
685
kono
parents:
diff changeset
686 function Explicit_Suppress (E : Entity_Id; C : Check_Id) return Boolean;
kono
parents:
diff changeset
687 -- This function returns True if an explicit pragma Suppress for check C
kono
parents:
diff changeset
688 -- is present in the package defining E.
kono
parents:
diff changeset
689
kono
parents:
diff changeset
690 function Preanalysis_Active return Boolean;
kono
parents:
diff changeset
691 pragma Inline (Preanalysis_Active);
kono
parents:
diff changeset
692 -- Determine whether preanalysis is active at the point of invocation
kono
parents:
diff changeset
693
kono
parents:
diff changeset
694 procedure Preanalyze (N : Node_Id);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
695 -- Performs a preanalysis of node N. During preanalysis no expansion is
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
696 -- carried out for N or its children. See above for more info on
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
697 -- preanalysis.
111
kono
parents:
diff changeset
698
kono
parents:
diff changeset
699 generic
kono
parents:
diff changeset
700 with procedure Action (Item : Node_Id);
kono
parents:
diff changeset
701 procedure Walk_Library_Items;
kono
parents:
diff changeset
702 -- Primarily for use by CodePeer and GNATprove. Must be called after
kono
parents:
diff changeset
703 -- semantic analysis (and expansion in the case of CodePeer) are complete.
kono
parents:
diff changeset
704 -- Walks each relevant library item, calling Action for each, in an order
kono
parents:
diff changeset
705 -- such that one will not run across forward references. Each Item passed
kono
parents:
diff changeset
706 -- to Action is the declaration or body of a library unit, including
kono
parents:
diff changeset
707 -- generics and renamings. The first item is the N_Package_Declaration node
kono
parents:
diff changeset
708 -- for package Standard. Bodies are not included, except for the main unit
kono
parents:
diff changeset
709 -- itself, which always comes last.
kono
parents:
diff changeset
710 --
kono
parents:
diff changeset
711 -- Item is never a subunit
kono
parents:
diff changeset
712 --
kono
parents:
diff changeset
713 -- Item is never an instantiation. Instead, the instance declaration is
kono
parents:
diff changeset
714 -- passed, and (if the instantiation is the main unit), the instance body.
kono
parents:
diff changeset
715
kono
parents:
diff changeset
716 ------------------------
kono
parents:
diff changeset
717 -- Debugging Routines --
kono
parents:
diff changeset
718 ------------------------
kono
parents:
diff changeset
719
kono
parents:
diff changeset
720 function ss (Index : Int) return Scope_Stack_Entry;
kono
parents:
diff changeset
721 pragma Export (Ada, ss);
kono
parents:
diff changeset
722 -- "ss" = "scope stack"; returns the Index'th entry in the Scope_Stack
kono
parents:
diff changeset
723
kono
parents:
diff changeset
724 function sst return Scope_Stack_Entry;
kono
parents:
diff changeset
725 pragma Export (Ada, sst);
kono
parents:
diff changeset
726 -- "sst" = "scope stack top"; same as ss(Scope_Stack.Last)
kono
parents:
diff changeset
727
kono
parents:
diff changeset
728 end Sem;