1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- E I N F O . U T I L S --
9 -- Copyright (C) 2020-2021, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Einfo
.Entities
; use Einfo
.Entities
;
28 package Einfo
.Utils
is
30 -----------------------------------
31 -- Renamings of Renamed_Or_Alias --
32 -----------------------------------
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.
37 -- ????Should add preconditions.
40 (N
: Entity_Id
) return Node_Id
renames Renamed_Or_Alias
;
42 (N
: Entity_Id
; Val
: Node_Id
) renames Set_Renamed_Or_Alias
;
43 function Renamed_Entity
44 (N
: Entity_Id
) return Node_Id
renames Renamed_Or_Alias
;
45 procedure Set_Renamed_Entity
46 (N
: Entity_Id
; Val
: Node_Id
) renames Set_Renamed_Or_Alias
;
47 function Renamed_Object
48 (N
: Entity_Id
) return Node_Id
renames Renamed_Or_Alias
;
49 procedure Set_Renamed_Object
50 (N
: Entity_Id
; Val
: Node_Id
) renames Set_Renamed_Or_Alias
;
52 --------------------------
53 -- Subtype Declarations --
54 --------------------------
57 -- The above entities are arranged so that they can be conveniently grouped
58 -- into subtype ranges. Note that for each of the xxx_Kind ranges defined
59 -- below, there is a corresponding Is_xxx (or for types, Is_xxx_Type)
60 -- predicate which is to be used in preference to direct range tests using
61 -- the subtype name. However, the subtype names are available for direct
62 -- use, e.g. as choices in case statements.
68 -- The following type synonyms are used to tidy up the function and
69 -- procedure declarations that follow, and also to make it possible to meet
70 -- the requirement for the XEINFO utility that all function specs must fit
71 -- on a single source line.????
74 subtype C
is Component_Alignment_Kind
;
75 subtype E
is Entity_Id
;
76 subtype F
is Float_Rep_Kind
;
77 subtype M
is Mechanism_Type
;
81 subtype L
is Elist_Id
;
84 -------------------------------
85 -- Classification Attributes --
86 -------------------------------
88 -- These functions provide a convenient functional notation for testing
89 -- whether an Ekind value belongs to a specified kind, for example the
90 -- function Is_Elementary_Type tests if its argument is in Elementary_Kind.
91 -- In some cases, the test is of an entity attribute (e.g. in the case of
92 -- Is_Generic_Type where the Ekind does not provide the needed
94 -- ????Could automatically generate some of these?
96 function Is_Access_Object_Type
(Id
: E
) return B
;
97 function Is_Access_Type
(Id
: E
) return B
;
98 function Is_Access_Protected_Subprogram_Type
(Id
: E
) return B
;
99 function Is_Access_Subprogram_Type
(Id
: E
) return B
;
100 function Is_Aggregate_Type
(Id
: E
) return B
;
101 function Is_Anonymous_Access_Type
(Id
: E
) return B
;
102 function Is_Array_Type
(Id
: E
) return B
;
103 function Is_Assignable
(Id
: E
) return B
;
104 function Is_Class_Wide_Type
(Id
: E
) return B
;
105 function Is_Composite_Type
(Id
: E
) return B
;
106 function Is_Concurrent_Body
(Id
: E
) return B
;
107 function Is_Concurrent_Type
(Id
: E
) return B
;
108 function Is_Decimal_Fixed_Point_Type
(Id
: E
) return B
;
109 function Is_Digits_Type
(Id
: E
) return B
;
110 function Is_Discrete_Or_Fixed_Point_Type
(Id
: E
) return B
;
111 function Is_Discrete_Type
(Id
: E
) return B
;
112 function Is_Elementary_Type
(Id
: E
) return B
;
113 function Is_Entry
(Id
: E
) return B
;
114 function Is_Enumeration_Type
(Id
: E
) return B
;
115 function Is_Fixed_Point_Type
(Id
: E
) return B
;
116 function Is_Floating_Point_Type
(Id
: E
) return B
;
117 function Is_Formal
(Id
: E
) return B
;
118 function Is_Formal_Object
(Id
: E
) return B
;
119 function Is_Generic_Subprogram
(Id
: E
) return B
;
120 function Is_Generic_Unit
(Id
: E
) return B
;
121 function Is_Ghost_Entity
(Id
: E
) return B
;
122 function Is_Incomplete_Or_Private_Type
(Id
: E
) return B
;
123 function Is_Incomplete_Type
(Id
: E
) return B
;
124 function Is_Integer_Type
(Id
: E
) return B
;
125 function Is_Modular_Integer_Type
(Id
: E
) return B
;
126 function Is_Named_Access_Type
(Id
: E
) return B
;
127 function Is_Named_Number
(Id
: E
) return B
;
128 function Is_Numeric_Type
(Id
: E
) return B
;
129 function Is_Object
(Id
: E
) return B
;
130 function Is_Ordinary_Fixed_Point_Type
(Id
: E
) return B
;
131 function Is_Overloadable
(Id
: E
) return B
;
132 function Is_Private_Type
(Id
: E
) return B
;
133 function Is_Protected_Type
(Id
: E
) return B
;
134 function Is_Real_Type
(Id
: E
) return B
;
135 function Is_Record_Type
(Id
: E
) return B
;
136 function Is_Scalar_Type
(Id
: E
) return B
;
137 function Is_Signed_Integer_Type
(Id
: E
) return B
;
138 function Is_Subprogram
(Id
: E
) return B
;
139 function Is_Subprogram_Or_Entry
(Id
: E
) return B
;
140 function Is_Subprogram_Or_Generic_Subprogram
(Id
: E
) return B
;
141 function Is_Task_Type
(Id
: E
) return B
;
142 function Is_Type
(Id
: E
) return B
;
144 pragma Inline
(Is_Access_Object_Type
);
145 pragma Inline
(Is_Access_Type
);
146 pragma Inline
(Is_Access_Protected_Subprogram_Type
);
147 pragma Inline
(Is_Access_Subprogram_Type
);
148 pragma Inline
(Is_Aggregate_Type
);
149 pragma Inline
(Is_Anonymous_Access_Type
);
150 pragma Inline
(Is_Array_Type
);
151 pragma Inline
(Is_Assignable
);
152 pragma Inline
(Is_Class_Wide_Type
);
153 pragma Inline
(Is_Composite_Type
);
154 pragma Inline
(Is_Concurrent_Body
);
155 pragma Inline
(Is_Concurrent_Type
);
156 pragma Inline
(Is_Decimal_Fixed_Point_Type
);
157 pragma Inline
(Is_Digits_Type
);
158 pragma Inline
(Is_Discrete_Type
);
159 pragma Inline
(Is_Elementary_Type
);
160 pragma Inline
(Is_Entry
);
161 pragma Inline
(Is_Enumeration_Type
);
162 pragma Inline
(Is_Fixed_Point_Type
);
163 pragma Inline
(Is_Floating_Point_Type
);
164 pragma Inline
(Is_Formal
);
165 pragma Inline
(Is_Formal_Object
);
166 pragma Inline
(Is_Generic_Subprogram
);
167 pragma Inline
(Is_Generic_Unit
);
168 pragma Inline
(Is_Ghost_Entity
);
169 pragma Inline
(Is_Incomplete_Or_Private_Type
);
170 pragma Inline
(Is_Incomplete_Type
);
171 pragma Inline
(Is_Integer_Type
);
172 pragma Inline
(Is_Modular_Integer_Type
);
173 pragma Inline
(Is_Named_Access_Type
);
174 pragma Inline
(Is_Named_Number
);
175 pragma Inline
(Is_Numeric_Type
);
176 pragma Inline
(Is_Object
);
177 pragma Inline
(Is_Ordinary_Fixed_Point_Type
);
178 pragma Inline
(Is_Overloadable
);
179 pragma Inline
(Is_Private_Type
);
180 pragma Inline
(Is_Protected_Type
);
181 pragma Inline
(Is_Real_Type
);
182 pragma Inline
(Is_Record_Type
);
183 pragma Inline
(Is_Scalar_Type
);
184 pragma Inline
(Is_Signed_Integer_Type
);
185 pragma Inline
(Is_Subprogram
);
186 pragma Inline
(Is_Subprogram_Or_Entry
);
187 pragma Inline
(Is_Subprogram_Or_Generic_Subprogram
);
188 pragma Inline
(Is_Task_Type
);
189 pragma Inline
(Is_Type
);
191 -------------------------------------
192 -- Synthesized Attribute Functions --
193 -------------------------------------
195 -- The functions in this section synthesize attributes from the tree,
196 -- so they do not correspond to defined fields in the entity itself.
198 function Address_Clause
(Id
: E
) return N
;
199 function Aft_Value
(Id
: E
) return U
;
200 function Alignment_Clause
(Id
: E
) return N
;
201 function Base_Type
(Id
: E
) return E
;
202 function Declaration_Node
(Id
: E
) return N
;
203 function Designated_Type
(Id
: E
) return E
;
204 function Entry_Index_Type
(Id
: E
) return E
;
205 function First_Component
(Id
: E
) return E
;
206 function First_Component_Or_Discriminant
(Id
: E
) return E
;
207 function First_Formal
(Id
: E
) return E
;
208 function First_Formal_With_Extras
(Id
: E
) return E
;
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
;
223 function Is_Boolean_Type
(Id
: E
) return B
;
224 function Is_Constant_Object
(Id
: E
) return B
;
225 function Is_Controlled
(Id
: E
) return B
;
226 function Is_Discriminal
(Id
: E
) return B
;
227 function Is_Dynamic_Scope
(Id
: E
) return B
;
228 function Is_Elaboration_Target
(Id
: E
) return B
;
229 function Is_External_State
(Id
: E
) return B
;
230 function Is_Finalizer
(Id
: E
) return B
;
231 function Is_Full_Access
(Id
: E
) return B
;
232 function Is_Null_State
(Id
: E
) return B
;
233 function Is_Package_Or_Generic_Package
(Id
: E
) return B
;
234 function Is_Packed_Array
(Id
: E
) return B
;
235 function Is_Prival
(Id
: E
) return B
;
236 function Is_Protected_Component
(Id
: E
) return B
;
237 function Is_Protected_Interface
(Id
: E
) return B
;
238 function Is_Protected_Record_Type
(Id
: E
) return B
;
239 function Is_Relaxed_Initialization_State
(Id
: E
) return B
;
240 function Is_Standard_Character_Type
(Id
: E
) return B
;
241 function Is_Standard_String_Type
(Id
: E
) return B
;
242 function Is_String_Type
(Id
: E
) return B
;
243 function Is_Synchronized_Interface
(Id
: E
) return B
;
244 function Is_Synchronized_State
(Id
: E
) return B
;
245 function Is_Task_Interface
(Id
: E
) return B
;
246 function Is_Task_Record_Type
(Id
: E
) return B
;
247 function Is_Wrapper_Package
(Id
: E
) return B
;
248 function Last_Formal
(Id
: E
) return E
;
249 function Machine_Emax_Value
(Id
: E
) return U
;
250 function Machine_Emin_Value
(Id
: E
) return U
;
251 function Machine_Mantissa_Value
(Id
: E
) return U
;
252 function Machine_Radix_Value
(Id
: E
) return U
;
253 function Model_Emin_Value
(Id
: E
) return U
;
254 function Model_Epsilon_Value
(Id
: E
) return R
;
255 function Model_Mantissa_Value
(Id
: E
) return U
;
256 function Model_Small_Value
(Id
: E
) return R
;
257 function Next_Component
(Id
: E
) return E
;
258 function Next_Component_Or_Discriminant
(Id
: E
) return E
;
259 function Next_Discriminant
(Id
: E
) return E
;
260 function Next_Formal
(Id
: E
) return E
;
261 function Next_Formal_With_Extras
(Id
: E
) return E
;
262 function Next_Index
(Id
: N
) return N
;
263 function Next_Literal
(Id
: E
) return E
;
264 function Next_Stored_Discriminant
(Id
: E
) return E
;
265 function Number_Dimensions
(Id
: E
) return Pos
;
266 function Number_Entries
(Id
: E
) return Nat
;
267 function Number_Formals
(Id
: E
) return Pos
;
268 function Object_Size_Clause
(Id
: E
) return N
;
269 function Parameter_Mode
(Id
: E
) return Formal_Kind
;
270 function Partial_Refinement_Constituents
(Id
: E
) return L
;
271 function Primitive_Operations
(Id
: E
) return L
;
272 function Root_Type
(Id
: E
) return E
;
273 function Safe_Emax_Value
(Id
: E
) return U
;
274 function Safe_First_Value
(Id
: E
) return R
;
275 function Safe_Last_Value
(Id
: E
) return R
;
276 function Scope_Depth
(Id
: E
) return U
;
277 function Scope_Depth_Set
(Id
: E
) return B
;
278 function Size_Clause
(Id
: E
) return N
;
279 function Stream_Size_Clause
(Id
: E
) return N
;
280 function Type_High_Bound
(Id
: E
) return N
;
281 function Type_Low_Bound
(Id
: E
) return N
;
282 function Underlying_Type
(Id
: E
) return E
;
284 pragma Inline
(Address_Clause
);
285 pragma Inline
(Alignment_Clause
);
286 pragma Inline
(Base_Type
);
287 pragma Inline
(Has_Foreign_Convention
);
288 pragma Inline
(Has_Non_Limited_View
);
289 pragma Inline
(Is_Base_Type
);
290 pragma Inline
(Is_Boolean_Type
);
291 pragma Inline
(Is_Constant_Object
);
292 pragma Inline
(Is_Controlled
);
293 pragma Inline
(Is_Discriminal
);
294 pragma Inline
(Is_Finalizer
);
295 pragma Inline
(Is_Full_Access
);
296 pragma Inline
(Is_Null_State
);
297 pragma Inline
(Is_Package_Or_Generic_Package
);
298 pragma Inline
(Is_Packed_Array
);
299 pragma Inline
(Is_Prival
);
300 pragma Inline
(Is_Protected_Component
);
301 pragma Inline
(Is_Protected_Record_Type
);
302 pragma Inline
(Is_String_Type
);
303 pragma Inline
(Is_Task_Record_Type
);
304 pragma Inline
(Is_Wrapper_Package
);
305 pragma Inline
(Scope_Depth
);
306 pragma Inline
(Scope_Depth_Set
);
307 pragma Inline
(Size_Clause
);
308 pragma Inline
(Stream_Size_Clause
);
309 pragma Inline
(Type_High_Bound
);
310 pragma Inline
(Type_Low_Bound
);
312 ----------------------------------------------
313 -- Type Representation Attribute Predicates --
314 ----------------------------------------------
316 -- These predicates test the setting of the indicated attribute. If the
317 -- value has been set, then Known is True, and Unknown is False. If no
318 -- value is set, then Known is False and Unknown is True. The Known_Static
319 -- predicate is true only if the value is set (Known) and is set to a
320 -- compile time known value. Note that in the case of Alignment and
321 -- Normalized_First_Bit, dynamic values are not possible, so we do not
322 -- need a separate Known_Static calls in these cases. The not set (unknown)
323 -- values are as follows:
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
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).
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.
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
;
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
;
366 function Unknown_Alignment
(E
: Entity_Id
) return B
;
367 function Unknown_Component_Bit_Offset
(E
: Entity_Id
) return B
;
368 function Unknown_Component_Size
(E
: Entity_Id
) return B
;
369 function Unknown_Esize
(E
: Entity_Id
) return B
;
370 function Unknown_Normalized_First_Bit
(E
: Entity_Id
) return B
;
371 function Unknown_Normalized_Position
(E
: Entity_Id
) return B
;
372 function Unknown_Normalized_Position_Max
(E
: Entity_Id
) return B
;
373 function Unknown_RM_Size
(E
: Entity_Id
) return B
;
375 pragma Inline
(Known_Alignment
);
376 pragma Inline
(Known_Component_Bit_Offset
);
377 pragma Inline
(Known_Component_Size
);
378 pragma Inline
(Known_Esize
);
379 pragma Inline
(Known_Normalized_First_Bit
);
380 pragma Inline
(Known_Normalized_Position
);
381 pragma Inline
(Known_Normalized_Position_Max
);
382 pragma Inline
(Known_RM_Size
);
384 pragma Inline
(Known_Static_Component_Bit_Offset
);
385 pragma Inline
(Known_Static_Component_Size
);
386 pragma Inline
(Known_Static_Esize
);
387 pragma Inline
(Known_Static_Normalized_First_Bit
);
388 pragma Inline
(Known_Static_Normalized_Position
);
389 pragma Inline
(Known_Static_Normalized_Position_Max
);
390 pragma Inline
(Known_Static_RM_Size
);
392 pragma Inline
(Unknown_Alignment
);
393 pragma Inline
(Unknown_Component_Bit_Offset
);
394 pragma Inline
(Unknown_Component_Size
);
395 pragma Inline
(Unknown_Esize
);
396 pragma Inline
(Unknown_Normalized_First_Bit
);
397 pragma Inline
(Unknown_Normalized_Position
);
398 pragma Inline
(Unknown_Normalized_Position_Max
);
399 pragma Inline
(Unknown_RM_Size
);
401 ---------------------------------------------------
402 -- Access to Subprograms in Subprograms_For_Type --
403 ---------------------------------------------------
405 function Is_Partial_DIC_Procedure
(Id
: E
) return B
;
407 function DIC_Procedure
(Id
: E
) return E
;
408 function Partial_DIC_Procedure
(Id
: E
) return E
;
409 function Invariant_Procedure
(Id
: E
) return E
;
410 function Partial_Invariant_Procedure
(Id
: E
) return E
;
411 function Predicate_Function
(Id
: E
) return E
;
412 function Predicate_Function_M
(Id
: E
) return E
;
414 procedure Set_DIC_Procedure
(Id
: E
; V
: E
);
415 procedure Set_Partial_DIC_Procedure
(Id
: E
; V
: E
);
416 procedure Set_Invariant_Procedure
(Id
: E
; V
: E
);
417 procedure Set_Partial_Invariant_Procedure
(Id
: E
; V
: E
);
418 procedure Set_Predicate_Function
(Id
: E
; V
: E
);
419 procedure Set_Predicate_Function_M
(Id
: E
; V
: E
);
421 -----------------------------------
422 -- Field Initialization Routines --
423 -----------------------------------
425 -- These routines are overloadings of some of the above Set procedures
426 -- where the argument is normally a Uint. The overloadings take an Int
427 -- parameter instead, and appropriately convert it. There are also
428 -- versions that implicitly initialize to the appropriate "not set"
429 -- value. The not set (unknown) values are as follows:
432 -- Component_Size Uint_0
433 -- Component_Bit_Offset No_Uint
434 -- Digits_Value Uint_0
436 -- Normalized_First_Bit No_Uint
437 -- Normalized_Position No_Uint
438 -- Normalized_Position_Max No_Uint
441 -- It would be cleaner to use No_Uint in all these cases, but historically
442 -- we chose to use Uint_0 at first, and the change over will take time ???
443 -- This is particularly true for the RM_Size field, where a value of zero
444 -- is legitimate and causes some special tests around the code.
446 -- Contrary to the corresponding Set procedures above, these routines
447 -- do NOT check the entity kind of their argument, instead they set the
448 -- underlying Uint fields directly (this allows them to be used for
449 -- entities whose Ekind has not been set yet).
451 procedure Init_Alignment
(Id
: E
; V
: Int
);
452 procedure Init_Component_Bit_Offset
(Id
: E
; V
: Int
);
453 procedure Init_Component_Size
(Id
: E
; V
: Int
);
454 procedure Init_Digits_Value
(Id
: E
; V
: Int
);
455 procedure Init_Esize
(Id
: E
; V
: Int
);
456 procedure Init_Normalized_First_Bit
(Id
: E
; V
: Int
);
457 procedure Init_Normalized_Position
(Id
: E
; V
: Int
);
458 procedure Init_Normalized_Position_Max
(Id
: E
; V
: Int
);
459 procedure Init_RM_Size
(Id
: E
; V
: Int
);
461 procedure Init_Alignment
(Id
: E
);
462 procedure Init_Component_Bit_Offset
(Id
: E
);
463 procedure Init_Component_Size
(Id
: E
);
464 procedure Init_Digits_Value
(Id
: E
);
465 procedure Init_Esize
(Id
: E
);
466 procedure Init_Normalized_First_Bit
(Id
: E
);
467 procedure Init_Normalized_Position
(Id
: E
);
468 procedure Init_Normalized_Position_Max
(Id
: E
);
469 procedure Init_RM_Size
(Id
: E
);
471 pragma Inline
(Init_Alignment
);
472 pragma Inline
(Init_Component_Bit_Offset
);
473 pragma Inline
(Init_Component_Size
);
474 pragma Inline
(Init_Digits_Value
);
475 pragma Inline
(Init_Esize
);
476 pragma Inline
(Init_Normalized_First_Bit
);
477 pragma Inline
(Init_Normalized_Position
);
478 pragma Inline
(Init_Normalized_Position_Max
);
479 pragma Inline
(Init_RM_Size
);
481 procedure Init_Component_Location
(Id
: E
);
482 -- Initializes all fields describing the location of a component
483 -- (Normalized_Position, Component_Bit_Offset, Normalized_First_Bit,
484 -- Normalized_Position_Max, Esize) to all be Unknown.
486 procedure Init_Size
(Id
: E
; V
: Int
);
487 -- Initialize both the Esize and RM_Size fields of E to V
489 procedure Init_Size_Align
(Id
: E
);
490 -- This procedure initializes both size fields and the alignment
491 -- field to all be Unknown.
493 procedure Init_Object_Size_Align
(Id
: E
);
494 -- Same as Init_Size_Align except RM_Size field (which is only for types)
501 -- The call to Next_xxx (obj) is equivalent to obj := Next_xxx (obj)
502 -- We define the set of Proc_Next_xxx routines simply for the purposes
503 -- of inlining them without necessarily inlining the function.
505 procedure Proc_Next_Component
(N
: in out Node_Id
);
506 procedure Proc_Next_Component_Or_Discriminant
(N
: in out Node_Id
);
507 procedure Proc_Next_Discriminant
(N
: in out Node_Id
);
508 procedure Proc_Next_Formal
(N
: in out Node_Id
);
509 procedure Proc_Next_Formal_With_Extras
(N
: in out Node_Id
);
510 procedure Proc_Next_Index
(N
: in out Node_Id
);
511 procedure Proc_Next_Inlined_Subprogram
(N
: in out Node_Id
);
512 procedure Proc_Next_Literal
(N
: in out Node_Id
);
513 procedure Proc_Next_Stored_Discriminant
(N
: in out Node_Id
);
515 pragma Inline
(Proc_Next_Component
);
516 pragma Inline
(Proc_Next_Component_Or_Discriminant
);
517 pragma Inline
(Proc_Next_Discriminant
);
518 pragma Inline
(Proc_Next_Formal
);
519 pragma Inline
(Proc_Next_Formal_With_Extras
);
520 pragma Inline
(Proc_Next_Index
);
521 pragma Inline
(Proc_Next_Inlined_Subprogram
);
522 pragma Inline
(Proc_Next_Literal
);
523 pragma Inline
(Proc_Next_Stored_Discriminant
);
525 procedure Next_Component
(N
: in out Node_Id
)
526 renames Proc_Next_Component
;
528 procedure Next_Component_Or_Discriminant
(N
: in out Node_Id
)
529 renames Proc_Next_Component_Or_Discriminant
;
531 procedure Next_Discriminant
(N
: in out Node_Id
)
532 renames Proc_Next_Discriminant
;
534 procedure Next_Formal
(N
: in out Node_Id
)
535 renames Proc_Next_Formal
;
537 procedure Next_Formal_With_Extras
(N
: in out Node_Id
)
538 renames Proc_Next_Formal_With_Extras
;
540 procedure Next_Index
(N
: in out Node_Id
)
541 renames Proc_Next_Index
;
543 procedure Next_Inlined_Subprogram
(N
: in out Node_Id
)
544 renames Proc_Next_Inlined_Subprogram
;
546 procedure Next_Literal
(N
: in out Node_Id
)
547 renames Proc_Next_Literal
;
549 procedure Next_Stored_Discriminant
(N
: in out Node_Id
)
550 renames Proc_Next_Stored_Discriminant
;
552 ---------------------------
553 -- Testing Warning Flags --
554 ---------------------------
556 -- These routines are to be used rather than testing flags Warnings_Off,
557 -- Has_Pragma_Unmodified, Has_Pragma_Unreferenced. They deal with setting
558 -- the flags Warnings_Off_Used[_Unmodified|Unreferenced] for later access.
560 function Has_Warnings_Off
(E
: Entity_Id
) return Boolean;
561 -- If Warnings_Off is set on E, then returns True and also sets the flag
562 -- Warnings_Off_Used on E. If Warnings_Off is not set on E, returns False
563 -- and has no side effect.
565 function Has_Unmodified
(E
: Entity_Id
) return Boolean;
566 -- If flag Has_Pragma_Unmodified 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_Unmodified on E. If neither of the flags
569 -- Warnings_Off nor Has_Pragma_Unmodified is set, returns False with no
572 function Has_Unreferenced
(E
: Entity_Id
) return Boolean;
573 -- If flag Has_Pragma_Unreferenced is set on E, returns True with no side
574 -- effects. Otherwise if Warnings_Off is set on E, returns True and also
575 -- sets the flag Warnings_Off_Used_Unreferenced on E. If neither of the
576 -- flags Warnings_Off nor Has_Pragma_Unreferenced is set, returns False
577 -- with no side effects.
579 ----------------------------------------------
580 -- Subprograms for Accessing Rep Item Chain --
581 ----------------------------------------------
583 -- The First_Rep_Item field of every entity points to a linked list (linked
584 -- through Next_Rep_Item) of representation pragmas, attribute definition
585 -- clauses, representation clauses, and aspect specifications that apply to
586 -- the item. Note that in the case of types, it is assumed that any such
587 -- rep items for a base type also apply to all subtypes. This is achieved
588 -- by having the chain for subtypes link onto the chain for the base type,
589 -- so that new entries for the subtype are added at the start of the chain.
591 -- Note: aspect specification nodes are linked only when evaluation of the
592 -- expression is deferred to the freeze point. For further details see
593 -- Sem_Ch13.Analyze_Aspect_Specifications.
595 function Get_Attribute_Definition_Clause
597 Id
: Attribute_Id
) return Node_Id
;
598 -- Searches the Rep_Item chain for a given entity E, for an instance of an
599 -- attribute definition clause with the given attribute Id. If found, the
600 -- value returned is the N_Attribute_Definition_Clause node, otherwise
601 -- Empty is returned.
603 -- WARNING: There is a matching C declaration of this subprogram in fe.h
605 function Get_Pragma
(E
: Entity_Id
; Id
: Pragma_Id
) return Node_Id
;
606 -- Searches the Rep_Item chain of entity E, for an instance of a pragma
607 -- with the given pragma Id. If found, the value returned is the N_Pragma
608 -- node, otherwise Empty is returned. The following contract pragmas that
609 -- appear in N_Contract nodes are also handled by this routine:
614 -- Constant_After_Elaboration
631 -- Subprogram_Variant
635 function Get_Class_Wide_Pragma
637 Id
: Pragma_Id
) return Node_Id
;
638 -- Examine Rep_Item chain to locate a classwide pre- or postcondition of a
639 -- primitive operation. Returns Empty if not present.
641 function Get_Record_Representation_Clause
(E
: Entity_Id
) return Node_Id
;
642 -- Searches the Rep_Item chain for a given entity E, for a record
643 -- representation clause, and if found, returns it. Returns Empty
644 -- if no such clause is found.
646 function Present_In_Rep_Item
(E
: Entity_Id
; N
: Node_Id
) return Boolean;
647 -- Return True if N is present in the Rep_Item chain for a given entity E
649 procedure Record_Rep_Item
(E
: Entity_Id
; N
: Node_Id
);
650 -- N is the node for a representation pragma, representation clause, an
651 -- attribute definition clause, or an aspect specification that applies to
652 -- entity E. This procedure links the node N onto the Rep_Item chain for
653 -- entity E. Note that it is an error to call this procedure with E being
654 -- overloadable, and N being a pragma that applies to multiple overloadable
655 -- entities (Convention, Interface, Inline, Inline_Always, Import, Export,
656 -- External). This is not allowed even in the case where the entity is not
657 -- overloaded, since we can't rely on it being present in the overloaded
658 -- case, it is not useful to have it present in the non-overloaded case.
660 -------------------------------
661 -- Miscellaneous Subprograms --
662 -------------------------------
664 procedure Append_Entity
(Id
: Entity_Id
; Scop
: Entity_Id
);
665 -- Add an entity to the list of entities declared in the scope Scop
667 function Get_Full_View
(T
: Entity_Id
) return Entity_Id
;
668 -- If T is an incomplete type and the full declaration has been seen, or
669 -- is the name of a class_wide type whose root is incomplete, return the
670 -- corresponding full declaration, else return T itself.
672 function Is_Entity_Name
(N
: Node_Id
) return Boolean;
673 -- Test if the node N is the name of an entity (i.e. is an identifier,
674 -- expanded name, or an attribute reference that returns an entity).
676 -- WARNING: There is a matching C declaration of this subprogram in fe.h
678 procedure Link_Entities
(First
: Entity_Id
; Second
: Entity_Id
);
679 -- Link entities First and Second in one entity chain.
681 -- NOTE: No updates are done to the First_Entity and Last_Entity fields
684 procedure Remove_Entity
(Id
: Entity_Id
);
685 -- Remove entity Id from the entity chain of its scope
687 function Subtype_Kind
(K
: Entity_Kind
) return Entity_Kind
;
688 -- Given an entity_kind K this function returns the entity_kind
689 -- corresponding to subtype kind of the type represented by K. For
690 -- example if K is E_Signed_Integer_Type then E_Signed_Integer_Subtype
691 -- is returned. If K is already a subtype kind it itself is returned. An
692 -- internal error is generated if no such correspondence exists for K.
694 procedure Unlink_Next_Entity
(Id
: Entity_Id
);
695 -- Unchain entity Id's forward link within the entity chain of its scope
697 function Is_Volatile
(Id
: E
) return B
;
698 procedure Set_Is_Volatile
(Id
: E
; V
: B
:= True);
699 -- Call [Set_]Is_Volatile_Type/Is_Volatile_Object as appropriate for the
703 (N
: Entity_Id
) return Convention_Id
renames Basic_Convention
;
704 procedure Set_Convention
(E
: Entity_Id
; Val
: Convention_Id
);
705 -- Same as Set_Basic_Convention, but with an extra check for access types.
706 -- In particular, if E is an access-to-subprogram type, and Val is a
707 -- foreign convention, then we set Can_Use_Internal_Rep to False on E.
708 -- Also, if the Etype of E is set and is an anonymous access type with
709 -- no convention set, this anonymous type inherits the convention of E.
711 pragma Inline
(Is_Entity_Name
);
713 ----------------------------------
714 -- Debugging Output Subprograms --
715 ----------------------------------
717 procedure Write_Entity_Info
(Id
: Entity_Id
; Prefix
: String);
718 -- A debugging procedure to write out information about an entity