]>
Commit | Line | Data |
---|---|---|
70482933 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3 | -- GNAT COMPILER COMPONENTS -- | |
4 | -- -- | |
5 | -- E X P _ U T I L -- | |
6 | -- -- | |
7 | -- S p e c -- | |
8 | -- -- | |
cccef051 | 9 | -- Copyright (C) 1992-2023, Free Software Foundation, Inc. -- |
70482933 RK |
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- -- | |
b5c84c3c | 13 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
70482933 RK |
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 -- | |
b5c84c3c RD |
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. -- | |
70482933 RK |
20 | -- -- |
21 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 22 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
70482933 RK |
23 | -- -- |
24 | ------------------------------------------------------------------------------ | |
25 | ||
26 | -- Package containing utility procedures used throughout the expander | |
27 | ||
8517317c | 28 | with Einfo.Utils; use Einfo.Utils; |
104f58db BD |
29 | with Exp_Tss; use Exp_Tss; |
30 | with Namet; use Namet; | |
31 | with Rtsfind; use Rtsfind; | |
32 | with Sinfo; use Sinfo; | |
33 | with Sinfo.Nodes; use Sinfo.Nodes; | |
34 | with Types; use Types; | |
35 | with Uintp; use Uintp; | |
70482933 RK |
36 | |
37 | package Exp_Util is | |
38 | ||
39 | ----------------------------------------------- | |
40 | -- Handling of Actions Associated with Nodes -- | |
41 | ----------------------------------------------- | |
42 | ||
43 | -- The evaluation of certain expression nodes involves the elaboration | |
44 | -- of associated types and other declarations, and the execution of | |
45 | -- statement sequences. Expansion routines generating such actions must | |
46 | -- find an appropriate place in the tree to hang the actions so that | |
47 | -- they will be evaluated at the appropriate point. | |
48 | ||
49 | -- Some cases are simple: | |
50 | ||
51 | -- For an expression occurring in a simple statement that is in a list | |
52 | -- of statements, the actions are simply inserted into the list before | |
53 | -- the associated statement. | |
54 | ||
62acd2c4 GD |
55 | -- For an expression occurring in a declaration the actions are similarly |
56 | -- inserted into the list just before the associated declaration. (But | |
57 | -- note that although declarations usually appear in lists, they don't | |
58 | -- always; in particular, a library unit declaration does not appear in | |
59 | -- a list, and Insert_Action will crash in that case.) | |
70482933 RK |
60 | |
61 | -- The following special cases arise: | |
62 | ||
63 | -- For actions associated with the right operand of a short circuit | |
64 | -- form, the actions are first stored in the short circuit form node | |
65 | -- in the Actions field. The expansion of these forms subsequently | |
66 | -- expands the short circuit forms into if statements which can then | |
67 | -- be moved as described above. | |
68 | ||
69 | -- For actions appearing in the Condition expression of a while loop, | |
70 | -- or an elsif clause, the actions are similarly temporarily stored in | |
71 | -- in the node (N_Elsif_Part or N_Iteration_Scheme) associated with | |
72 | -- the expression using the Condition_Actions field. Subsequently, the | |
73 | -- expansion of these nodes rewrites the control structures involved to | |
74 | -- reposition the actions in normal statement sequence. | |
75 | ||
76 | -- For actions appearing in the then or else expression of a conditional | |
77 | -- expression, these actions are similarly placed in the node, using the | |
78 | -- Then_Actions or Else_Actions field as appropriate. Once again the | |
9b16cb57 RD |
79 | -- expansion of the N_If_Expression node rewrites the node so that the |
80 | -- actions can be positioned normally. | |
70482933 | 81 | |
7fcd29e0 RD |
82 | -- For actions coming from expansion of the expression in an expression |
83 | -- with actions node, the action is appended to the list of actions. | |
84 | ||
70482933 RK |
85 | -- Basically what we do is to climb up to the tree looking for the |
86 | -- proper insertion point, as described by one of the above cases, | |
87 | -- and then insert the appropriate action or actions. | |
88 | ||
89 | -- Note if more than one insert call is made specifying the same | |
90 | -- Assoc_Node, then the actions are elaborated in the order of the | |
91 | -- calls, and this guarantee is preserved for the special cases above. | |
92 | ||
93 | procedure Insert_Action | |
e2819941 HK |
94 | (Assoc_Node : Node_Id; |
95 | Ins_Action : Node_Id; | |
96 | Spec_Expr_OK : Boolean := False); | |
70482933 RK |
97 | -- Insert the action Ins_Action at the appropriate point as described |
98 | -- above. The action is analyzed using the default checks after it is | |
99 | -- inserted. Assoc_Node is the node with which the action is associated. | |
e2819941 | 100 | -- When flag Spec_Expr_OK is set, insertions triggered in the context of |
371e21cf | 101 | -- spec expressions are honored, even though they contradict "Handling |
e2819941 | 102 | -- of Default and Per-Object Expressions". |
70482933 RK |
103 | |
104 | procedure Insert_Action | |
e2819941 HK |
105 | (Assoc_Node : Node_Id; |
106 | Ins_Action : Node_Id; | |
107 | Suppress : Check_Id; | |
108 | Spec_Expr_OK : Boolean := False); | |
70482933 RK |
109 | -- Insert the action Ins_Action at the appropriate point as described |
110 | -- above. The action is analyzed using the default checks as modified | |
111 | -- by the given Suppress argument after it is inserted. Assoc_Node is | |
e2819941 HK |
112 | -- the node with which the action is associated. When flag Spec_Expr_OK |
113 | -- is set, insertions triggered in the context of spec expressions are | |
371e21cf | 114 | -- honored, even though they contradict "Handling of Default and Per- |
e2819941 | 115 | -- Object Expressions". |
70482933 RK |
116 | |
117 | procedure Insert_Actions | |
e2819941 HK |
118 | (Assoc_Node : Node_Id; |
119 | Ins_Actions : List_Id; | |
120 | Spec_Expr_OK : Boolean := False); | |
70482933 RK |
121 | -- Insert the list of action Ins_Actions at the appropriate point as |
122 | -- described above. The actions are analyzed using the default checks | |
123 | -- after they are inserted. Assoc_Node is the node with which the actions | |
124 | -- are associated. Ins_Actions may be No_List, in which case the call has | |
e2819941 | 125 | -- no effect. When flag Spec_Expr_OK is set, insertions triggered in the |
371e21cf | 126 | -- context of spec expressions are honored, even though they contradict |
e2819941 | 127 | -- "Handling of Default and Per-Object Expressions". |
70482933 RK |
128 | |
129 | procedure Insert_Actions | |
e2819941 HK |
130 | (Assoc_Node : Node_Id; |
131 | Ins_Actions : List_Id; | |
132 | Suppress : Check_Id; | |
133 | Spec_Expr_OK : Boolean := False); | |
70482933 RK |
134 | -- Insert the list of action Ins_Actions at the appropriate point as |
135 | -- described above. The actions are analyzed using the default checks | |
136 | -- as modified by the given Suppress argument after they are inserted. | |
e2819941 | 137 | -- Assoc_Node is the node with which the actions are associated. List |
70482933 | 138 | -- Ins_Actions may be No_List, in which case the call has no effect. |
e2819941 | 139 | -- When flag Spec_Expr_OK is set, insertions triggered in the context of |
371e21cf | 140 | -- spec expressions are honored, even though they contradict "Handling |
e2819941 | 141 | -- of Default and Per-Object Expressions". |
70482933 | 142 | |
df3e68b1 HK |
143 | procedure Insert_Action_After |
144 | (Assoc_Node : Node_Id; | |
145 | Ins_Action : Node_Id); | |
146 | -- Assoc_Node must be a node in a list. Same as Insert_Action but the | |
147 | -- action will be inserted after N in a manner that is compatible with | |
148 | -- the transient scope mechanism. | |
7b966a95 AC |
149 | -- |
150 | -- Note: If several successive calls to Insert_Action_After are made for | |
151 | -- the same node, they will each in turn be inserted just after the node. | |
152 | -- This means they will end up being executed in reverse order. Use the | |
153 | -- call to Insert_Actions_After to insert a list of actions to be executed | |
154 | -- in the sequence in which they are given in the list. | |
df3e68b1 | 155 | |
70482933 RK |
156 | procedure Insert_Actions_After |
157 | (Assoc_Node : Node_Id; | |
158 | Ins_Actions : List_Id); | |
159 | -- Assoc_Node must be a node in a list. Same as Insert_Actions but | |
160 | -- actions will be inserted after N in a manner that is compatible with | |
161 | -- the transient scope mechanism. This procedure must be used instead | |
162 | -- of Insert_List_After if Assoc_Node may be in a transient scope. | |
163 | -- | |
164 | -- Implementation limitation: Assoc_Node must be a statement. We can | |
165 | -- generalize to expressions if there is a need but this is tricky to | |
06a5fb60 | 166 | -- implement because of short-circuits (among other things). |
70482933 RK |
167 | |
168 | procedure Insert_Library_Level_Action (N : Node_Id); | |
169 | -- This procedure inserts and analyzes the node N as an action at the | |
170 | -- library level for the current unit (i.e. it is attached to the | |
171 | -- Actions field of the N_Compilation_Aux node for the main unit). | |
172 | ||
173 | procedure Insert_Library_Level_Actions (L : List_Id); | |
758c442c | 174 | -- Similar, but inserts a list of actions |
70482933 RK |
175 | |
176 | ----------------------- | |
177 | -- Other Subprograms -- | |
178 | ----------------------- | |
179 | ||
4c318253 AC |
180 | procedure Activate_Atomic_Synchronization (N : Node_Id); |
181 | -- N is a node for which atomic synchronization may be required (it is | |
182 | -- either an identifier, expanded name, or selected/indexed component or | |
183 | -- an explicit dereference). The caller has checked the basic conditions | |
184 | -- (atomic variable appearing and Atomic_Sync not disabled). This function | |
185 | -- checks if atomic synchronization is required and if so sets the flag | |
186 | -- and if appropriate generates a warning (in -gnatw.n mode). | |
187 | ||
70482933 RK |
188 | procedure Adjust_Condition (N : Node_Id); |
189 | -- The node N is an expression whose root-type is Boolean, and which | |
190 | -- represents a boolean value used as a condition (i.e. a True/False | |
191 | -- value). This routine handles the case of C and Fortran convention | |
758c442c GD |
192 | -- boolean types, which have zero/non-zero semantics rather than the normal |
193 | -- 0/1 semantics, and also the case of an enumeration rep clause that | |
194 | -- specifies a non-standard representation. On return, node N always has | |
195 | -- the type Standard.Boolean, with a value that is a standard Boolean | |
196 | -- values of 0/1 for False/True. This procedure is used in two situations. | |
197 | -- First, the processing for a condition field always calls | |
198 | -- Adjust_Condition, so that the boolean value presented to the backend is | |
199 | -- a standard value. Second, for the code for boolean operations such as | |
200 | -- AND, Adjust_Condition is called on both operands, and then the operation | |
201 | -- is done in the domain of Standard_Boolean, then Adjust_Result_Type is | |
202 | -- called on the result to possibly reset the original type. This procedure | |
70482933 RK |
203 | -- also takes care of validity checking if Validity_Checks = Tests. |
204 | ||
205 | procedure Adjust_Result_Type (N : Node_Id; T : Entity_Id); | |
206 | -- The processing of boolean operations like AND uses the procedure | |
758c442c GD |
207 | -- Adjust_Condition so that it can operate on Standard.Boolean, which is |
208 | -- the only boolean type on which the backend needs to be able to implement | |
209 | -- such operators. This means that the result is also of type | |
210 | -- Standard.Boolean. In general the type must be reset back to the original | |
211 | -- type to get proper semantics, and that is the purpose of this procedure. | |
212 | -- N is the node (of type Standard.Boolean), and T is the desired type. As | |
213 | -- an optimization, this procedure leaves the type as Standard.Boolean in | |
214 | -- contexts where this is permissible (in particular for Condition fields, | |
215 | -- and for operands of other logical operations higher up the tree). The | |
216 | -- call to this procedure is completely ignored if the argument N is not of | |
217 | -- type Boolean. | |
70482933 RK |
218 | |
219 | procedure Append_Freeze_Action (T : Entity_Id; N : Node_Id); | |
220 | -- Add a new freeze action for the given type. The freeze action is | |
758c442c GD |
221 | -- attached to the freeze node for the type. Actions will be elaborated in |
222 | -- the order in which they are added. Note that the added node is not | |
05350ac6 | 223 | -- analyzed. The analyze call is found in Exp_Ch13.Expand_N_Freeze_Entity. |
70482933 RK |
224 | |
225 | procedure Append_Freeze_Actions (T : Entity_Id; L : List_Id); | |
758c442c GD |
226 | -- Adds the given list of freeze actions (declarations or statements) for |
227 | -- the given type. The freeze actions are attached to the freeze node for | |
228 | -- the type. Actions will be elaborated in the order in which they are | |
229 | -- added, and the actions within the list will be elaborated in list order. | |
230 | -- Note that the added nodes are not analyzed. The analyze call is found in | |
05350ac6 | 231 | -- Exp_Ch13.Expand_N_Freeze_Entity. |
70482933 | 232 | |
d2880e69 CD |
233 | function Attribute_Constrained_Static_Value (Pref : Node_Id) return Boolean; |
234 | -- Return the static value of a statically known attribute reference | |
235 | -- Pref'Constrained. | |
236 | ||
df3e68b1 HK |
237 | procedure Build_Allocate_Deallocate_Proc |
238 | (N : Node_Id; | |
239 | Is_Allocate : Boolean); | |
240 | -- Create a custom Allocate/Deallocate to be associated with an allocation | |
ca5af305 AC |
241 | -- or deallocation: |
242 | -- | |
243 | -- 1) controlled objects | |
244 | -- 2) class-wide objects | |
245 | -- 3) any kind of object on a subpool | |
246 | -- | |
247 | -- N must be an allocator or the declaration of a temporary variable which | |
df3e68b1 HK |
248 | -- represents the expression of the original allocator node, otherwise N |
249 | -- must be a free statement. If flag Is_Allocate is set, the generated | |
d3f70b35 | 250 | -- routine is allocate, deallocate otherwise. |
df3e68b1 | 251 | |
bb072d1c AC |
252 | function Build_Abort_Undefer_Block |
253 | (Loc : Source_Ptr; | |
254 | Stmts : List_Id; | |
255 | Context : Node_Id) return Node_Id; | |
256 | -- Wrap statements Stmts in a block where the AT END handler contains a | |
257 | -- call to Abort_Undefer_Direct. Context is the node which prompted the | |
258 | -- inlining of the abort undefer routine. Note that this routine does | |
259 | -- not install a call to Abort_Defer. | |
260 | ||
f63d601b | 261 | procedure Build_Class_Wide_Expression |
475e1d24 JM |
262 | (Pragma_Or_Expr : Node_Id; |
263 | Subp : Entity_Id; | |
264 | Par_Subp : Entity_Id; | |
265 | Adjust_Sloc : Boolean); | |
266 | -- Build the expression for an inherited class-wide condition. Pragma_Or_ | |
267 | -- _Expr is either the pragma constructed from the corresponding aspect of | |
268 | -- the parent subprogram or the class-wide pre/postcondition built from the | |
269 | -- parent, Subp is the overriding operation, and Par_Subp is the overridden | |
270 | -- operation that has the condition. Adjust_Sloc is True when the sloc of | |
271 | -- nodes traversed should be adjusted for the inherited pragma. | |
f63d601b HK |
272 | |
273 | function Build_DIC_Call | |
f7937111 GD |
274 | (Loc : Source_Ptr; |
275 | Obj_Name : Node_Id; | |
276 | Typ : Entity_Id) return Node_Id; | |
277 | -- Build a call to the DIC procedure for Typ with Obj_Name as the actual | |
f63d601b HK |
278 | -- parameter. |
279 | ||
b619c88e | 280 | procedure Build_DIC_Procedure_Body |
f7937111 GD |
281 | (Typ : Entity_Id; |
282 | Partial_DIC : Boolean := False); | |
f63d601b | 283 | -- Create the body of the procedure which verifies the assertion expression |
f7937111 GD |
284 | -- of pragma Default_Initial_Condition at run time. Partial_DIC indicates |
285 | -- that a partial DIC-checking procedure body should be built, for checking | |
286 | -- a DIC associated with the type's partial view, and which will be called | |
287 | -- by the main DIC procedure. | |
288 | ||
289 | procedure Build_DIC_Procedure_Declaration | |
290 | (Typ : Entity_Id; | |
291 | Partial_DIC : Boolean := False); | |
f63d601b | 292 | -- Create the declaration of the procedure which verifies the assertion |
f7937111 GD |
293 | -- expression of pragma Default_Initial_Condition at run time. Partial_DIC |
294 | -- indicates that a partial DIC-checking procedure should be declared, | |
295 | -- for checking a DIC associated with the type's partial view, and which | |
296 | -- will be called by the main DIC procedure. | |
f63d601b | 297 | |
51148dda AC |
298 | procedure Build_Invariant_Procedure_Body |
299 | (Typ : Entity_Id; | |
300 | Partial_Invariant : Boolean := False); | |
301 | -- Create the body of the procedure which verifies the invariants of type | |
302 | -- Typ at runtime. Flag Partial_Invariant should be set when Typ denotes a | |
303 | -- private type, otherwise it is assumed that Typ denotes the full view of | |
304 | -- a private type. | |
305 | ||
306 | procedure Build_Invariant_Procedure_Declaration | |
307 | (Typ : Entity_Id; | |
308 | Partial_Invariant : Boolean := False); | |
309 | -- Create the declaration of the procedure which verifies the invariants of | |
310 | -- type Typ at runtime. Flag Partial_Invariant should be set when building | |
311 | -- the invariant procedure for a private type. | |
312 | ||
51b42ffa AC |
313 | procedure Build_Procedure_Form (N : Node_Id); |
314 | -- Create a procedure declaration which emulates the behavior of a function | |
315 | -- that returns an array type, for C-compatible generation. | |
316 | ||
70482933 RK |
317 | function Build_Runtime_Call (Loc : Source_Ptr; RE : RE_Id) return Node_Id; |
318 | -- Build an N_Procedure_Call_Statement calling the given runtime entity. | |
319 | -- The call has no parameters. The first argument provides the location | |
320 | -- information for the tree and for error messages. The call node is not | |
321 | -- analyzed on return, the caller is responsible for analyzing it. | |
322 | ||
8e888920 AC |
323 | function Build_SS_Mark_Call |
324 | (Loc : Source_Ptr; | |
325 | Mark : Entity_Id) return Node_Id; | |
326 | -- Build a call to routine System.Secondary_Stack.Mark. Mark denotes the | |
327 | -- entity of the secondary stack mark. | |
328 | ||
329 | function Build_SS_Release_Call | |
330 | (Loc : Source_Ptr; | |
331 | Mark : Entity_Id) return Node_Id; | |
332 | -- Build a call to routine System.Secondary_Stack.Release. Mark denotes the | |
333 | -- entity of the secondary stack mark. | |
334 | ||
70482933 | 335 | function Build_Task_Image_Decls |
05350ac6 BD |
336 | (Loc : Source_Ptr; |
337 | Id_Ref : Node_Id; | |
338 | A_Type : Entity_Id; | |
339 | In_Init_Proc : Boolean := False) return List_Id; | |
758c442c GD |
340 | -- Build declaration for a variable that holds an identifying string to be |
341 | -- used as a task name. Id_Ref is an identifier if the task is a variable, | |
342 | -- and a selected or indexed component if the task is component of an | |
343 | -- object. If it is an indexed component, A_Type is the corresponding array | |
344 | -- type. Its index types are used to build the string as an image of the | |
345 | -- index values. For composite types, the result includes two declarations: | |
346 | -- one for a generated function that computes the image without using | |
347 | -- concatenation, and one for the variable that holds the result. | |
b970b571 | 348 | -- |
05350ac6 BD |
349 | -- If In_Init_Proc is true, the call is part of the initialization of |
350 | -- a component of a composite type, and the enclosing initialization | |
351 | -- procedure must be flagged as using the secondary stack. If In_Init_Proc | |
352 | -- is false, the call is for a stand-alone object, and the generated | |
353 | -- function itself must do its own cleanups. | |
70482933 | 354 | |
ca4bff3a EB |
355 | function Build_Temporary_On_Secondary_Stack |
356 | (Loc : Source_Ptr; | |
357 | Typ : Entity_Id; | |
358 | Code : List_Id) return Entity_Id; | |
359 | -- Build a temporary of type Typ on the secondary stack, appending the | |
360 | -- necessary actions to Code, and return a constant holding the access | |
361 | -- value designating this temporary, under the assumption that Typ does | |
362 | -- not need finalization. | |
363 | ||
364 | -- This should be used when Typ can potentially be large, to avoid putting | |
365 | -- too much pressure on the primary stack, for example with storage models. | |
366 | ||
937e9676 AC |
367 | procedure Build_Transient_Object_Statements |
368 | (Obj_Decl : Node_Id; | |
369 | Fin_Call : out Node_Id; | |
370 | Hook_Assign : out Node_Id; | |
371 | Hook_Clear : out Node_Id; | |
372 | Hook_Decl : out Node_Id; | |
373 | Ptr_Decl : out Node_Id; | |
374 | Finalize_Obj : Boolean := True); | |
375 | -- Subsidiary to the processing of transient objects in transient scopes, | |
4b14ffb9 EB |
376 | -- if expressions, case expressions, and expression_with_action nodes. |
377 | -- Obj_Decl denotes the declaration of the transient object. Generate the | |
378 | -- following nodes: | |
937e9676 AC |
379 | -- |
380 | -- * Fin_Call - the call to [Deep_]Finalize which cleans up the transient | |
381 | -- object if flag Finalize_Obj is set to True, or finalizes the hook when | |
382 | -- the flag is False. | |
383 | -- | |
384 | -- * Hook_Assign - the assignment statement which captures a reference to | |
385 | -- the transient object in the hook. | |
386 | -- | |
387 | -- * Hook_Clear - the assignment statement which resets the hook to null | |
388 | -- | |
389 | -- * Hook_Decl - the declaration of the hook object | |
390 | -- | |
391 | -- * Ptr_Decl - the full type declaration of the hook type | |
392 | -- | |
393 | -- These nodes are inserted in specific places depending on the context by | |
394 | -- the various Process_Transient_xxx routines. | |
395 | ||
d26d790d AC |
396 | procedure Check_Float_Op_Overflow (N : Node_Id); |
397 | -- Called where we could have a floating-point binary operator where we | |
398 | -- must check for infinities if we are operating in Check_Float_Overflow | |
399 | -- mode. Note that we don't need to worry about unary operator cases, | |
400 | -- since for floating-point, abs, unary "-", and unary "+" can never | |
401 | -- case overflow. | |
402 | ||
65ea0024 EB |
403 | function Component_May_Be_Bit_Aligned |
404 | (Comp : Entity_Id; | |
405 | For_Slice : Boolean := False) return Boolean; | |
fba9fcae | 406 | -- This function is in charge of detecting record components that may cause |
65ea0024 EB |
407 | -- trouble for the back end if an attempt is made to access the component, |
408 | -- either as a whole if For_Slice is False, or through an array slice if | |
409 | -- For_Slice is True. The back end can handle such accesses only if the | |
410 | -- components involved are small (64/128 bits or less) records or scalars | |
fba9fcae EB |
411 | -- (including bit-packed arrays represented with a modular type), or else |
412 | -- if they are aligned on byte boundaries (i.e. starting on a byte boundary | |
413 | -- and occupying an integral number of bytes). | |
91b1417d | 414 | -- |
65ea0024 | 415 | -- However problems arise for records larger than 64/128 bits or for arrays |
758c442c | 416 | -- (other than bit-packed arrays represented with a modular type) if the |
fba9fcae EB |
417 | -- component either does not start on a byte boundary or does not occupy an |
418 | -- integral number of bytes (i.e. there are some bits possibly shared with | |
419 | -- other components at the start or the end of the component). The back end | |
420 | -- cannot handle loading from or storing to such components as a whole. | |
91b1417d | 421 | -- |
fba9fcae EB |
422 | -- This function is used to detect the troublesome situation. It is meant |
423 | -- to be conservative in the sense that it produces True unless it knows | |
424 | -- for sure that the component is safe (as outlined in the first paragraph | |
425 | -- above). The processing for record and array assignment indirectly checks | |
426 | -- for trouble using this function and, if so, the assignment is expanded | |
758c442c | 427 | -- component-wise, which the back end is required to handle correctly. |
91b1417d | 428 | |
70482933 | 429 | procedure Convert_To_Actual_Subtype (Exp : Node_Id); |
1923d2d6 JM |
430 | -- The Etype of an expression is the nominal type of the expression, |
431 | -- not the actual subtype. Often these are the same, but not always. | |
432 | -- For example, a reference to a formal of unconstrained type has the | |
758c442c GD |
433 | -- unconstrained type as its Etype, but the actual subtype is obtained by |
434 | -- applying the actual bounds. This routine is given an expression, Exp, | |
1923d2d6 JM |
435 | -- and (if necessary), replaces it using Rewrite, with a conversion to |
436 | -- the actual subtype, building the actual subtype if necessary. If the | |
758c442c | 437 | -- expression is already of the requested type, then it is unchanged. |
70482933 | 438 | |
1923d2d6 JM |
439 | function Corresponding_Runtime_Package (Typ : Entity_Id) return RTU_Id; |
440 | -- Return the id of the runtime package that will provide support for | |
441 | -- concurrent type Typ. Currently only protected types are supported, | |
442 | -- and the returned value is one of the following: | |
443 | -- System_Tasking_Protected_Objects | |
444 | -- System_Tasking_Protected_Objects_Entries | |
445 | -- System_Tasking_Protected_Objects_Single_Entry | |
446 | ||
70482933 | 447 | function Current_Sem_Unit_Declarations return List_Id; |
e14c931f | 448 | -- Return the place where it is fine to insert declarations for the |
70482933 RK |
449 | -- current semantic unit. If the unit is a package body, return the |
450 | -- visible declarations of the corresponding spec. For RCI stubs, this | |
451 | -- is necessary because the point at which they are generated may not | |
452 | -- be the earliest point at which they are used. | |
453 | ||
454 | function Duplicate_Subexpr | |
a43f6434 AC |
455 | (Exp : Node_Id; |
456 | Name_Req : Boolean := False; | |
457 | Renaming_Req : Boolean := False) return Node_Id; | |
758c442c GD |
458 | -- Given the node for a subexpression, this function makes a logical copy |
459 | -- of the subexpression, and returns it. This is intended for use when the | |
460 | -- expansion of an expression needs to repeat part of it. For example, | |
461 | -- replacing a**2 by a*a requires two references to a which may be a | |
462 | -- complex subexpression. Duplicate_Subexpr guarantees not to duplicate | |
463 | -- side effects. If necessary, it generates actions to save the expression | |
464 | -- value in a temporary, inserting these actions into the tree using | |
465 | -- Insert_Actions with Exp as the insertion location. The original | |
466 | -- expression and the returned result then become references to this saved | |
467 | -- value. Exp must be analyzed on entry. On return, Exp is analyzed, but | |
468 | -- the caller is responsible for analyzing the returned copy after it is | |
a43f6434 AC |
469 | -- attached to the tree. |
470 | -- | |
471 | -- The Name_Req flag is set to ensure that the result is suitable for use | |
472 | -- in a context requiring a name (for example, the prefix of an attribute | |
62acd2c4 | 473 | -- reference). |
a43f6434 AC |
474 | -- |
475 | -- The Renaming_Req flag is set to produce an object renaming declaration | |
476 | -- rather than an object declaration. This is valid only if the expression | |
477 | -- Exp designates a renamable object. This is used for example in the case | |
478 | -- of an unchecked deallocation, to make sure the object gets set to null. | |
8cbb664e MG |
479 | -- |
480 | -- Note that if there are any run time checks in Exp, these same checks | |
481 | -- will be duplicated in the returned duplicated expression. The two | |
482 | -- following functions allow this behavior to be modified. | |
483 | ||
484 | function Duplicate_Subexpr_No_Checks | |
2934b84a AC |
485 | (Exp : Node_Id; |
486 | Name_Req : Boolean := False; | |
487 | Renaming_Req : Boolean := False; | |
488 | Related_Id : Entity_Id := Empty; | |
489 | Is_Low_Bound : Boolean := False; | |
490 | Is_High_Bound : Boolean := False) return Node_Id; | |
491 | -- Identical in effect to Duplicate_Subexpr, except that Remove_Checks is | |
492 | -- called on the result, so that the duplicated expression does not include | |
493 | -- checks. This is appropriate for use when Exp, the original expression is | |
494 | -- unconditionally elaborated before the duplicated expression, so that | |
495 | -- there is no need to repeat any checks. | |
496 | -- | |
497 | -- Related_Id denotes the entity of the context where Expr appears. Flags | |
498 | -- Is_Low_Bound and Is_High_Bound specify whether the expression to check | |
499 | -- is the low or the high bound of a range. These three optional arguments | |
500 | -- signal Remove_Side_Effects to create an external symbol of the form | |
580d40e8 AC |
501 | -- Chars (Related_Id)_FIRST/_LAST. For suggested use of these parameters |
502 | -- see the warning in the body of Sem_Ch3.Process_Range_Expr_In_Decl. | |
8cbb664e MG |
503 | |
504 | function Duplicate_Subexpr_Move_Checks | |
a43f6434 AC |
505 | (Exp : Node_Id; |
506 | Name_Req : Boolean := False; | |
507 | Renaming_Req : Boolean := False) return Node_Id; | |
758c442c GD |
508 | -- Identical in effect to Duplicate_Subexpr, except that Remove_Checks is |
509 | -- called on Exp after the duplication is complete, so that the original | |
510 | -- expression does not include checks. In this case the result returned | |
511 | -- (the duplicated expression) will retain the original checks. This is | |
512 | -- appropriate for use when the duplicated expression is sure to be | |
513 | -- elaborated before the original expression Exp, so that there is no need | |
514 | -- to repeat the checks. | |
70482933 | 515 | |
341e0bb6 | 516 | function Enclosing_Init_Proc return Entity_Id; |
f537fc00 HK |
517 | -- Obtain the entity of the type initialization procedure which encloses |
518 | -- the current scope. Return Empty if no such procedure exists. | |
341e0bb6 | 519 | |
70482933 RK |
520 | procedure Ensure_Defined (Typ : Entity_Id; N : Node_Id); |
521 | -- This procedure ensures that type referenced by Typ is defined. For the | |
522 | -- case of a type other than an Itype, nothing needs to be done, since | |
523 | -- all such types have declaration nodes. For Itypes, an N_Itype_Reference | |
ce532f42 | 524 | -- node is generated and inserted as an action on node N. This is typically |
70482933 RK |
525 | -- used to ensure that an Itype is properly defined outside a conditional |
526 | -- construct when it is referenced in more than one branch. | |
527 | ||
cc570be6 | 528 | procedure Evaluate_Name (Nam : Node_Id); |
63bb4268 | 529 | -- Remove all side effects from a name which appears as part of an object |
cd5acda5 YM |
530 | -- renaming declaration. Similarly to Force_Evaluation, it removes the |
531 | -- side effects and captures the values of the variables, except for the | |
532 | -- variable being renamed. Hence this differs from Force_Evaluation and | |
533 | -- Remove_Side_Effects (but it calls Force_Evaluation on subexpressions | |
534 | -- whose value needs to be fixed). | |
cc570be6 | 535 | |
70482933 RK |
536 | procedure Evolve_And_Then (Cond : in out Node_Id; Cond1 : Node_Id); |
537 | -- Rewrites Cond with the expression: Cond and then Cond1. If Cond is | |
538 | -- Empty, then simply returns Cond1 (this allows the use of Empty to | |
539 | -- initialize a series of checks evolved by this routine, with a final | |
758c442c GD |
540 | -- result of Empty indicating that no checks were required). The Sloc field |
541 | -- of the constructed N_And_Then node is copied from Cond1. | |
70482933 RK |
542 | |
543 | procedure Evolve_Or_Else (Cond : in out Node_Id; Cond1 : Node_Id); | |
758c442c GD |
544 | -- Rewrites Cond with the expression: Cond or else Cond1. If Cond is Empty, |
545 | -- then simply returns Cond1 (this allows the use of Empty to initialize a | |
546 | -- series of checks evolved by this routine, with a final result of Empty | |
547 | -- indicating that no checks were required). The Sloc field of the | |
548 | -- constructed N_Or_Else node is copied from Cond1. | |
70482933 | 549 | |
d32db3a7 GD |
550 | procedure Expand_Sliding_Conversion (N : Node_Id; Arr_Typ : Entity_Id); |
551 | -- When sliding is needed for an array object N in the context of an | |
552 | -- unconstrained array type Arr_Typ with fixed lower bound (FLB), create | |
553 | -- a subtype with appropriate index constraint (FLB .. N'Length + FLB - 1) | |
554 | -- and apply a conversion from N to that subtype. | |
555 | ||
9e92ad49 AC |
556 | procedure Expand_Static_Predicates_In_Choices (N : Node_Id); |
557 | -- N is either a case alternative or a variant. The Discrete_Choices field | |
558 | -- of N points to a list of choices. If any of these choices is the name | |
559 | -- of a (statically) predicated subtype, then it is rewritten as the series | |
560 | -- of choices that correspond to the values allowed for the subtype. | |
561 | ||
70482933 RK |
562 | procedure Expand_Subtype_From_Expr |
563 | (N : Node_Id; | |
564 | Unc_Type : Entity_Id; | |
565 | Subtype_Indic : Node_Id; | |
d9307840 HK |
566 | Exp : Node_Id; |
567 | Related_Id : Entity_Id := Empty); | |
70482933 RK |
568 | -- Build a constrained subtype from the initial value in object |
569 | -- declarations and/or allocations when the type is indefinite (including | |
d9307840 HK |
570 | -- class-wide). Set Related_Id to request an external name for the subtype |
571 | -- rather than an internal temporary. | |
70482933 | 572 | |
28ccbd3f AC |
573 | function Expression_Contains_Primitives_Calls_Of |
574 | (Expr : Node_Id; | |
575 | Typ : Entity_Id) return Boolean; | |
178c3cba | 576 | -- Return True if the expression Expr contains a nondispatching call to a |
28ccbd3f AC |
577 | -- function which is a primitive of the tagged type Typ. |
578 | ||
760804f3 | 579 | function Finalize_Address (Typ : Entity_Id) return Entity_Id; |
46413d9e AC |
580 | -- Locate TSS primitive Finalize_Address in type Typ. Return Empty if the |
581 | -- subprogram is not available. | |
760804f3 | 582 | |
758c442c | 583 | function Find_Interface_ADT |
f4d379b8 | 584 | (T : Entity_Id; |
ac4d6407 | 585 | Iface : Entity_Id) return Elmt_Id; |
758c442c | 586 | -- Ada 2005 (AI-251): Given a type T implementing the interface Iface, |
ac4d6407 RD |
587 | -- return the element of Access_Disp_Table containing the tag of the |
588 | -- interface. | |
758c442c GD |
589 | |
590 | function Find_Interface_Tag | |
f4d379b8 HK |
591 | (T : Entity_Id; |
592 | Iface : Entity_Id) return Entity_Id; | |
d58008d2 EB |
593 | -- Ada 2005 (AI-251): Given a type T and an interface Iface, return the |
594 | -- record component containing the tag of Iface if T implements Iface or | |
595 | -- Empty if it does not. | |
758c442c | 596 | |
c7732bbe EB |
597 | -- WARNING: There is a matching C declaration of this subprogram in fe.h |
598 | ||
70482933 | 599 | function Find_Prim_Op (T : Entity_Id; Name : Name_Id) return Entity_Id; |
c2b2b2d7 | 600 | -- Find the first primitive operation of a tagged type T with name Name. |
fbf5a39b | 601 | -- This function allows the use of a primitive operation which is not |
475e1d24 | 602 | -- directly visible. If T is a class-wide type, then the reference is to an |
ca811241 BD |
603 | -- operation of the corresponding root type. It is an error if no primitive |
604 | -- operation with the given name is found. | |
fbf5a39b AC |
605 | |
606 | function Find_Prim_Op | |
607 | (T : Entity_Id; | |
608 | Name : TSS_Name_Type) return Entity_Id; | |
31e358e1 AC |
609 | -- Same as Find_Prim_Op above, except we're searching for an op that has |
610 | -- the form indicated by Name (i.e. is a type support subprogram with the | |
611 | -- indicated suffix). | |
ca811241 BD |
612 | |
613 | function Find_Optional_Prim_Op | |
614 | (T : Entity_Id; Name : Name_Id) return Entity_Id; | |
615 | function Find_Optional_Prim_Op | |
616 | (T : Entity_Id; | |
617 | Name : TSS_Name_Type) return Entity_Id; | |
618 | -- Same as Find_Prim_Op, except returns Empty if not found | |
70482933 | 619 | |
65df5b71 | 620 | function Find_Protection_Object (Scop : Entity_Id) return Entity_Id; |
ca811241 BD |
621 | -- Traverse the scope stack starting from Scop and look for an entry, entry |
622 | -- family, or a subprogram that has a Protection_Object and return it. Must | |
623 | -- always return a value since the context in which this routine is invoked | |
624 | -- should always have a protection object. | |
65df5b71 | 625 | |
df3e68b1 HK |
626 | function Find_Protection_Type (Conc_Typ : Entity_Id) return Entity_Id; |
627 | -- Given a protected type or its corresponding record, find the type of | |
628 | -- field _object. | |
629 | ||
b479c0f7 GD |
630 | function Find_Storage_Op |
631 | (Typ : Entity_Id; | |
632 | Nam : Name_Id) return Entity_Id; | |
633 | -- Given type Typ that's either a descendant of Root_Storage_Pool or else | |
634 | -- specifies aspect Storage_Model_Type, returns the Entity_Id of the | |
635 | -- subprogram associated with Nam, which must either be a primitive op of | |
636 | -- the type in the case of a storage pool, or the operation corresponding | |
9f857be3 GD |
637 | -- to Nam as specified in the aspect Storage_Model_Type. In the case of |
638 | -- aspect Storage_Model_Type, returns Empty when no operation is found, | |
639 | -- indicating that the operation is defaulted in the aspect (can occur in | |
640 | -- the case where the storage-model address type is System.Address). | |
b479c0f7 | 641 | |
e59243fa AC |
642 | function Find_Hook_Context (N : Node_Id) return Node_Id; |
643 | -- Determine a suitable node on which to attach actions related to N that | |
644 | -- need to be elaborated unconditionally. In general this is the topmost | |
645 | -- expression of which N is a subexpression, which in turn may or may not | |
646 | -- be evaluated, for example if N is the right operand of a short circuit | |
647 | -- operator. | |
648 | ||
cd2c6027 AC |
649 | function Following_Address_Clause (D : Node_Id) return Node_Id; |
650 | -- D is the node for an object declaration. This function searches the | |
651 | -- current declarative part to look for an address clause for the object | |
652 | -- being declared, and returns the clause if one is found, returns | |
653 | -- Empty otherwise. | |
654 | ||
89d3b1a1 AC |
655 | type Force_Evaluation_Mode is (Relaxed, Strict); |
656 | ||
70482933 | 657 | procedure Force_Evaluation |
28c7180f RD |
658 | (Exp : Node_Id; |
659 | Name_Req : Boolean := False; | |
660 | Related_Id : Entity_Id := Empty; | |
661 | Is_Low_Bound : Boolean := False; | |
89d3b1a1 | 662 | Is_High_Bound : Boolean := False; |
325443d2 | 663 | Discr_Number : Int := 0; |
89d3b1a1 | 664 | Mode : Force_Evaluation_Mode := Relaxed); |
70482933 RK |
665 | -- Force the evaluation of the expression right away. Similar behavior |
666 | -- to Remove_Side_Effects when Variable_Ref is set to TRUE. That is to | |
28c7180f | 667 | -- say, it removes the side effects and captures the values of the |
984a64bc | 668 | -- variables. Remove_Side_Effects guarantees that multiple evaluations |
70482933 RK |
669 | -- of the same expression won't generate multiple side effects, whereas |
670 | -- Force_Evaluation further guarantees that all evaluations will yield | |
89d3b1a1 | 671 | -- the same result. If Mode is Relaxed then calls to this subprogram have |
14c3ae9a GD |
672 | -- no effect if Exp is side-effect free; if Mode is Strict and Exp is not |
673 | -- a static expression then no side-effect check is performed on Exp and | |
89d3b1a1 | 674 | -- temporaries are unconditionally generated. |
28c7180f RD |
675 | -- |
676 | -- Related_Id denotes the entity of the context where Expr appears. Flags | |
677 | -- Is_Low_Bound and Is_High_Bound specify whether the expression to check | |
678 | -- is the low or the high bound of a range. These three optional arguments | |
679 | -- signal Remove_Side_Effects to create an external symbol of the form | |
680 | -- Chars (Related_Id)_FIRST/_LAST. If Related_Id is set, then exactly one | |
681 | -- of the Is_xxx_Bound flags must be set. For use of these parameters see | |
682 | -- the warning in the body of Sem_Ch3.Process_Range_Expr_In_Decl. | |
70482933 | 683 | |
325443d2 ES |
684 | -- Discr_Number is positive when the expression is a discriminant value |
685 | -- in an object or component declaration. In that case Discr_Number is | |
686 | -- the position of the corresponding discriminant in the corresponding | |
687 | -- type declaration, and the name for the evaluated expression is built | |
688 | -- out of the Related_Id and the Discr_Number. | |
689 | ||
72267417 AC |
690 | function Fully_Qualified_Name_String |
691 | (E : Entity_Id; | |
692 | Append_NUL : Boolean := True) return String_Id; | |
afbcdf5e | 693 | -- Generates the string literal corresponding to the fully qualified name |
b2502161 | 694 | -- of entity E, in all upper case, with an ASCII.NUL appended at the end |
72267417 | 695 | -- of the name if Append_NUL is True. |
afbcdf5e | 696 | |
fbf5a39b AC |
697 | procedure Get_Current_Value_Condition |
698 | (Var : Node_Id; | |
699 | Op : out Node_Kind; | |
a6505936 | 700 | Val : out Node_Id) with Post => Val /= Var; |
758c442c GD |
701 | -- This routine processes the Current_Value field of the variable Var. If |
702 | -- the Current_Value field is null or if it represents a known value, then | |
703 | -- on return Cond is set to N_Empty, and Val is set to Empty. | |
fbf5a39b | 704 | -- |
758c442c | 705 | -- The other case is when Current_Value points to an N_If_Statement or an |
05350ac6 BD |
706 | -- N_Elsif_Part or a N_Iteration_Scheme node (see description in Einfo for |
707 | -- exact details). In this case, Get_Current_Condition digs out the | |
708 | -- condition, and then checks if the condition is known false, known true, | |
709 | -- or not known at all. In the first two cases, Get_Current_Condition will | |
710 | -- return with Op set to the appropriate conditional operator (inverted if | |
711 | -- the condition is known false), and Val set to the constant value. If the | |
0712790c | 712 | -- condition is not known, then Op and Val are set for the empty case |
05350ac6 | 713 | -- (N_Empty and Empty). |
fbf5a39b AC |
714 | -- |
715 | -- The check for whether the condition is true/false unknown depends | |
716 | -- on the case: | |
717 | -- | |
758c442c GD |
718 | -- For an IF, the condition is known true in the THEN part, known false |
719 | -- in any ELSIF or ELSE part, and not known outside the IF statement in | |
720 | -- question. | |
fbf5a39b | 721 | -- |
758c442c GD |
722 | -- For an ELSIF, the condition is known true in the ELSIF part, known |
723 | -- FALSE in any subsequent ELSIF, or ELSE part, and not known before the | |
724 | -- ELSIF, or after the end of the IF statement. | |
fbf5a39b | 725 | -- |
758c442c GD |
726 | -- The caller can use this result to determine the value (for the case of |
727 | -- N_Op_Eq), or to determine the result of some other test in other cases | |
728 | -- (e.g. no access check required if N_Op_Ne Null). | |
fbf5a39b | 729 | |
3ebf0cbd | 730 | function Get_Index_Subtype (N : Node_Id) return Entity_Id; |
cf7cdde5 | 731 | -- Used for First, Last, and Length, when the prefix is an array type. |
3ebf0cbd PT |
732 | -- Obtains the corresponding index subtype. |
733 | ||
475e1d24 JM |
734 | function Get_Mapped_Entity (E : Entity_Id) return Entity_Id; |
735 | -- Return the mapped entity of E; used to check inherited class-wide | |
736 | -- pre/postconditions. | |
737 | ||
9eea4346 GB |
738 | function Get_Stream_Size (E : Entity_Id) return Uint; |
739 | -- Return the stream size value of the subtype E | |
740 | ||
df3e68b1 | 741 | function Has_Access_Constraint (E : Entity_Id) return Boolean; |
2c1b72d7 | 742 | -- Given object or type E, determine if a discriminant is of an access type |
df3e68b1 | 743 | |
39a7b603 EB |
744 | function Has_Tag_Of_Type (Exp : Node_Id) return Boolean; |
745 | -- Return True if expression Exp of a tagged type is known to statically | |
746 | -- have the tag of this tagged type as specified by RM 3.9(19-25). | |
747 | ||
c4f372c5 | 748 | function Homonym_Number (Subp : Entity_Id) return Pos; |
70482933 | 749 | -- Here subp is the entity for a subprogram. This routine returns the |
758c442c GD |
750 | -- homonym number used to disambiguate overloaded subprograms in the same |
751 | -- scope (the number is used as part of constructed names to make sure that | |
752 | -- they are unique). The number is the ordinal position on the Homonym | |
e14c931f | 753 | -- chain, counting only entries in the current scope. If an entity is not |
758c442c | 754 | -- overloaded, the returned number will be one. |
70482933 RK |
755 | |
756 | function Inside_Init_Proc return Boolean; | |
fbf5a39b | 757 | -- Returns True if current scope is within an init proc |
70482933 | 758 | |
df3e68b1 HK |
759 | function In_Library_Level_Package_Body (Id : Entity_Id) return Boolean; |
760 | -- Given an arbitrary entity, determine whether it appears at the library | |
761 | -- level of a package body. | |
762 | ||
70482933 | 763 | function In_Unconditional_Context (Node : Node_Id) return Boolean; |
758c442c | 764 | -- Node is the node for a statement or a component of a statement. This |
e14c931f | 765 | -- function determines if the statement appears in a context that is |
758c442c GD |
766 | -- unconditionally executed, i.e. it is not within a loop or a conditional |
767 | -- or a case statement etc. | |
70482933 | 768 | |
c7c7dd3a EB |
769 | function Integer_Type_For (S : Uint; Uns : Boolean) return Entity_Id; |
770 | -- Return a suitable standard integer type containing at least S bits and | |
94425248 | 771 | -- of the signedness given by Uns. See also Small_Integer_Type_For. |
c7c7dd3a | 772 | |
7caa6841 EB |
773 | function Is_Captured_Function_Call (N : Node_Id) return Boolean; |
774 | -- Return True if N is a captured function call, i.e. the result of calling | |
775 | -- Remove_Side_Effects on an N_Function_Call node: | |
776 | ||
777 | -- type Ann is access all Typ; | |
778 | -- Rnn : constant Ann := Func (...)'reference; | |
779 | -- Rnn.all | |
780 | ||
df3e68b1 HK |
781 | function Is_Finalizable_Transient |
782 | (Decl : Node_Id; | |
783 | Rel_Node : Node_Id) return Boolean; | |
784 | -- Determine whether declaration Decl denotes a controlled transient which | |
785 | -- should be finalized. Rel_Node is the related context. Even though some | |
7c4d86c9 | 786 | -- transients are controlled, they may act as renamings of other objects or |
df3e68b1 HK |
787 | -- function calls. |
788 | ||
6fb4cdde AC |
789 | function Is_Fully_Repped_Tagged_Type (T : Entity_Id) return Boolean; |
790 | -- Tests given type T, and returns True if T is a non-discriminated tagged | |
791 | -- type which has a record representation clause that specifies the layout | |
792 | -- of all the components, including recursively components in all parent | |
793 | -- types. We exclude discriminated types for convenience, it is extremely | |
794 | -- unlikely that the special processing associated with the use of this | |
795 | -- routine is useful for the case of a discriminated type, and testing for | |
796 | -- component overlap would be a pain. | |
797 | ||
c7732bbe EB |
798 | -- WARNING: There is a matching C declaration of this subprogram in fe.h |
799 | ||
86cde7b1 RD |
800 | function Is_Library_Level_Tagged_Type (Typ : Entity_Id) return Boolean; |
801 | -- Return True if Typ is a library level tagged type. Currently we use | |
802 | -- this information to build statically allocated dispatch tables. | |
803 | ||
df3e68b1 HK |
804 | function Is_Non_BIP_Func_Call (Expr : Node_Id) return Boolean; |
805 | -- Determine whether node Expr denotes a non build-in-place function call | |
806 | ||
cdc96e3e AC |
807 | function Is_Possibly_Unaligned_Object (N : Node_Id) return Boolean; |
808 | -- Node N is an object reference. This function returns True if it is | |
809 | -- possible that the object may not be aligned according to the normal | |
810 | -- default alignment requirement for its type (e.g. if it appears in a | |
811 | -- packed record, or as part of a component that has a component clause.) | |
812 | ||
813 | function Is_Possibly_Unaligned_Slice (N : Node_Id) return Boolean; | |
814 | -- Determine whether the node P is a slice of an array where the slice | |
815 | -- result may cause alignment problems because it has an alignment that | |
816 | -- is not compatible with the type. Return True if so. | |
817 | ||
f44fe430 | 818 | function Is_Ref_To_Bit_Packed_Array (N : Node_Id) return Boolean; |
758c442c GD |
819 | -- Determine whether the node P is a reference to a bit packed array, i.e. |
820 | -- whether the designated object is a component of a bit packed array, or a | |
821 | -- subcomponent of such a component. If so, then all subscripts in P are | |
822 | -- evaluated with a call to Force_Evaluation, and True is returned. | |
823 | -- Otherwise False is returned, and P is not affected. | |
70482933 | 824 | |
f44fe430 | 825 | function Is_Ref_To_Bit_Packed_Slice (N : Node_Id) return Boolean; |
758c442c GD |
826 | -- Determine whether the node P is a reference to a bit packed slice, i.e. |
827 | -- whether the designated object is bit packed slice or a component of a | |
828 | -- bit packed slice. Return True if so. | |
70482933 | 829 | |
df3e68b1 HK |
830 | function Is_Related_To_Func_Return (Id : Entity_Id) return Boolean; |
831 | -- Determine whether object Id is related to an expanded return statement. | |
832 | -- The case concerned is "return Id.all;". | |
833 | ||
de77a81b EB |
834 | -- This is effectively used to determine which temporaries generated for |
835 | -- return statements must be finalized because they are regular temporaries | |
836 | -- and which ones must not be since they are allocated on the return stack. | |
837 | ||
8be71a90 EB |
838 | -- WARNING: There is a matching C declaration of this subprogram in fe.h |
839 | ||
70482933 | 840 | function Is_Renamed_Object (N : Node_Id) return Boolean; |
758c442c GD |
841 | -- Returns True if the node N is a renamed object. An expression is |
842 | -- considered to be a renamed object if either it is the Name of an object | |
843 | -- renaming declaration, or is the prefix of a name which is a renamed | |
844 | -- object. For example, in: | |
70482933 RK |
845 | -- |
846 | -- x : r renames a (1 .. 2) (1); | |
847 | -- | |
758c442c GD |
848 | -- We consider that a (1 .. 2) is a renamed object since it is the prefix |
849 | -- of the name in the renaming declaration. | |
70482933 | 850 | |
cdc96e3e AC |
851 | function Is_Secondary_Stack_BIP_Func_Call (Expr : Node_Id) return Boolean; |
852 | -- Determine whether Expr denotes a build-in-place function which returns | |
853 | -- its result on the secondary stack. | |
854 | ||
89e037d0 EB |
855 | function Is_Secondary_Stack_Thunk (Id : Entity_Id) return Boolean; |
856 | -- Determine whether Id denotes a secondary stack thunk | |
857 | ||
858 | -- WARNING: There is a matching C declaration of this subprogram in fe.h | |
859 | ||
8517317c YM |
860 | function Is_Statically_Disabled |
861 | (N : Node_Id; | |
862 | Value : Boolean; | |
863 | Include_Valid : Boolean) | |
864 | return Boolean | |
865 | with Pre => Nkind (N) in N_Subexpr and then Is_Boolean_Type (Etype (N)); | |
866 | -- Returns whether N is a "statically disabled" condition which evaluates | |
867 | -- to Value, as described in section 7.3.2 of SPARK User's Guide. | |
868 | -- | |
869 | -- If Include_Valid is True, a reference to 'Valid or 'Valid_Scalar is | |
870 | -- considered as disabled for Value=True, which is useful in GNATprove, as | |
871 | -- proof considers that these attributes always return the value True. In | |
872 | -- general, Include_Valid is set to True in the proof phase of GNATprove, | |
873 | -- as 'Valid is assumed to always evaluate to True, but not in the flow | |
874 | -- analysis phase of GNATprove, which does not make this assumption. | |
875 | ||
70482933 RK |
876 | function Is_Untagged_Derivation (T : Entity_Id) return Boolean; |
877 | -- Returns true if type T is not tagged and is a derived type, | |
878 | -- or is a private type whose completion is such a type. | |
879 | ||
51148dda AC |
880 | function Is_Untagged_Private_Derivation |
881 | (Priv_Typ : Entity_Id; | |
882 | Full_Typ : Entity_Id) return Boolean; | |
883 | -- Determine whether private type Priv_Typ and its full view Full_Typ | |
884 | -- represent an untagged derivation from a private parent. | |
885 | ||
65df5b71 HK |
886 | function Is_Volatile_Reference (N : Node_Id) return Boolean; |
887 | -- Checks if the node N represents a volatile reference, which can be | |
888 | -- either a direct reference to a variable treated as volatile, or an | |
889 | -- indexed/selected component where the prefix is treated as volatile, | |
890 | -- or has Volatile_Components set. A slice of a volatile variable is | |
891 | -- also volatile. | |
892 | ||
05350ac6 | 893 | procedure Kill_Dead_Code (N : Node_Id; Warn : Boolean := False); |
ac4d6407 RD |
894 | -- N represents a node for a section of code that is known to be dead. Any |
895 | -- exception handler references and warning messages relating to this code | |
896 | -- are removed. If Warn is True, a warning will be output at the start of N | |
897 | -- indicating the deletion of the code. Note that the tree for the deleted | |
898 | -- code is left intact so that e.g. cross-reference data is still valid. | |
70482933 | 899 | |
05350ac6 | 900 | procedure Kill_Dead_Code (L : List_Id; Warn : Boolean := False); |
70482933 | 901 | -- Like the above procedure, but applies to every element in the given |
ac4d6407 RD |
902 | -- list. If Warn is True, a warning will be output at the start of N |
903 | -- indicating the deletion of the code. | |
70482933 | 904 | |
e606088a | 905 | function Make_Invariant_Call (Expr : Node_Id) return Node_Id; |
90e491a7 PMR |
906 | -- Generate a call to the Invariant_Procedure associated with the type of |
907 | -- expression Expr. Expr is passed as an actual parameter in the call. | |
4818e7b9 RD |
908 | |
909 | function Make_Predicate_Call | |
55a11c7e SB |
910 | (Typ : Entity_Id; |
911 | Expr : Node_Id; | |
912 | Static_Mem : Boolean := False; | |
913 | Dynamic_Mem : Node_Id := Empty) return Node_Id; | |
4818e7b9 RD |
914 | -- Typ is a type with Predicate_Function set. This routine builds a call to |
915 | -- this function passing Expr as the argument, and returns it unanalyzed. | |
55a11c7e SB |
916 | -- If the callee takes a second parameter (as determined by |
917 | -- Sem_Util.Predicate_Function_Needs_Membership_Parameter), then the | |
918 | -- actual parameter is determined by the two Mem parameters. | |
919 | -- If Dynamic_Mem is nonempty, then Dynamic_Mem is the actual parameter. | |
920 | -- Otherwise, the value of the Static_Mem parameter is passed in as | |
921 | -- a Boolean literal. It is an error if Dynamic_Mem is nonempty but | |
922 | -- the callee does not take a second parameter. | |
4818e7b9 RD |
923 | |
924 | function Make_Predicate_Check | |
925 | (Typ : Entity_Id; | |
926 | Expr : Node_Id) return Node_Id; | |
927 | -- Typ is a type with Predicate_Function set. This routine builds a Check | |
f1c80977 AC |
928 | -- pragma whose first argument is Predicate, and the second argument is |
929 | -- a call to the predicate function of Typ with Expr as the argument. If | |
930 | -- Predicate_Check is suppressed then a null statement is returned instead. | |
e606088a | 931 | |
70482933 | 932 | function Make_Subtype_From_Expr |
d9307840 HK |
933 | (E : Node_Id; |
934 | Unc_Typ : Entity_Id; | |
935 | Related_Id : Entity_Id := Empty) return Node_Id; | |
70482933 | 936 | -- Returns a subtype indication corresponding to the actual type of an |
d9307840 HK |
937 | -- expression E. Unc_Typ is an unconstrained array or record, or a class- |
938 | -- wide type. Set Related_Id to request an external name for the subtype | |
939 | -- rather than an internal temporary. | |
70482933 | 940 | |
af10c962 EB |
941 | function Make_Tag_Assignment_From_Type |
942 | (Loc : Source_Ptr; | |
943 | Target : Node_Id; | |
944 | Typ : Entity_Id) return Node_Id; | |
945 | -- Return an assignment of the tag of tagged type Typ to prefix Target, | |
946 | -- which must be a record object of a descendant of Typ. | |
947 | ||
afa1ffd4 PT |
948 | function Make_Variant_Comparison |
949 | (Loc : Source_Ptr; | |
93e7c91e | 950 | Typ : Entity_Id; |
afa1ffd4 PT |
951 | Mode : Name_Id; |
952 | Curr_Val : Node_Id; | |
953 | Old_Val : Node_Id) return Node_Id; | |
954 | -- Subsidiary to the expansion of pragmas Loop_Variant and | |
955 | -- Subprogram_Variant. Generate a comparison between Curr_Val and Old_Val | |
93e7c91e PT |
956 | -- depending on the variant mode (Increases / Decreases) using less or |
957 | -- greater operator for Typ. | |
afa1ffd4 | 958 | |
475e1d24 JM |
959 | procedure Map_Formals |
960 | (Parent_Subp : Entity_Id; | |
961 | Derived_Subp : Entity_Id; | |
962 | Force_Update : Boolean := False); | |
963 | -- Establish the mapping from the formals of Parent_Subp to the formals | |
964 | -- of Derived_Subp; if Force_Update is True then mapping of Parent_Subp to | |
965 | -- Derived_Subp is also updated; used to update mapping of late-overriding | |
966 | -- primitives of a tagged type. | |
967 | ||
b619c88e AC |
968 | procedure Map_Types (Parent_Type : Entity_Id; Derived_Type : Entity_Id); |
969 | -- Establish the following mapping between the attributes of tagged parent | |
970 | -- type Parent_Type and tagged derived type Derived_Type. | |
971 | -- | |
06fd120d | 972 | -- * Map each discriminant of Parent_Type to either the corresponding |
b619c88e AC |
973 | -- discriminant of Derived_Type or come constraint. |
974 | ||
975 | -- * Map each primitive operation of Parent_Type to the corresponding | |
976 | -- primitive of Derived_Type. | |
977 | -- | |
978 | -- The mapping Parent_Type -> Derived_Type is also added to the table in | |
979 | -- order to prevent subsequent attempts of the same mapping. | |
980 | ||
e03f7ccf AC |
981 | function Matching_Standard_Type (Typ : Entity_Id) return Entity_Id; |
982 | -- Given a scalar subtype Typ, returns a matching type in standard that | |
983 | -- has the same object size value. For example, a 16 bit signed type will | |
984 | -- typically return Standard_Short_Integer. For fixed-point types, this | |
985 | -- will return integer types of the corresponding size. | |
986 | ||
70482933 | 987 | function May_Generate_Large_Temp (Typ : Entity_Id) return Boolean; |
758c442c GD |
988 | -- Determines if the given type, Typ, may require a large temporary of the |
989 | -- kind that causes back-end trouble if stack checking is enabled. The | |
990 | -- result is True only the size of the type is known at compile time and | |
991 | -- large, where large is defined heuristically by the body of this routine. | |
992 | -- The purpose of this routine is to help avoid generating troublesome | |
993 | -- temporaries that interfere with stack checking mechanism. Note that the | |
994 | -- caller has to check whether stack checking is actually enabled in order | |
995 | -- to guide the expansion (typically of a function call). | |
70482933 | 996 | |
341e0bb6 JS |
997 | function Needs_Conditional_Null_Excluding_Check |
998 | (Typ : Entity_Id) return Boolean; | |
999 | -- Check if a type meets certain properties that require it to have a | |
1000 | -- conditional null-excluding check within its Init_Proc. | |
1001 | ||
0d901290 AC |
1002 | function Needs_Constant_Address |
1003 | (Decl : Node_Id; | |
1004 | Typ : Entity_Id) return Boolean; | |
1005 | -- Check whether the expression in an address clause is restricted to | |
31101470 | 1006 | -- consist of constants, when the object has a nontrivial initialization |
0d901290 AC |
1007 | -- or is controlled. |
1008 | ||
59e54267 ES |
1009 | function OK_To_Do_Constant_Replacement (E : Entity_Id) return Boolean; |
1010 | -- This function is used when testing whether or not to replace a reference | |
1011 | -- to entity E by a known constant value. Such replacement must be done | |
1012 | -- only in a scope known to be safe for such replacements. In particular, | |
1013 | -- if we are within a subprogram and the entity E is declared outside the | |
1014 | -- subprogram then we cannot do the replacement, since we do not attempt to | |
1015 | -- trace subprogram call flow. It is also unsafe to replace statically | |
1016 | -- allocated values (since they can be modified outside the scope), and we | |
1017 | -- also inhibit replacement of Volatile or aliased objects since their | |
1018 | -- address might be captured in a way we do not detect. A value of True is | |
1019 | -- returned only if the replacement is safe. | |
1020 | ||
65ea0024 EB |
1021 | function Possible_Bit_Aligned_Component |
1022 | (N : Node_Id; | |
1023 | For_Slice : Boolean := False) return Boolean; | |
fba9fcae EB |
1024 | -- This function is used during processing the assignment of a record or an |
1025 | -- array, or the construction of an aggregate. The argument N is either the | |
1026 | -- left or the right hand side of an assignment and the function determines | |
1027 | -- whether there is a record component reference where the component may be | |
1028 | -- bit aligned in a manner that causes trouble for the back end (see also | |
1029 | -- Component_May_Be_Bit_Aligned for further details). | |
0712790c | 1030 | |
2c9f8c0a AC |
1031 | function Power_Of_Two (N : Node_Id) return Nat; |
1032 | -- Determines if N is a known at compile time value which is of the form | |
1033 | -- 2**K, where K is in the range 1 .. M, where the Esize of N is 2**(M+1). | |
1034 | -- If so, returns the value K, otherwise returns zero. The caller checks | |
1035 | -- that N is of an integer type. | |
1036 | ||
87eb6d2c PT |
1037 | function Predicate_Check_In_Scope (N : Node_Id) return Boolean; |
1038 | -- Return True if predicate checks should be generated in the current | |
1039 | -- scope on the given node. Will return False for example when the current | |
1040 | -- scope is a predefined primitive operation. | |
1041 | ||
2ba7e31e AC |
1042 | procedure Process_Statements_For_Controlled_Objects (N : Node_Id); |
1043 | -- N is a node which contains a non-handled statement list. Inspect the | |
1044 | -- statements looking for declarations of controlled objects. If at least | |
1045 | -- one such object is found, wrap the statement list in a block. | |
1046 | ||
3a3af4c3 AC |
1047 | function Remove_Init_Call |
1048 | (Var : Entity_Id; | |
1049 | Rep_Clause : Node_Id) return Node_Id; | |
1050 | -- Look for init_proc call or aggregate initialization statements for | |
1051 | -- variable Var, either among declarations between that of Var and a | |
1052 | -- subsequent Rep_Clause applying to Var, or in the list of freeze actions | |
1053 | -- associated with Var, and if found, remove and return that call node. | |
1054 | ||
70482933 | 1055 | procedure Remove_Side_Effects |
89d3b1a1 AC |
1056 | (Exp : Node_Id; |
1057 | Name_Req : Boolean := False; | |
1058 | Renaming_Req : Boolean := False; | |
1059 | Variable_Ref : Boolean := False; | |
1060 | Related_Id : Entity_Id := Empty; | |
1061 | Is_Low_Bound : Boolean := False; | |
1062 | Is_High_Bound : Boolean := False; | |
325443d2 | 1063 | Discr_Number : Int := 0; |
89d3b1a1 | 1064 | Check_Side_Effects : Boolean := True); |
758c442c GD |
1065 | -- Given the node for a subexpression, this function replaces the node if |
1066 | -- necessary by an equivalent subexpression that is guaranteed to be side | |
1067 | -- effect free. This is done by extracting any actions that could cause | |
adb252d8 AC |
1068 | -- side effects, and inserting them using Insert_Actions into the tree |
1069 | -- to which Exp is attached. Exp must be analyzed and resolved before the | |
1070 | -- call and is analyzed and resolved on return. Name_Req may only be set to | |
758c442c | 1071 | -- True if Exp has the form of a name, and the effect is to guarantee that |
a43f6434 | 1072 | -- any replacement maintains the form of name. If Renaming_Req is set to |
22e89283 AC |
1073 | -- True, the routine produces an object renaming reclaration capturing the |
1074 | -- expression. If Variable_Ref is set to True, a variable is considered as | |
a43f6434 AC |
1075 | -- side effect (used in implementing Force_Evaluation). Note: after call to |
1076 | -- Remove_Side_Effects, it is safe to call New_Copy_Tree to obtain a copy | |
89d3b1a1 AC |
1077 | -- of the resulting expression. If Check_Side_Effects is set to True then |
1078 | -- no action is performed if Exp is known to be side-effect free. | |
2934b84a AC |
1079 | -- |
1080 | -- Related_Id denotes the entity of the context where Expr appears. Flags | |
1081 | -- Is_Low_Bound and Is_High_Bound specify whether the expression to check | |
1082 | -- is the low or the high bound of a range. These three optional arguments | |
1083 | -- signal Remove_Side_Effects to create an external symbol of the form | |
9fc0f672 | 1084 | -- Chars (Related_Id)_FIRST/_LAST. If Related_Id is set, then exactly one |
580d40e8 AC |
1085 | -- of the Is_xxx_Bound flags must be set. For use of these parameters see |
1086 | -- the warning in the body of Sem_Ch3.Process_Range_Expr_In_Decl. | |
22e89283 | 1087 | -- |
325443d2 ES |
1088 | -- If Discr_Number is positive, the expression denotes a discrimant value |
1089 | -- in a constraint, the suffix DISCR is used to create the external name. | |
1090 | ||
22e89283 AC |
1091 | -- The side effects are captured using one of the following methods: |
1092 | -- | |
1093 | -- 1) a constant initialized with the value of the subexpression | |
1094 | -- 2) a renaming of the subexpression | |
1095 | -- 3) a reference to the subexpression | |
1096 | -- | |
1097 | -- For elementary types, methods 1) and 2) are used; for composite types, | |
1098 | -- methods 2) and 3) are used. The renaming (method 2) is used only when | |
1099 | -- the subexpression denotes a name, so that it can be elaborated by gigi | |
1100 | -- without evaluating the subexpression. | |
1101 | -- | |
1102 | -- Historical note: the reference (method 3) used to be the common fallback | |
1103 | -- method but it gives rise to aliasing issues if the subexpression denotes | |
1104 | -- a name that is not aliased, since it is equivalent to taking the address | |
1105 | -- in this case. The renaming (method 2) used to be applied to any objects | |
1106 | -- in the RM sense, that is to say to the cases where a renaming is legal | |
1107 | -- in Ada. But for some of these cases, most notably functions calls, the | |
1108 | -- renaming cannot be elaborated without evaluating the subexpression, so | |
1109 | -- gigi would resort to method 1) or 3) under the hood for them. | |
70482933 | 1110 | |
b619c88e AC |
1111 | procedure Replace_References |
1112 | (Expr : Node_Id; | |
1113 | Par_Typ : Entity_Id; | |
1114 | Deriv_Typ : Entity_Id; | |
1115 | Par_Obj : Entity_Id := Empty; | |
1116 | Deriv_Obj : Entity_Id := Empty); | |
1117 | -- Expr denotes an arbitrary expression. Par_Typ is a tagged parent type | |
1118 | -- in a type hierarchy. Deriv_Typ is a tagged type derived from Par_Typ | |
1119 | -- with optional ancestors in between. Par_Obj is a formal parameter | |
1120 | -- which emulates the current instance of Par_Typ. Deriv_Obj is a formal | |
1121 | -- parameter which emulates the current instance of Deriv_Typ. Perform the | |
1122 | -- following substitutions in Expr: | |
1123 | -- | |
1124 | -- * Replace a reference to Par_Obj with a reference to Deriv_Obj | |
1125 | -- | |
1126 | -- * Replace a reference to a discriminant of Par_Typ with a suitable | |
1127 | -- value from the point of view of Deriv_Typ. | |
1128 | -- | |
1129 | -- * Replace a call to an overridden primitive of Par_Typ with a call to | |
1130 | -- an overriding primitive of Deriv_Typ. | |
1131 | -- | |
1132 | -- * Replace a call to an inherited primitive of Par_Type with a call to | |
1133 | -- the internally-generated inherited primitive of Deriv_Typ. | |
1134 | ||
1135 | procedure Replace_Type_References | |
b554177a AC |
1136 | (Expr : Node_Id; |
1137 | Typ : Entity_Id; | |
1138 | Obj_Id : Entity_Id); | |
b619c88e AC |
1139 | -- Substitute all references of the current instance of type Typ with |
1140 | -- references to formal parameter Obj_Id within expression Expr. | |
1141 | ||
f44fe430 RD |
1142 | function Represented_As_Scalar (T : Entity_Id) return Boolean; |
1143 | -- Returns True iff the implementation of this type in code generation | |
1144 | -- terms is scalar. This is true for scalars in the Ada sense, and for | |
1145 | -- packed arrays which are represented by a scalar (modular) type. | |
1146 | ||
fcf848c4 AC |
1147 | function Requires_Cleanup_Actions |
1148 | (N : Node_Id; | |
1149 | Lib_Level : Boolean) return Boolean; | |
87729e5a AC |
1150 | -- Given a node N, determine whether its declarative and/or statement list |
1151 | -- contains one of the following: | |
1152 | -- | |
1153 | -- 1) controlled objects | |
1154 | -- 2) library-level tagged types | |
1155 | -- | |
f2ef7a05 BD |
1156 | -- These cases require special actions on scope exit. Lib_Level is True if |
1157 | -- the construct is at library level, and False otherwise. | |
87729e5a | 1158 | |
70482933 | 1159 | function Safe_Unchecked_Type_Conversion (Exp : Node_Id) return Boolean; |
758c442c GD |
1160 | -- Given the node for an N_Unchecked_Type_Conversion, return True if this |
1161 | -- is an unchecked conversion that Gigi can handle directly. Otherwise | |
1162 | -- return False if it is one for which the front end must provide a | |
1163 | -- temporary. Note that the node need not be analyzed, and thus the Etype | |
1164 | -- field may not be set, but in that case it must be the case that the | |
1165 | -- Subtype_Mark field of the node is set/analyzed. | |
70482933 | 1166 | |
05350ac6 BD |
1167 | procedure Set_Current_Value_Condition (Cnode : Node_Id); |
1168 | -- Cnode is N_If_Statement, N_Elsif_Part, or N_Iteration_Scheme (the latter | |
1169 | -- when a WHILE condition is present). This call checks whether Condition | |
1170 | -- (Cnode) has embedded expressions of a form that should result in setting | |
1171 | -- the Current_Value field of one or more entities, and if so sets these | |
1172 | -- fields to point to Cnode. | |
1173 | ||
70482933 | 1174 | procedure Set_Elaboration_Flag (N : Node_Id; Spec_Id : Entity_Id); |
758c442c GD |
1175 | -- N is the node for a subprogram or generic body, and Spec_Id is the |
1176 | -- entity for the corresponding spec. If an elaboration entity is defined, | |
1177 | -- then this procedure generates an assignment statement to set it True, | |
1178 | -- immediately after the body is elaborated. However, no assignment is | |
1179 | -- generated in the case of library level procedures, since the setting of | |
1180 | -- the flag in this case is generated in the binder. We do that so that we | |
1181 | -- can detect cases where this is the only elaboration action that is | |
1182 | -- required. | |
70482933 | 1183 | |
59e54267 ES |
1184 | procedure Set_Renamed_Subprogram (N : Node_Id; E : Entity_Id); |
1185 | -- N is an node which is an entity name that represents the name of a | |
1186 | -- renamed subprogram. The node is rewritten to be an identifier that | |
1187 | -- refers directly to the renamed subprogram, given by entity E. | |
1188 | ||
adb252d8 AC |
1189 | function Side_Effect_Free |
1190 | (N : Node_Id; | |
1191 | Name_Req : Boolean := False; | |
1192 | Variable_Ref : Boolean := False) return Boolean; | |
1193 | -- Determines if the tree N represents an expression that is known not | |
1194 | -- to have side effects. If this function returns True, then for example | |
1195 | -- a call to Remove_Side_Effects has no effect. | |
1196 | -- | |
1197 | -- Name_Req controls the handling of volatile variable references. If | |
1198 | -- Name_Req is False (the normal case), then volatile references are | |
1199 | -- considered to be side effects. If Name_Req is True, then volatility | |
1200 | -- of variables is ignored. | |
1201 | -- | |
1202 | -- If Variable_Ref is True, then all variable references are considered to | |
1203 | -- be side effects (regardless of volatility or the setting of Name_Req). | |
1204 | ||
1205 | function Side_Effect_Free | |
1206 | (L : List_Id; | |
1207 | Name_Req : Boolean := False; | |
1208 | Variable_Ref : Boolean := False) return Boolean; | |
14c3ae9a | 1209 | -- Determines if all elements of the list L are side-effect free. Name_Req |
adb252d8 AC |
1210 | -- and Variable_Ref are as described above. |
1211 | ||
65df5b71 HK |
1212 | procedure Silly_Boolean_Array_Not_Test (N : Node_Id; T : Entity_Id); |
1213 | -- N is the node for a boolean array NOT operation, and T is the type of | |
1214 | -- the array. This routine deals with the silly case where the subtype of | |
1215 | -- the boolean array is False..False or True..True, where it is required | |
1216 | -- that a Constraint_Error exception be raised (RM 4.5.6(6)). | |
1217 | ||
076bbec1 | 1218 | procedure Silly_Boolean_Array_Xor_Test |
89beb653 HK |
1219 | (N : Node_Id; |
1220 | R : Node_Id; | |
1221 | T : Entity_Id); | |
076bbec1 ES |
1222 | -- N is the node for a boolean array XOR operation, T is the type of the |
1223 | -- array, and R is a copy of the right operand of N, required to prevent | |
1224 | -- scope anomalies when unnesting is in effect. This routine deals with | |
1225 | -- the admitedly silly case where the subtype of the boolean array is | |
1226 | -- True..True, where a raise of a Constraint_Error exception is required | |
1227 | -- (RM 4.5.6(6)) and ACATS-tested. | |
65df5b71 | 1228 | |
c7c7dd3a EB |
1229 | function Small_Integer_Type_For (S : Uint; Uns : Boolean) return Entity_Id; |
1230 | -- Return the smallest standard integer type containing at least S bits and | |
94425248 | 1231 | -- of the signedness given by Uns. See also Integer_Type_For. |
c7c7dd3a | 1232 | |
89e037d0 EB |
1233 | function Thunk_Target (Thunk : Entity_Id) return Entity_Id; |
1234 | -- Return the entity ultimately called by the thunk, that is to say return | |
1235 | -- the Thunk_Entity of the last member on the thunk chain. | |
1236 | ||
1237 | -- WARNING: There is a matching C declaration of this subprogram in fe.h | |
1238 | ||
91b1417d AC |
1239 | function Type_May_Have_Bit_Aligned_Components |
1240 | (Typ : Entity_Id) return Boolean; | |
758c442c | 1241 | -- Determines if Typ is a composite type that has within it (looking down |
fba9fcae EB |
1242 | -- recursively at subcomponents) a record which contains a component that |
1243 | -- may be bit aligned in a manner that causes trouble for the back end | |
1244 | -- (see also Component_May_Be_Bit_Aligned for further details). The result | |
758c442c GD |
1245 | -- is conservative, in that a result of False is decisive. A result of True |
1246 | -- means that such a component may or may not be present. | |
91b1417d | 1247 | |
f63d601b HK |
1248 | procedure Update_Primitives_Mapping |
1249 | (Inher_Id : Entity_Id; | |
1250 | Subp_Id : Entity_Id); | |
1251 | -- Map primitive operations of the parent type to the corresponding | |
1252 | -- operations of the descendant. Note that the descendant type may not be | |
1253 | -- frozen yet, so we cannot use the dispatch table directly. This is called | |
1254 | -- when elaborating a contract for a subprogram, and when freezing a type | |
1255 | -- extension to verify legality rules on inherited conditions. | |
1256 | ||
4c7e0990 | 1257 | function Within_Case_Or_If_Expression (N : Node_Id) return Boolean; |
985d6045 EB |
1258 | -- Determine whether arbitrary node N is immediately within a case or an if |
1259 | -- expression. The criterion is whether temporaries created by the actions | |
1260 | -- attached to N need to outlive an enclosing case or if expression. | |
4c7e0990 | 1261 | |
70482933 | 1262 | private |
70482933 | 1263 | pragma Inline (Duplicate_Subexpr); |
86cde7b1 | 1264 | pragma Inline (Force_Evaluation); |
475e1d24 | 1265 | pragma Inline (Get_Mapped_Entity); |
86cde7b1 | 1266 | pragma Inline (Is_Library_Level_Tagged_Type); |
89e037d0 EB |
1267 | pragma Inline (Is_Secondary_Stack_Thunk); |
1268 | pragma Inline (Thunk_Target); | |
70482933 | 1269 | end Exp_Util; |