1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT COMPILER COMPONENTS                         --
4--                                                                          --
5--                             E X P _ U T I L                              --
6--                                                                          --
7--                                 S p e c                                  --
8--                                                                          --
9--          Copyright (C) 1992-2003 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 2,  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 COPYING.  If not, write --
19-- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
20-- MA 02111-1307, USA.                                                      --
21--                                                                          --
22-- GNAT was originally developed  by the GNAT team at  New York University. --
23-- Extensive contributions were provided by Ada Core Technologies Inc.      --
24--                                                                          --
25------------------------------------------------------------------------------
26
27--  Package containing utility procedures used throughout the expander
28
29with Exp_Tss; use Exp_Tss;
30with Rtsfind; use Rtsfind;
31with Sinfo;   use Sinfo;
32with Types;   use Types;
33
34package Exp_Util is
35
36   -----------------------------------------------
37   -- Handling of Actions Associated with Nodes --
38   -----------------------------------------------
39
40   --  The evaluation of certain expression nodes involves the elaboration
41   --  of associated types and other declarations, and the execution of
42   --  statement sequences. Expansion routines generating such actions must
43   --  find an appropriate place in the tree to hang the actions so that
44   --  they will be evaluated at the appropriate point.
45
46   --  Some cases are simple:
47
48   --    For an expression occurring in a simple statement that is in a list
49   --    of statements, the actions are simply inserted into the list before
50   --    the associated statement.
51
52   --    For an expression occurring in a declaration (declarations always
53   --    appear in lists), the actions are similarly inserted into the list
54   --    just before the associated declaration.
55
56   --  The following special cases arise:
57
58   --    For actions associated with the right operand of a short circuit
59   --    form, the actions are first stored in the short circuit form node
60   --    in the Actions field. The expansion of these forms subsequently
61   --    expands the short circuit forms into if statements which can then
62   --    be moved as described above.
63
64   --    For actions appearing in the Condition expression of a while loop,
65   --    or an elsif clause, the actions are similarly temporarily stored in
66   --    in the node (N_Elsif_Part or N_Iteration_Scheme) associated with
67   --    the expression using the Condition_Actions field. Subsequently, the
68   --    expansion of these nodes rewrites the control structures involved to
69   --    reposition the actions in normal statement sequence.
70
71   --    For actions appearing in the then or else expression of a conditional
72   --    expression, these actions are similarly placed in the node, using the
73   --    Then_Actions or Else_Actions field as appropriate. Once again the
74   --    expansion of the N_Conditional_Expression node rewrites the node so
75   --    that the actions can be normally positioned.
76
77   --  Basically what we do is to climb up to the tree looking for the
78   --  proper insertion point, as described by one of the above cases,
79   --  and then insert the appropriate action or actions.
80
81   --  Note if more than one insert call is made specifying the same
82   --  Assoc_Node, then the actions are elaborated in the order of the
83   --  calls, and this guarantee is preserved for the special cases above.
84
85   procedure Insert_Action
86     (Assoc_Node : Node_Id;
87      Ins_Action : Node_Id);
88   --  Insert the action Ins_Action at the appropriate point as described
89   --  above. The action is analyzed using the default checks after it is
90   --  inserted. Assoc_Node is the node with which the action is associated.
91
92   procedure Insert_Action
93     (Assoc_Node : Node_Id;
94      Ins_Action : Node_Id;
95      Suppress   : Check_Id);
96   --  Insert the action Ins_Action at the appropriate point as described
97   --  above. The action is analyzed using the default checks as modified
98   --  by the given Suppress argument after it is inserted. Assoc_Node is
99   --  the node with which the action is associated.
100
101   procedure Insert_Actions
102     (Assoc_Node  : Node_Id;
103      Ins_Actions : List_Id);
104   --  Insert the list of action Ins_Actions at the appropriate point as
105   --  described above. The actions are analyzed using the default checks
106   --  after they are inserted. Assoc_Node is the node with which the actions
107   --  are associated. Ins_Actions may be No_List, in which case the call has
108   --  no effect.
109
110   procedure Insert_Actions
111     (Assoc_Node  : Node_Id;
112      Ins_Actions : List_Id;
113      Suppress    : Check_Id);
114   --  Insert the list of action Ins_Actions at the appropriate point as
115   --  described above. The actions are analyzed using the default checks
116   --  as modified by the given Suppress argument after they are inserted.
117   --  Assoc_Node is the node with which the actions are associated.
118   --  Ins_Actions may be No_List, in which case the call has no effect.
119
120   procedure Insert_Actions_After
121     (Assoc_Node  : Node_Id;
122      Ins_Actions : List_Id);
123   --  Assoc_Node must be a node in a list. Same as Insert_Actions but
124   --  actions will be inserted after N in a manner that is compatible with
125   --  the transient scope mechanism. This procedure must be used instead
126   --  of Insert_List_After if Assoc_Node may be in a transient scope.
127   --
128   --  Implementation limitation: Assoc_Node must be a statement. We can
129   --  generalize to expressions if there is a need but this is tricky to
130   --  implement because of short-ciruits (among other things).???
131
132   procedure Insert_Library_Level_Action (N : Node_Id);
133   --  This procedure inserts and analyzes the node N as an action at the
134   --  library level for the current unit (i.e. it is attached to the
135   --  Actions field of the N_Compilation_Aux node for the main unit).
136
137   procedure Insert_Library_Level_Actions (L : List_Id);
138   --  Similar, but inserts a list of actions.
139
140   -----------------------
141   -- Other Subprograms --
142   -----------------------
143
144   procedure Adjust_Condition (N : Node_Id);
145   --  The node N is an expression whose root-type is Boolean, and which
146   --  represents a boolean value used as a condition (i.e. a True/False
147   --  value). This routine handles the case of C and Fortran convention
148   --  boolean types, which have zero/non-zero semantics rather than the
149   --  normal 0/1 semantics, and also the case of an enumeration rep
150   --  clause that specifies a non-standard representation. On return,
151   --  node N always has the type Standard.Boolean, with a value that
152   --  is a standard Boolean values of 0/1 for False/True. This procedure
153   --  is used in two situations. First, the processing for a condition
154   --  field always calls Adjust_Condition, so that the boolean value
155   --  presented to the backend is a standard value. Second, for the
156   --  code for boolean operations such as AND, Adjust_Condition is
157   --  called on both operands, and then the operation is done in the
158   --  domain of Standard_Boolean, then Adjust_Result_Type is called
159   --  on the result to possibly reset the original type. This procedure
160   --  also takes care of validity checking if Validity_Checks = Tests.
161
162   procedure Adjust_Result_Type (N : Node_Id; T : Entity_Id);
163   --  The processing of boolean operations like AND uses the procedure
164   --  Adjust_Condition so that it can operate on Standard.Boolean, which
165   --  is the only boolean type on which the backend needs to be able to
166   --  implement such operators. This means that the result is also of
167   --  type Standard.Boolean. In general the type must be reset back to
168   --  the original type to get proper semantics, and that is the purpose
169   --  of this procedure. N is the node (of type Standard.Boolean), and
170   --  T is the desired type. As an optimization, this procedure leaves
171   --  the type as Standard.Boolean in contexts where this is permissible
172   --  (in particular for Condition fields, and for operands of other
173   --  logical operations higher up the tree). The call to this procedure
174   --  is completely ignored if the argument N is not of type Boolean.
175
176   procedure Append_Freeze_Action (T : Entity_Id; N : Node_Id);
177   --  Add a new freeze action for the given type. The freeze action is
178   --  attached to the freeze node for the type. Actions will be elaborated
179   --  in the order in which they are added. Note that the added node is not
180   --  analyzed. The analyze call is found in Sem_Ch13.Expand_N_Freeze_Entity.
181
182   procedure Append_Freeze_Actions (T : Entity_Id; L : List_Id);
183   --  Adds the given list of freeze actions (declarations or statements)
184   --  for the given type. The freeze actions are attached to the freeze
185   --  node for the type. Actions will be elaborated in the order in which
186   --  they are added, and the actions within the list will be elaborated in
187   --  list order. Note that the added nodes are not analyzed. The analyze
188   --  call is found in Sem_Ch13.Expand_N_Freeze_Entity.
189
190   function Build_Runtime_Call (Loc : Source_Ptr; RE : RE_Id) return Node_Id;
191   --  Build an N_Procedure_Call_Statement calling the given runtime entity.
192   --  The call has no parameters. The first argument provides the location
193   --  information for the tree and for error messages. The call node is not
194   --  analyzed on return, the caller is responsible for analyzing it.
195
196   function Build_Task_Image_Decls
197     (Loc    : Source_Ptr;
198      Id_Ref : Node_Id;
199      A_Type : Entity_Id)
200      return   List_Id;
201   --  Build declaration for a variable that holds an identifying string
202   --  to be used as a task name. Id_Ref is an identifier if the task is
203   --  a variable, and a selected or indexed component if the task is a
204   --  component of an object. If it is an indexed component, A_Type is
205   --  the corresponding array type. Its index types are used to build the
206   --  string as an image of the index values. For composite types, the
207   --  result includes two declarations: one for a generated function that
208   --  computes the image without using concatenation, and one for the
209   --  variable that holds the result.
210
211   function Component_May_Be_Bit_Aligned (Comp : Entity_Id) return Boolean;
212   --  This function is in charge of detecting record components that may
213   --  cause trouble in the back end if an attempt is made to assign the
214   --  component. The back end can handle such assignments with no problem
215   --  if the components involved are small (64-bits or less) records or
216   --  scalar items (including bit-packed arrays represented with modular
217   --  types) or are both aligned on a byte boundary (starting on a byte
218   --  boundary, and occupying an integral number of bytes).
219   --
220   --  However, problems arise for records larger than 64 bits, or for
221   --  arrays (other than bit-packed arrays represented with a modular
222   --  type) if the component starts on a non-byte boundary, or does
223   --  not occupy an integral number of bytes (i.e. there are some bits
224   --  possibly shared with fields at the start or beginning of the
225   --  component). The back end cannot handle loading and storing such
226   --  components in a single operation.
227   --
228   --  This function is used to detect the troublesome situation. it is
229   --  conservative in the sense that it produces True unless it knows
230   --  for sure that the component is safe (as outlined in the first
231   --  paragraph above). The code generation for record and array
232   --  assignment checks for trouble using this function, and if so
233   --  the assignment is generated component-wise, which the back end
234   --  is required to handle correctly.
235   --
236   --  Note that in GNAT 3, the back end will reject such components
237   --  anyway, so the hard work in checking for this case is wasted
238   --  in GNAT 3, but it's harmless, so it is easier to do it in
239   --  all cases, rather than conditionalize it in GNAT 5 or beyond.
240
241   procedure Convert_To_Actual_Subtype (Exp : Node_Id);
242   --  The Etype of an expression is the nominal type of the expression,
243   --  not the actual subtype. Often these are the same, but not always.
244   --  For example, a reference to a formal of unconstrained type has the
245   --  unconstrained type as its Etype, but the actual subtype is obtained
246   --  by applying the actual bounds. This routine is given an expression,
247   --  Exp, and (if necessary), replaces it using Rewrite, with a conversion
248   --  to the actual subtype, building the actual subtype if necessary. If
249   --  the expression is already of the requested type, then it is unchanged.
250
251   function Current_Sem_Unit_Declarations return List_Id;
252   --  Return the a place where it is fine to insert declarations for the
253   --  current semantic unit. If the unit is a package body, return the
254   --  visible declarations of the corresponding spec. For RCI stubs, this
255   --  is necessary because the point at which they are generated may not
256   --  be the earliest point at which they are used.
257
258   function Duplicate_Subexpr
259     (Exp      : Node_Id;
260      Name_Req : Boolean := False)
261      return     Node_Id;
262   --  Given the node for a subexpression, this function makes a logical
263   --  copy of the subexpression, and returns it. This is intended for use
264   --  when the expansion of an expression needs to repeat part of it. For
265   --  example, replacing a**2 by a*a requires two references to a which
266   --  may be a complex subexpression. Duplicate_Subexpression guarantees
267   --  not to duplicate side effects. If necessary, it generates actions
268   --  to save the expression value in a temporary, inserting these actions
269   --  into the tree using Insert_Actions with Exp as the insertion location.
270   --  The original expression and the returned result then become references
271   --  to this saved value. Exp must be analyzed on entry. On return, Exp
272   --  is analyzed, but the caller is responsible for analyzing the returned
273   --  copy after it is attached to the tree. The Name_Req flag is set to
274   --  ensure that the result is suitable for use in a context requiring a
275   --  name (e.g. the prefix of an attribute reference).
276   --
277   --  Note that if there are any run time checks in Exp, these same checks
278   --  will be duplicated in the returned duplicated expression. The two
279   --  following functions allow this behavior to be modified.
280
281   function Duplicate_Subexpr_No_Checks
282     (Exp      : Node_Id;
283      Name_Req : Boolean := False)
284      return     Node_Id;
285   --  Identical in effect to Duplicate_Subexpr, except that Remove_Checks
286   --  is called on the result, so that the duplicated expression does not
287   --  include checks. This is appropriate for use when Exp, the original
288   --  expression is unconditionally elaborated before the duplicated
289   --  expression, so that there is no need to repeat any checks.
290
291   function Duplicate_Subexpr_Move_Checks
292     (Exp      : Node_Id;
293      Name_Req : Boolean := False)
294      return     Node_Id;
295   --  Identical in effect to Duplicate_Subexpr, except that Remove_Checks
296   --  is called on Exp after the duplication is complete, so that the
297   --  original expression does not include checks. In this case the result
298   --  returned (the duplicated expression) will retain the original checks.
299   --  This is appropriate for use when the duplicated expression is sure
300   --  to be elaborated before the original expression Exp, so that there
301   --  is no need to repeat the checks.
302
303   procedure Ensure_Defined (Typ : Entity_Id; N : Node_Id);
304   --  This procedure ensures that type referenced by Typ is defined. For the
305   --  case of a type other than an Itype, nothing needs to be done, since
306   --  all such types have declaration nodes. For Itypes, an N_Itype_Reference
307   --  node is generated and inserted at the given node N. This is typically
308   --  used to ensure that an Itype is properly defined outside a conditional
309   --  construct when it is referenced in more than one branch.
310
311   procedure Evolve_And_Then (Cond : in out Node_Id; Cond1 : Node_Id);
312   --  Rewrites Cond with the expression: Cond and then Cond1. If Cond is
313   --  Empty, then simply returns Cond1 (this allows the use of Empty to
314   --  initialize a series of checks evolved by this routine, with a final
315   --  result of Empty indicating that no checks were required). The Sloc
316   --  field of the constructed N_And_Then node is copied from Cond1.
317
318   procedure Evolve_Or_Else (Cond : in out Node_Id; Cond1 : Node_Id);
319   --  Rewrites Cond with the expression: Cond or else Cond1. If Cond is
320   --  Empty, then simply returns Cond1 (this allows the use of Empty to
321   --  initialize a series of checks evolved by this routine, with a final
322   --  result of Empty indicating that no checks were required). The Sloc
323   --  field of the constructed N_And_Then node is copied from Cond1.
324
325   procedure Expand_Subtype_From_Expr
326     (N             : Node_Id;
327      Unc_Type      : Entity_Id;
328      Subtype_Indic : Node_Id;
329      Exp           : Node_Id);
330   --  Build a constrained subtype from the initial value in object
331   --  declarations and/or allocations when the type is indefinite (including
332   --  class-wide).
333
334   function Find_Prim_Op (T : Entity_Id; Name : Name_Id) return Entity_Id;
335   --  Find the first primitive operation of type T whose name is 'Name'.
336   --  This function allows the use of a primitive operation which is not
337   --  directly visible. If T is a class wide type, then the reference is
338   --  to an operation of the corresponding root type.
339
340   function Find_Prim_Op
341     (T    : Entity_Id;
342      Name : TSS_Name_Type) return Entity_Id;
343   --  Find the first primitive operation of type T whose name has the form
344   --  indicated by the name parameter (i.e. is a type support subprogram
345   --  with the indicated suffix). This function allows use of a primitive
346   --  operation which is not directly visible. If T is a class wide type,
347   --  then the reference is to an operation of the corresponding root type.
348
349   procedure Force_Evaluation
350     (Exp      : Node_Id;
351      Name_Req : Boolean := False);
352   --  Force the evaluation of the expression right away. Similar behavior
353   --  to Remove_Side_Effects when Variable_Ref is set to TRUE. That is to
354   --  say, it removes the side-effects and capture the values of the
355   --  variables. Remove_Side_effects guarantees that multiple evaluations
356   --  of the same expression won't generate multiple side effects, whereas
357   --  Force_Evaluation further guarantees that all evaluations will yield
358   --  the same result.
359
360   procedure Generate_Poll_Call (N : Node_Id);
361   --  If polling is active, then a call to the Poll routine is built,
362   --  and then inserted before the given node N and analyzed.
363
364   procedure Get_Current_Value_Condition
365     (Var : Node_Id;
366      Op  : out Node_Kind;
367      Val : out Node_Id);
368   --  This routine processes the Current_Value field of the variable Var.
369   --  If the Current_Value field is null or if it represents a known value,
370   --  then on return Cond is set to N_Empty, and Val is set to Empty.
371   --
372   --  The other case is when Current_Value points to an N_If_Statement
373   --  or an N_Elsif_Part (while statement). Such a setting only occurs
374   --  if the condition of an IF or ELSIF is of the form X op Y, where X
375   --  is the variable in question, Y is a compile-time known value, and
376   --  op is one of the six possible relational operators.
377   --
378   --  In this case, Get_Current_Condition digs out the condition, and
379   --  then checks if the condition is known false, known true, or not
380   --  known at all. In the first two cases, Get_Current_Condition will
381   --  return with Op set to the appropriate conditional operator (inverted
382   --  if the condition is known false), and Val set to the constant value.
383   --  If the condition is not known, then Cond and Val are set for the
384   --  empty case (N_Empty and Empty).
385   --
386   --  The check for whether the condition is true/false unknown depends
387   --  on the case:
388   --
389   --     For an IF, the condition is known true in the THEN part, known
390   --     false in any ELSIF or ELSE part, and not known outside the IF
391   --     statement in question.
392   --
393   --     For an ELSIF, the condition is known true in the ELSIF part,
394   --     known FALSE in any subsequent ELSIF, or ELSE part, and not
395   --     known before the ELSIF, or after the end of the IF statement.
396   --
397   --  The caller can use this result to determine the value (for the
398   --  case of N_Op_Eq), or to determine the result of some other test
399   --  in other cases (e.g. no access check required if N_Op_Ne Null).
400
401   function Homonym_Number (Subp : Entity_Id) return Nat;
402   --  Here subp is the entity for a subprogram. This routine returns the
403   --  homonym number used to disambiguate overloaded subprograms in the
404   --  same scope (the number is used as part of constructed names to make
405   --  sure that they are unique). The number is the ordinal position on
406   --  the Homonym chain, counting only entries in the curren scope. If
407   --  an entity is not overloaded, the returned number will be one.
408
409   function Inside_Init_Proc return Boolean;
410   --  Returns True if current scope is within an init proc
411
412   function In_Unconditional_Context (Node : Node_Id) return Boolean;
413   --  Node is the node for a statement or a component of a statement.
414   --  This function deteermines if the statement appears in a context
415   --  that is unconditionally executed, i.e. it is not within a loop
416   --  or a conditional or a case statement etc.
417
418   function Is_All_Null_Statements (L : List_Id) return Boolean;
419   --  Return True if all the items of the list are N_Null_Statement
420   --  nodes. False otherwise. True for an empty list. It is an error
421   --  to call this routine with No_List as the argument.
422
423   function Is_Ref_To_Bit_Packed_Array (P : Node_Id) return Boolean;
424   --  Determine whether the node P is a reference to a bit packed
425   --  array, i.e. whether the designated object is a component of
426   --  a bit packed array, or a subcomponent of such a component.
427   --  If so, then all subscripts in P are evaluated with a call
428   --  to Force_Evaluation, and True is returned. Otherwise False
429   --  is returned, and P is not affected.
430
431   function Is_Ref_To_Bit_Packed_Slice (P : Node_Id) return Boolean;
432   --  Determine whether the node P is a reference to a bit packed
433   --  slice, i.e. whether the designated object is bit packed slice
434   --  or a component of a bit packed slice. Return True if so.
435
436   function Is_Possibly_Unaligned_Slice (P : Node_Id) return Boolean;
437   --  Determine whether the node P is a slice of an array where the slice
438   --  result may cause alignment problems because it has an alignment that
439   --  is not compatible with the type. Return True if so.
440
441   function Is_Possibly_Unaligned_Object (P : Node_Id) return Boolean;
442   --  Node P is an object reference. This function returns True if it
443   --  is possible that the object may not be aligned according to the
444   --  normal default alignment requirement for its type (e.g. if it
445   --  appears in a packed record, or as part of a component that has
446   --  a component clause.
447
448   function Is_Renamed_Object (N : Node_Id) return Boolean;
449   --  Returns True if the node N is a renamed object. An expression
450   --  is considered to be a renamed object if either it is the Name
451   --  of an object renaming declaration, or is the prefix of a name
452   --  which is a renamed object. For example, in:
453   --
454   --     x : r renames a (1 .. 2) (1);
455   --
456   --  We consider that a (1 .. 2) is a renamed object since it is the
457   --  prefix of the name in the renaming declaration.
458
459   function Is_Untagged_Derivation (T : Entity_Id) return Boolean;
460   --  Returns true if type T is not tagged and is a derived type,
461   --  or is a private type whose completion is such a type.
462
463   procedure Kill_Dead_Code (N : Node_Id);
464   --  N represents a node for a section of code that is known to be
465   --  dead. The node is deleted, and any exception handler references
466   --  and warning messages relating to this code are removed.
467
468   procedure Kill_Dead_Code (L : List_Id);
469   --  Like the above procedure, but applies to every element in the given
470   --  list. Each of the entries is removed from the list before killing it.
471
472   function Known_Non_Negative (Opnd : Node_Id) return Boolean;
473   --  Given a node for a subexpression, determines if it represents a value
474   --  that cannot possibly be negative, and if so returns True. A value of
475   --  False means that it is not known if the value is positive or negative.
476
477   function Known_Non_Null (N : Node_Id) return Boolean;
478   --  Given a node N for a subexpression of an access type, determines if
479   --  this subexpression yields a value that is known at compile time to
480   --  be non-null and returns True if so. Returns False otherwise. It is
481   --  an error to call this function if N is not of an access type.
482
483   function Make_Subtype_From_Expr
484     (E       : Node_Id;
485      Unc_Typ : Entity_Id)
486      return    Node_Id;
487   --  Returns a subtype indication corresponding to the actual type of an
488   --  expression E. Unc_Typ is an unconstrained array or record, or
489   --  a classwide type.
490
491   function May_Generate_Large_Temp (Typ : Entity_Id) return Boolean;
492   --  Determines if the given type, Typ, may require a large temporary
493   --  of the type that causes trouble if stack checking is enabled. The
494   --  result is True only if stack checking is enabled and the size of
495   --  the type is known at compile time and large, where large is defined
496   --  hueristically by the body of this routine. The purpose of this
497   --  routine is to help avoid generating troublesome temporaries that
498   --  intefere with the stack checking mechanism.
499
500   procedure Remove_Side_Effects
501     (Exp          : Node_Id;
502      Name_Req     : Boolean := False;
503      Variable_Ref : Boolean := False);
504   --  Given the node for a subexpression, this function replaces the node
505   --  if necessary by an equivalent subexpression that is guaranteed to be
506   --  side effect free. This is done by extracting any actions that could
507   --  cause side effects, and inserting them using Insert_Actions into the
508   --  tree to which Exp is attached. Exp must be analayzed and resolved
509   --  before the call and is analyzed and resolved on return. The Name_Req
510   --  may only be set to True if Exp has the form of a name, and the
511   --  effect is to guarantee that any replacement maintains the form of a
512   --  name. If Variable_Ref is set to TRUE, a variable is considered as a
513   --  side effect (used in implementing Force_Evaluation). Note: after a
514   --  call to Remove_Side_Effects, it is safe to use a call to
515   --  New_Copy_Tree to obtain a copy of the resulting expression.
516
517   function Safe_Unchecked_Type_Conversion (Exp : Node_Id) return Boolean;
518   --  Given the node for an N_Unchecked_Type_Conversion, return True
519   --  if this is an unchecked conversion that Gigi can handle directly.
520   --  Otherwise return False if it is one for which the front end must
521   --  provide a temporary. Note that the node need not be analyzed, and
522   --  thus the Etype field may not be set, but in that case it must be
523   --  the case that the Subtype_Mark field of the node is set/analyzed.
524
525   procedure Set_Elaboration_Flag (N : Node_Id; Spec_Id : Entity_Id);
526   --  N is the node for a subprogram or generic body, and Spec_Id
527   --  is the entity for the corresponding spec. If an elaboration
528   --  entity is defined, then this procedure generates an assignment
529   --  statement to set it True, immediately after the body is elaborated.
530   --  However, no assignment is generated in the case of library level
531   --  procedures, since the setting of the flag in this case is generated
532   --  in the binder. We do that so that we can detect cases where this is
533   --  the only elaboration action that is required.
534
535   function Target_Has_Fixed_Ops
536     (Left_Typ   : Entity_Id;
537      Right_Typ  : Entity_Id;
538      Result_Typ : Entity_Id)
539      return       Boolean;
540   --  Returns True if and only if the target machine has direct support
541   --  for fixed-by-fixed multiplications and divisions for the given
542   --  operand and result types. This is called in package Exp_Fixd to
543   --  determine whether to expand such operations.
544
545   function Type_May_Have_Bit_Aligned_Components
546     (Typ : Entity_Id) return Boolean;
547   --  Determines if Typ is a composite type that has within it (looking
548   --  down recursively at any subcomponents), a record type which has a
549   --  component that may be bit aligned (see Possible_Bit_Aligned_Component).
550   --  The result is conservative, in that a result of False is decisive.
551   --  A result of True means that such a component may or may not be present.
552
553   procedure Wrap_Cleanup_Procedure (N : Node_Id);
554   --  Given an N_Subprogram_Body node, this procedure adds an Abort_Defer
555   --  call at the start of the statement sequence, and an Abort_Undefer call
556   --  at the end of the statement sequence. All cleanup routines (i.e. those
557   --  that are called from "at end" handlers) must defer abort on entry and
558   --  undefer abort on exit. Note that it is assumed that the code for the
559   --  procedure does not contain any return statements which would allow the
560   --  flow of control to escape doing the undefer call.
561
562private
563   pragma Inline (Force_Evaluation);
564   pragma Inline (Duplicate_Subexpr);
565
566end Exp_Util;
567