]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ada/einfo-utils.ads
Correct a function pre/postcondition [PR102403].
[thirdparty/gcc.git] / gcc / ada / einfo-utils.ads
CommitLineData
76f9c7f4
BD
1------------------------------------------------------------------------------
2-- --
3-- GNAT COMPILER COMPONENTS --
4-- --
5-- E I N F O . U T I L S --
6-- --
7-- S p e c --
8-- --
9-- Copyright (C) 2020-2021, Free Software Foundation, Inc. --
10-- --
11-- GNAT is free software; you can redistribute it and/or modify it under --
12-- terms of the GNU General Public License as published by the Free Soft- --
13-- ware Foundation; either version 3, or (at your option) any later ver- --
14-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17-- for more details. You should have received a copy of the GNU General --
18-- Public License distributed with GNAT; see file COPYING3. If not, go to --
19-- http://www.gnu.org/licenses for a complete copy of the license. --
20-- --
21-- GNAT was originally developed by the GNAT team at New York University. --
22-- Extensive contributions were provided by Ada Core Technologies Inc. --
23-- --
24------------------------------------------------------------------------------
25
26with Einfo.Entities; use Einfo.Entities;
27
28package Einfo.Utils is
29
30 -----------------------------------
31 -- Renamings of Renamed_Or_Alias --
32 -----------------------------------
33
34 -- See the comment in einfo.ads, "Renaming and Aliasing", which is somewhat
35 -- incorrect. In fact, the compiler uses Alias, Renamed_Entity, and
36 -- Renamed_Object more-or-less interchangeably, so we rename them here.
a7cadd18 37 -- Alias isn't really renamed, because we want an assertion in the body.
76f9c7f4 38
a7cadd18
BD
39 function Alias (N : Entity_Id) return Node_Id;
40 procedure Set_Alias (N : Entity_Id; Val : Node_Id);
76f9c7f4
BD
41 function Renamed_Entity
42 (N : Entity_Id) return Node_Id renames Renamed_Or_Alias;
43 procedure Set_Renamed_Entity
44 (N : Entity_Id; Val : Node_Id) renames Set_Renamed_Or_Alias;
45 function Renamed_Object
46 (N : Entity_Id) return Node_Id renames Renamed_Or_Alias;
47 procedure Set_Renamed_Object
48 (N : Entity_Id; Val : Node_Id) renames Set_Renamed_Or_Alias;
49
a7cadd18
BD
50 pragma Inline (Alias);
51 pragma Inline (Set_Alias);
52 pragma Inline (Renamed_Entity);
53 pragma Inline (Set_Renamed_Entity);
54 pragma Inline (Renamed_Object);
55 pragma Inline (Set_Renamed_Object);
76f9c7f4
BD
56
57 -------------------
58 -- Type Synonyms --
59 -------------------
60
61 -- The following type synonyms are used to tidy up the function and
a7cadd18 62 -- procedure declarations that follow.
76f9c7f4
BD
63
64 subtype B is Boolean;
65 subtype C is Component_Alignment_Kind;
66 subtype E is Entity_Id;
67 subtype F is Float_Rep_Kind;
68 subtype M is Mechanism_Type;
69 subtype N is Node_Id;
70 subtype U is Uint;
71 subtype R is Ureal;
72 subtype L is Elist_Id;
73 subtype S is List_Id;
74
75 -------------------------------
76 -- Classification Attributes --
77 -------------------------------
78
79 -- These functions provide a convenient functional notation for testing
80 -- whether an Ekind value belongs to a specified kind, for example the
81 -- function Is_Elementary_Type tests if its argument is in Elementary_Kind.
82 -- In some cases, the test is of an entity attribute (e.g. in the case of
83 -- Is_Generic_Type where the Ekind does not provide the needed
84 -- information).
76f9c7f4
BD
85
86 function Is_Access_Object_Type (Id : E) return B;
87 function Is_Access_Type (Id : E) return B;
88 function Is_Access_Protected_Subprogram_Type (Id : E) return B;
89 function Is_Access_Subprogram_Type (Id : E) return B;
90 function Is_Aggregate_Type (Id : E) return B;
91 function Is_Anonymous_Access_Type (Id : E) return B;
92 function Is_Array_Type (Id : E) return B;
93 function Is_Assignable (Id : E) return B;
94 function Is_Class_Wide_Type (Id : E) return B;
95 function Is_Composite_Type (Id : E) return B;
96 function Is_Concurrent_Body (Id : E) return B;
97 function Is_Concurrent_Type (Id : E) return B;
98 function Is_Decimal_Fixed_Point_Type (Id : E) return B;
99 function Is_Digits_Type (Id : E) return B;
100 function Is_Discrete_Or_Fixed_Point_Type (Id : E) return B;
101 function Is_Discrete_Type (Id : E) return B;
102 function Is_Elementary_Type (Id : E) return B;
103 function Is_Entry (Id : E) return B;
104 function Is_Enumeration_Type (Id : E) return B;
105 function Is_Fixed_Point_Type (Id : E) return B;
106 function Is_Floating_Point_Type (Id : E) return B;
107 function Is_Formal (Id : E) return B;
108 function Is_Formal_Object (Id : E) return B;
109 function Is_Generic_Subprogram (Id : E) return B;
110 function Is_Generic_Unit (Id : E) return B;
111 function Is_Ghost_Entity (Id : E) return B;
112 function Is_Incomplete_Or_Private_Type (Id : E) return B;
113 function Is_Incomplete_Type (Id : E) return B;
114 function Is_Integer_Type (Id : E) return B;
115 function Is_Modular_Integer_Type (Id : E) return B;
116 function Is_Named_Access_Type (Id : E) return B;
117 function Is_Named_Number (Id : E) return B;
118 function Is_Numeric_Type (Id : E) return B;
119 function Is_Object (Id : E) return B;
120 function Is_Ordinary_Fixed_Point_Type (Id : E) return B;
121 function Is_Overloadable (Id : E) return B;
122 function Is_Private_Type (Id : E) return B;
123 function Is_Protected_Type (Id : E) return B;
124 function Is_Real_Type (Id : E) return B;
125 function Is_Record_Type (Id : E) return B;
126 function Is_Scalar_Type (Id : E) return B;
127 function Is_Signed_Integer_Type (Id : E) return B;
128 function Is_Subprogram (Id : E) return B;
129 function Is_Subprogram_Or_Entry (Id : E) return B;
130 function Is_Subprogram_Or_Generic_Subprogram (Id : E) return B;
131 function Is_Task_Type (Id : E) return B;
132 function Is_Type (Id : E) return B;
133
77804c9a
EB
134 pragma Inline (Is_Access_Object_Type);
135 pragma Inline (Is_Access_Type);
136 pragma Inline (Is_Access_Protected_Subprogram_Type);
137 pragma Inline (Is_Access_Subprogram_Type);
138 pragma Inline (Is_Aggregate_Type);
139 pragma Inline (Is_Anonymous_Access_Type);
140 pragma Inline (Is_Array_Type);
141 pragma Inline (Is_Assignable);
142 pragma Inline (Is_Class_Wide_Type);
143 pragma Inline (Is_Composite_Type);
144 pragma Inline (Is_Concurrent_Body);
145 pragma Inline (Is_Concurrent_Type);
146 pragma Inline (Is_Decimal_Fixed_Point_Type);
147 pragma Inline (Is_Digits_Type);
148 pragma Inline (Is_Discrete_Type);
149 pragma Inline (Is_Elementary_Type);
150 pragma Inline (Is_Entry);
151 pragma Inline (Is_Enumeration_Type);
152 pragma Inline (Is_Fixed_Point_Type);
153 pragma Inline (Is_Floating_Point_Type);
154 pragma Inline (Is_Formal);
155 pragma Inline (Is_Formal_Object);
156 pragma Inline (Is_Generic_Subprogram);
157 pragma Inline (Is_Generic_Unit);
158 pragma Inline (Is_Ghost_Entity);
159 pragma Inline (Is_Incomplete_Or_Private_Type);
160 pragma Inline (Is_Incomplete_Type);
161 pragma Inline (Is_Integer_Type);
162 pragma Inline (Is_Modular_Integer_Type);
163 pragma Inline (Is_Named_Access_Type);
164 pragma Inline (Is_Named_Number);
165 pragma Inline (Is_Numeric_Type);
166 pragma Inline (Is_Object);
167 pragma Inline (Is_Ordinary_Fixed_Point_Type);
168 pragma Inline (Is_Overloadable);
169 pragma Inline (Is_Private_Type);
170 pragma Inline (Is_Protected_Type);
171 pragma Inline (Is_Real_Type);
172 pragma Inline (Is_Record_Type);
173 pragma Inline (Is_Scalar_Type);
174 pragma Inline (Is_Signed_Integer_Type);
175 pragma Inline (Is_Subprogram);
176 pragma Inline (Is_Subprogram_Or_Entry);
177 pragma Inline (Is_Subprogram_Or_Generic_Subprogram);
178 pragma Inline (Is_Task_Type);
179 pragma Inline (Is_Type);
180
76f9c7f4
BD
181 -------------------------------------
182 -- Synthesized Attribute Functions --
183 -------------------------------------
184
185 -- The functions in this section synthesize attributes from the tree,
186 -- so they do not correspond to defined fields in the entity itself.
187
188 function Address_Clause (Id : E) return N;
189 function Aft_Value (Id : E) return U;
190 function Alignment_Clause (Id : E) return N;
191 function Base_Type (Id : E) return E;
192 function Declaration_Node (Id : E) return N;
193 function Designated_Type (Id : E) return E;
194 function Entry_Index_Type (Id : E) return E;
195 function First_Component (Id : E) return E;
196 function First_Component_Or_Discriminant (Id : E) return E;
197 function First_Formal (Id : E) return E;
198 function First_Formal_With_Extras (Id : E) return E;
9324e07d
BD
199
200 function Float_Rep
201 (N : Entity_Id) return F with Inline, Pre =>
202 N in E_Void_Id
203 | Float_Kind_Id;
204 procedure Set_Float_Rep
205 (Ignore_N : Entity_Id; Ignore_Val : F) with Inline, Pre =>
206 Ignore_N in E_Void_Id
207 | Float_Kind_Id;
208
76f9c7f4
BD
209 function Has_Attach_Handler (Id : E) return B;
210 function Has_DIC (Id : E) return B;
211 function Has_Entries (Id : E) return B;
212 function Has_Foreign_Convention (Id : E) return B;
213 function Has_Interrupt_Handler (Id : E) return B;
214 function Has_Invariants (Id : E) return B;
215 function Has_Limited_View (Id : E) return B;
216 function Has_Non_Limited_View (Id : E) return B;
217 function Has_Non_Null_Abstract_State (Id : E) return B;
218 function Has_Non_Null_Visible_Refinement (Id : E) return B;
219 function Has_Null_Abstract_State (Id : E) return B;
220 function Has_Null_Visible_Refinement (Id : E) return B;
221 function Implementation_Base_Type (Id : E) return E;
222 function Is_Base_Type (Id : E) return B;
a7cadd18 223 -- Note that Is_Base_Type returns True for nontypes
76f9c7f4
BD
224 function Is_Boolean_Type (Id : E) return B;
225 function Is_Constant_Object (Id : E) return B;
226 function Is_Controlled (Id : E) return B;
227 function Is_Discriminal (Id : E) return B;
228 function Is_Dynamic_Scope (Id : E) return B;
229 function Is_Elaboration_Target (Id : E) return B;
230 function Is_External_State (Id : E) return B;
231 function Is_Finalizer (Id : E) return B;
232 function Is_Full_Access (Id : E) return B;
233 function Is_Null_State (Id : E) return B;
234 function Is_Package_Or_Generic_Package (Id : E) return B;
235 function Is_Packed_Array (Id : E) return B;
236 function Is_Prival (Id : E) return B;
237 function Is_Protected_Component (Id : E) return B;
238 function Is_Protected_Interface (Id : E) return B;
239 function Is_Protected_Record_Type (Id : E) return B;
240 function Is_Relaxed_Initialization_State (Id : E) return B;
241 function Is_Standard_Character_Type (Id : E) return B;
242 function Is_Standard_String_Type (Id : E) return B;
243 function Is_String_Type (Id : E) return B;
244 function Is_Synchronized_Interface (Id : E) return B;
245 function Is_Synchronized_State (Id : E) return B;
246 function Is_Task_Interface (Id : E) return B;
247 function Is_Task_Record_Type (Id : E) return B;
248 function Is_Wrapper_Package (Id : E) return B;
249 function Last_Formal (Id : E) return E;
250 function Machine_Emax_Value (Id : E) return U;
251 function Machine_Emin_Value (Id : E) return U;
252 function Machine_Mantissa_Value (Id : E) return U;
253 function Machine_Radix_Value (Id : E) return U;
254 function Model_Emin_Value (Id : E) return U;
255 function Model_Epsilon_Value (Id : E) return R;
256 function Model_Mantissa_Value (Id : E) return U;
257 function Model_Small_Value (Id : E) return R;
258 function Next_Component (Id : E) return E;
259 function Next_Component_Or_Discriminant (Id : E) return E;
260 function Next_Discriminant (Id : E) return E;
261 function Next_Formal (Id : E) return E;
262 function Next_Formal_With_Extras (Id : E) return E;
263 function Next_Index (Id : N) return N;
264 function Next_Literal (Id : E) return E;
265 function Next_Stored_Discriminant (Id : E) return E;
266 function Number_Dimensions (Id : E) return Pos;
267 function Number_Entries (Id : E) return Nat;
268 function Number_Formals (Id : E) return Pos;
269 function Object_Size_Clause (Id : E) return N;
270 function Parameter_Mode (Id : E) return Formal_Kind;
271 function Partial_Refinement_Constituents (Id : E) return L;
272 function Primitive_Operations (Id : E) return L;
273 function Root_Type (Id : E) return E;
274 function Safe_Emax_Value (Id : E) return U;
275 function Safe_First_Value (Id : E) return R;
276 function Safe_Last_Value (Id : E) return R;
277 function Scope_Depth (Id : E) return U;
278 function Scope_Depth_Set (Id : E) return B;
279 function Size_Clause (Id : E) return N;
280 function Stream_Size_Clause (Id : E) return N;
281 function Type_High_Bound (Id : E) return N;
282 function Type_Low_Bound (Id : E) return N;
283 function Underlying_Type (Id : E) return E;
284
77804c9a
EB
285 pragma Inline (Address_Clause);
286 pragma Inline (Alignment_Clause);
287 pragma Inline (Base_Type);
288 pragma Inline (Has_Foreign_Convention);
289 pragma Inline (Has_Non_Limited_View);
290 pragma Inline (Is_Base_Type);
291 pragma Inline (Is_Boolean_Type);
292 pragma Inline (Is_Constant_Object);
293 pragma Inline (Is_Controlled);
294 pragma Inline (Is_Discriminal);
295 pragma Inline (Is_Finalizer);
296 pragma Inline (Is_Full_Access);
297 pragma Inline (Is_Null_State);
298 pragma Inline (Is_Package_Or_Generic_Package);
299 pragma Inline (Is_Packed_Array);
300 pragma Inline (Is_Prival);
301 pragma Inline (Is_Protected_Component);
302 pragma Inline (Is_Protected_Record_Type);
303 pragma Inline (Is_String_Type);
304 pragma Inline (Is_Task_Record_Type);
305 pragma Inline (Is_Wrapper_Package);
306 pragma Inline (Scope_Depth);
307 pragma Inline (Scope_Depth_Set);
308 pragma Inline (Size_Clause);
309 pragma Inline (Stream_Size_Clause);
310 pragma Inline (Type_High_Bound);
311 pragma Inline (Type_Low_Bound);
312
76f9c7f4
BD
313 ----------------------------------------------
314 -- Type Representation Attribute Predicates --
315 ----------------------------------------------
316
8de68eb3
BD
317 -- These predicates test the setting of the indicated attribute. The
318 -- Known predicate is True if and only if the value has been set. The
319 -- Known_Static predicate is True only if the value is set (Known) and is
320 -- set to a compile time known value. Note that in the case of Alignment
321 -- and Normalized_First_Bit, dynamic values are not possible, so we do not
76f9c7f4
BD
322 -- need a separate Known_Static calls in these cases. The not set (unknown)
323 -- values are as follows:
324
325 -- Alignment Uint_0 or No_Uint
326 -- Component_Size Uint_0 or No_Uint
327 -- Component_Bit_Offset No_Uint
328 -- Digits_Value Uint_0 or No_Uint
329 -- Esize Uint_0 or No_Uint
330 -- Normalized_First_Bit No_Uint
331 -- Normalized_Position No_Uint
332 -- Normalized_Position_Max No_Uint
333 -- RM_Size Uint_0 or No_Uint
334
335 -- It would be cleaner to use No_Uint in all these cases, but historically
336 -- we chose to use Uint_0 at first, and the change over will take time ???
337 -- This is particularly true for the RM_Size field, where a value of zero
338 -- is legitimate. We deal with this by a considering that the value is
339 -- always known static for discrete types (and no other types can have
340 -- an RM_Size value of zero).
341
342 -- In two cases, Known_Static_Esize and Known_Static_RM_Size, there is one
343 -- more consideration, which is that we always return False for generic
344 -- types. Within a template, the size can look known, because of the fake
345 -- size values we put in template types, but they are not really known and
346 -- anyone testing if they are known within the template should get False as
347 -- a result to prevent incorrect assumptions.
348
349 function Known_Alignment (E : Entity_Id) return B;
350 function Known_Component_Bit_Offset (E : Entity_Id) return B;
351 function Known_Component_Size (E : Entity_Id) return B;
352 function Known_Esize (E : Entity_Id) return B;
353 function Known_Normalized_First_Bit (E : Entity_Id) return B;
354 function Known_Normalized_Position (E : Entity_Id) return B;
355 function Known_Normalized_Position_Max (E : Entity_Id) return B;
356 function Known_RM_Size (E : Entity_Id) return B;
357
358 function Known_Static_Component_Bit_Offset (E : Entity_Id) return B;
359 function Known_Static_Component_Size (E : Entity_Id) return B;
360 function Known_Static_Esize (E : Entity_Id) return B;
361 function Known_Static_Normalized_First_Bit (E : Entity_Id) return B;
362 function Known_Static_Normalized_Position (E : Entity_Id) return B;
363 function Known_Static_Normalized_Position_Max (E : Entity_Id) return B;
364 function Known_Static_RM_Size (E : Entity_Id) return B;
365
77804c9a
EB
366 pragma Inline (Known_Alignment);
367 pragma Inline (Known_Component_Bit_Offset);
368 pragma Inline (Known_Component_Size);
369 pragma Inline (Known_Esize);
370 pragma Inline (Known_Normalized_First_Bit);
371 pragma Inline (Known_Normalized_Position);
372 pragma Inline (Known_Normalized_Position_Max);
373 pragma Inline (Known_RM_Size);
374
375 pragma Inline (Known_Static_Component_Bit_Offset);
376 pragma Inline (Known_Static_Component_Size);
377 pragma Inline (Known_Static_Esize);
378 pragma Inline (Known_Static_Normalized_First_Bit);
379 pragma Inline (Known_Static_Normalized_Position);
380 pragma Inline (Known_Static_Normalized_Position_Max);
381 pragma Inline (Known_Static_RM_Size);
382
76f9c7f4
BD
383 ---------------------------------------------------
384 -- Access to Subprograms in Subprograms_For_Type --
385 ---------------------------------------------------
386
a7cadd18
BD
387 -- Now that we have variable-sized nodes, it might be possible to replace
388 -- the following with regular fields, and get rid of the flags used to mark
389 -- these kinds of subprograms.
390
391 function Is_Partial_DIC_Procedure (Id : E) return B;
76f9c7f4
BD
392
393 function DIC_Procedure (Id : E) return E;
394 function Partial_DIC_Procedure (Id : E) return E;
395 function Invariant_Procedure (Id : E) return E;
396 function Partial_Invariant_Procedure (Id : E) return E;
397 function Predicate_Function (Id : E) return E;
398 function Predicate_Function_M (Id : E) return E;
399
400 procedure Set_DIC_Procedure (Id : E; V : E);
401 procedure Set_Partial_DIC_Procedure (Id : E; V : E);
402 procedure Set_Invariant_Procedure (Id : E; V : E);
403 procedure Set_Partial_Invariant_Procedure (Id : E; V : E);
404 procedure Set_Predicate_Function (Id : E; V : E);
405 procedure Set_Predicate_Function_M (Id : E; V : E);
406
407 -----------------------------------
408 -- Field Initialization Routines --
409 -----------------------------------
410
411 -- These routines are overloadings of some of the above Set procedures
412 -- where the argument is normally a Uint. The overloadings take an Int
413 -- parameter instead, and appropriately convert it. There are also
414 -- versions that implicitly initialize to the appropriate "not set"
415 -- value. The not set (unknown) values are as follows:
416
417 -- Alignment Uint_0
418 -- Component_Size Uint_0
419 -- Component_Bit_Offset No_Uint
420 -- Digits_Value Uint_0
421 -- Esize Uint_0
422 -- Normalized_First_Bit No_Uint
423 -- Normalized_Position No_Uint
424 -- Normalized_Position_Max No_Uint
425 -- RM_Size Uint_0
426
427 -- It would be cleaner to use No_Uint in all these cases, but historically
428 -- we chose to use Uint_0 at first, and the change over will take time ???
429 -- This is particularly true for the RM_Size field, where a value of zero
430 -- is legitimate and causes some special tests around the code.
431
432 -- Contrary to the corresponding Set procedures above, these routines
433 -- do NOT check the entity kind of their argument, instead they set the
434 -- underlying Uint fields directly (this allows them to be used for
435 -- entities whose Ekind has not been set yet).
436
437 procedure Init_Alignment (Id : E; V : Int);
438 procedure Init_Component_Bit_Offset (Id : E; V : Int);
439 procedure Init_Component_Size (Id : E; V : Int);
440 procedure Init_Digits_Value (Id : E; V : Int);
441 procedure Init_Esize (Id : E; V : Int);
442 procedure Init_Normalized_First_Bit (Id : E; V : Int);
443 procedure Init_Normalized_Position (Id : E; V : Int);
444 procedure Init_Normalized_Position_Max (Id : E; V : Int);
445 procedure Init_RM_Size (Id : E; V : Int);
446
447 procedure Init_Alignment (Id : E);
448 procedure Init_Component_Bit_Offset (Id : E);
449 procedure Init_Component_Size (Id : E);
450 procedure Init_Digits_Value (Id : E);
451 procedure Init_Esize (Id : E);
452 procedure Init_Normalized_First_Bit (Id : E);
453 procedure Init_Normalized_Position (Id : E);
454 procedure Init_Normalized_Position_Max (Id : E);
455 procedure Init_RM_Size (Id : E);
456
0c8ff35e
BD
457 -- The following Copy_xxx procedures copy the value of xxx from From to
458 -- To. If xxx is set to its initial invalid (zero-bits) value, then it is
459 -- reset to invalid in To. We only have Copy_Alignment so far, but more are
460 -- planned.
461
462 procedure Copy_Alignment (To, From : E);
463
77804c9a
EB
464 pragma Inline (Init_Alignment);
465 pragma Inline (Init_Component_Bit_Offset);
466 pragma Inline (Init_Component_Size);
467 pragma Inline (Init_Digits_Value);
468 pragma Inline (Init_Esize);
469 pragma Inline (Init_Normalized_First_Bit);
470 pragma Inline (Init_Normalized_Position);
471 pragma Inline (Init_Normalized_Position_Max);
472 pragma Inline (Init_RM_Size);
473
76f9c7f4
BD
474 procedure Init_Component_Location (Id : E);
475 -- Initializes all fields describing the location of a component
476 -- (Normalized_Position, Component_Bit_Offset, Normalized_First_Bit,
477 -- Normalized_Position_Max, Esize) to all be Unknown.
478
479 procedure Init_Size (Id : E; V : Int);
480 -- Initialize both the Esize and RM_Size fields of E to V
481
482 procedure Init_Size_Align (Id : E);
483 -- This procedure initializes both size fields and the alignment
484 -- field to all be Unknown.
485
486 procedure Init_Object_Size_Align (Id : E);
487 -- Same as Init_Size_Align except RM_Size field (which is only for types)
488 -- is unaffected.
489
490 ---------------
491 -- Iterators --
492 ---------------
493
494 -- The call to Next_xxx (obj) is equivalent to obj := Next_xxx (obj)
495 -- We define the set of Proc_Next_xxx routines simply for the purposes
496 -- of inlining them without necessarily inlining the function.
497
498 procedure Proc_Next_Component (N : in out Node_Id);
499 procedure Proc_Next_Component_Or_Discriminant (N : in out Node_Id);
500 procedure Proc_Next_Discriminant (N : in out Node_Id);
501 procedure Proc_Next_Formal (N : in out Node_Id);
502 procedure Proc_Next_Formal_With_Extras (N : in out Node_Id);
503 procedure Proc_Next_Index (N : in out Node_Id);
504 procedure Proc_Next_Inlined_Subprogram (N : in out Node_Id);
505 procedure Proc_Next_Literal (N : in out Node_Id);
506 procedure Proc_Next_Stored_Discriminant (N : in out Node_Id);
507
508 pragma Inline (Proc_Next_Component);
509 pragma Inline (Proc_Next_Component_Or_Discriminant);
510 pragma Inline (Proc_Next_Discriminant);
511 pragma Inline (Proc_Next_Formal);
512 pragma Inline (Proc_Next_Formal_With_Extras);
513 pragma Inline (Proc_Next_Index);
514 pragma Inline (Proc_Next_Inlined_Subprogram);
515 pragma Inline (Proc_Next_Literal);
516 pragma Inline (Proc_Next_Stored_Discriminant);
517
518 procedure Next_Component (N : in out Node_Id)
519 renames Proc_Next_Component;
520
521 procedure Next_Component_Or_Discriminant (N : in out Node_Id)
522 renames Proc_Next_Component_Or_Discriminant;
523
524 procedure Next_Discriminant (N : in out Node_Id)
525 renames Proc_Next_Discriminant;
526
527 procedure Next_Formal (N : in out Node_Id)
528 renames Proc_Next_Formal;
529
530 procedure Next_Formal_With_Extras (N : in out Node_Id)
531 renames Proc_Next_Formal_With_Extras;
532
533 procedure Next_Index (N : in out Node_Id)
534 renames Proc_Next_Index;
535
536 procedure Next_Inlined_Subprogram (N : in out Node_Id)
537 renames Proc_Next_Inlined_Subprogram;
538
539 procedure Next_Literal (N : in out Node_Id)
540 renames Proc_Next_Literal;
541
542 procedure Next_Stored_Discriminant (N : in out Node_Id)
543 renames Proc_Next_Stored_Discriminant;
544
545 ---------------------------
546 -- Testing Warning Flags --
547 ---------------------------
548
549 -- These routines are to be used rather than testing flags Warnings_Off,
550 -- Has_Pragma_Unmodified, Has_Pragma_Unreferenced. They deal with setting
551 -- the flags Warnings_Off_Used[_Unmodified|Unreferenced] for later access.
552
553 function Has_Warnings_Off (E : Entity_Id) return Boolean;
554 -- If Warnings_Off is set on E, then returns True and also sets the flag
555 -- Warnings_Off_Used on E. If Warnings_Off is not set on E, returns False
556 -- and has no side effect.
557
558 function Has_Unmodified (E : Entity_Id) return Boolean;
559 -- If flag Has_Pragma_Unmodified is set on E, returns True with no side
560 -- effects. Otherwise if Warnings_Off is set on E, returns True and also
561 -- sets the flag Warnings_Off_Used_Unmodified on E. If neither of the flags
562 -- Warnings_Off nor Has_Pragma_Unmodified is set, returns False with no
563 -- side effects.
564
565 function Has_Unreferenced (E : Entity_Id) return Boolean;
566 -- If flag Has_Pragma_Unreferenced is set on E, returns True with no side
567 -- effects. Otherwise if Warnings_Off is set on E, returns True and also
568 -- sets the flag Warnings_Off_Used_Unreferenced on E. If neither of the
569 -- flags Warnings_Off nor Has_Pragma_Unreferenced is set, returns False
570 -- with no side effects.
571
572 ----------------------------------------------
573 -- Subprograms for Accessing Rep Item Chain --
574 ----------------------------------------------
575
576 -- The First_Rep_Item field of every entity points to a linked list (linked
577 -- through Next_Rep_Item) of representation pragmas, attribute definition
578 -- clauses, representation clauses, and aspect specifications that apply to
579 -- the item. Note that in the case of types, it is assumed that any such
580 -- rep items for a base type also apply to all subtypes. This is achieved
581 -- by having the chain for subtypes link onto the chain for the base type,
582 -- so that new entries for the subtype are added at the start of the chain.
583 --
584 -- Note: aspect specification nodes are linked only when evaluation of the
585 -- expression is deferred to the freeze point. For further details see
586 -- Sem_Ch13.Analyze_Aspect_Specifications.
587
588 function Get_Attribute_Definition_Clause
589 (E : Entity_Id;
590 Id : Attribute_Id) return Node_Id;
591 -- Searches the Rep_Item chain for a given entity E, for an instance of an
592 -- attribute definition clause with the given attribute Id. If found, the
593 -- value returned is the N_Attribute_Definition_Clause node, otherwise
594 -- Empty is returned.
595
596 -- WARNING: There is a matching C declaration of this subprogram in fe.h
597
598 function Get_Pragma (E : Entity_Id; Id : Pragma_Id) return Node_Id;
599 -- Searches the Rep_Item chain of entity E, for an instance of a pragma
600 -- with the given pragma Id. If found, the value returned is the N_Pragma
601 -- node, otherwise Empty is returned. The following contract pragmas that
602 -- appear in N_Contract nodes are also handled by this routine:
603 -- Abstract_State
604 -- Async_Readers
605 -- Async_Writers
606 -- Attach_Handler
607 -- Constant_After_Elaboration
608 -- Contract_Cases
609 -- Depends
610 -- Effective_Reads
611 -- Effective_Writes
612 -- Global
613 -- Initial_Condition
614 -- Initializes
615 -- Interrupt_Handler
616 -- No_Caching
617 -- Part_Of
618 -- Precondition
619 -- Postcondition
620 -- Refined_Depends
621 -- Refined_Global
622 -- Refined_Post
623 -- Refined_State
624 -- Subprogram_Variant
625 -- Test_Case
626 -- Volatile_Function
627
628 function Get_Class_Wide_Pragma
629 (E : Entity_Id;
630 Id : Pragma_Id) return Node_Id;
631 -- Examine Rep_Item chain to locate a classwide pre- or postcondition of a
632 -- primitive operation. Returns Empty if not present.
633
634 function Get_Record_Representation_Clause (E : Entity_Id) return Node_Id;
635 -- Searches the Rep_Item chain for a given entity E, for a record
636 -- representation clause, and if found, returns it. Returns Empty
637 -- if no such clause is found.
638
639 function Present_In_Rep_Item (E : Entity_Id; N : Node_Id) return Boolean;
640 -- Return True if N is present in the Rep_Item chain for a given entity E
641
642 procedure Record_Rep_Item (E : Entity_Id; N : Node_Id);
643 -- N is the node for a representation pragma, representation clause, an
644 -- attribute definition clause, or an aspect specification that applies to
645 -- entity E. This procedure links the node N onto the Rep_Item chain for
646 -- entity E. Note that it is an error to call this procedure with E being
647 -- overloadable, and N being a pragma that applies to multiple overloadable
648 -- entities (Convention, Interface, Inline, Inline_Always, Import, Export,
649 -- External). This is not allowed even in the case where the entity is not
650 -- overloaded, since we can't rely on it being present in the overloaded
651 -- case, it is not useful to have it present in the non-overloaded case.
652
653 -------------------------------
654 -- Miscellaneous Subprograms --
655 -------------------------------
656
657 procedure Append_Entity (Id : Entity_Id; Scop : Entity_Id);
658 -- Add an entity to the list of entities declared in the scope Scop
659
660 function Get_Full_View (T : Entity_Id) return Entity_Id;
661 -- If T is an incomplete type and the full declaration has been seen, or
662 -- is the name of a class_wide type whose root is incomplete, return the
663 -- corresponding full declaration, else return T itself.
664
665 function Is_Entity_Name (N : Node_Id) return Boolean;
666 -- Test if the node N is the name of an entity (i.e. is an identifier,
667 -- expanded name, or an attribute reference that returns an entity).
668
669 -- WARNING: There is a matching C declaration of this subprogram in fe.h
670
671 procedure Link_Entities (First : Entity_Id; Second : Entity_Id);
672 -- Link entities First and Second in one entity chain.
673 --
674 -- NOTE: No updates are done to the First_Entity and Last_Entity fields
675 -- of the scope.
676
677 procedure Remove_Entity (Id : Entity_Id);
678 -- Remove entity Id from the entity chain of its scope
679
680 function Subtype_Kind (K : Entity_Kind) return Entity_Kind;
681 -- Given an entity_kind K this function returns the entity_kind
682 -- corresponding to subtype kind of the type represented by K. For
683 -- example if K is E_Signed_Integer_Type then E_Signed_Integer_Subtype
684 -- is returned. If K is already a subtype kind it itself is returned. An
685 -- internal error is generated if no such correspondence exists for K.
686
687 procedure Unlink_Next_Entity (Id : Entity_Id);
688 -- Unchain entity Id's forward link within the entity chain of its scope
689
690 function Is_Volatile (Id : E) return B;
691 procedure Set_Is_Volatile (Id : E; V : B := True);
692 -- Call [Set_]Is_Volatile_Type/Is_Volatile_Object as appropriate for the
693 -- Ekind of Id.
694
695 function Convention
696 (N : Entity_Id) return Convention_Id renames Basic_Convention;
697 procedure Set_Convention (E : Entity_Id; Val : Convention_Id);
698 -- Same as Set_Basic_Convention, but with an extra check for access types.
699 -- In particular, if E is an access-to-subprogram type, and Val is a
700 -- foreign convention, then we set Can_Use_Internal_Rep to False on E.
701 -- Also, if the Etype of E is set and is an anonymous access type with
702 -- no convention set, this anonymous type inherits the convention of E.
703
77804c9a
EB
704 pragma Inline (Is_Entity_Name);
705
76f9c7f4
BD
706 ----------------------------------
707 -- Debugging Output Subprograms --
708 ----------------------------------
709
710 procedure Write_Entity_Info (Id : Entity_Id; Prefix : String);
711 -- A debugging procedure to write out information about an entity
712
76f9c7f4 713end Einfo.Utils;