OSDN Git Service

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