[Ada] Support for new aspect Subprogram_Variant on recursive subprograms
[gcc.git] / gcc / ada / aspects.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A S P E C T S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2010-2020, 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. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
31
32 -- This package defines the aspects that are recognized by GNAT in aspect
33 -- specifications. It also contains the subprograms for storing/retrieving
34 -- aspect specifications from the tree. The semantic processing for aspect
35 -- specifications is found in Sem_Ch13.Analyze_Aspect_Specifications.
36
37 ------------------------
38 -- Adding New Aspects --
39 ------------------------
40
41 -- In general, each aspect should have a corresponding pragma or attribute, so
42 -- that the newly developed functionality is available for old Ada versions.
43 -- When both are defined, it is convenient to first transform the aspect into
44 -- an equivalent pragma or attribute in Sem_Ch13.Analyze_Aspect_Specifications
45 -- and then analyze that.
46
47 -- To add a new aspect, you need to do the following
48
49 -- 1. Create a name in snames.ads-tmpl
50
51 -- 2. Create a value in type Aspect_Id in this unit
52
53 -- 3. Add a value for the aspect in the global arrays defined in this unit
54
55 -- 4. Add code for the aspect in Sem_Ch13.Analyze_Aspect_Specifications.
56 -- This may involve adding some nodes to the tree to perform additional
57 -- treatments later.
58
59 -- 5. If the semantic analysis of expressions/names in the aspect should not
60 -- occur at the point the aspect is defined, add code in the appropriate
61 -- semantic analysis procedure for the aspect. For example, this is the
62 -- case for aspects Pre and Post on subprograms, which are preanalyzed
63 -- at the end of the declaration list to which the subprogram belongs,
64 -- and fully analyzed (possibly with expansion) during the semantic
65 -- analysis of subprogram bodies.
66
67 with Namet; use Namet;
68 with Snames; use Snames;
69 with Types; use Types;
70
71 package Aspects is
72
73 -- Type defining recognized aspects
74
75 type Aspect_Id is
76 (No_Aspect, -- Dummy entry for no aspect
77 Aspect_Abstract_State, -- GNAT
78 Aspect_Address,
79 Aspect_Aggregate,
80 Aspect_Alignment,
81 Aspect_Annotate, -- GNAT
82 Aspect_Async_Readers, -- GNAT
83 Aspect_Async_Writers, -- GNAT
84 Aspect_Attach_Handler,
85 Aspect_Bit_Order,
86 Aspect_Component_Size,
87 Aspect_Constant_After_Elaboration, -- GNAT
88 Aspect_Constant_Indexing,
89 Aspect_Contract_Cases, -- GNAT
90 Aspect_Convention,
91 Aspect_CPU,
92 Aspect_Default_Component_Value,
93 Aspect_Default_Initial_Condition, -- GNAT
94 Aspect_Default_Iterator,
95 Aspect_Default_Storage_Pool,
96 Aspect_Default_Value,
97 Aspect_Depends, -- GNAT
98 Aspect_Dimension, -- GNAT
99 Aspect_Dimension_System, -- GNAT
100 Aspect_Dispatching_Domain,
101 Aspect_Dynamic_Predicate,
102 Aspect_Effective_Reads, -- GNAT
103 Aspect_Effective_Writes, -- GNAT
104 Aspect_Extensions_Visible, -- GNAT
105 Aspect_External_Name,
106 Aspect_External_Tag,
107 Aspect_Ghost, -- GNAT
108 Aspect_Global, -- GNAT
109 Aspect_Implicit_Dereference,
110 Aspect_Initial_Condition, -- GNAT
111 Aspect_Initializes, -- GNAT
112 Aspect_Input,
113 Aspect_Integer_Literal,
114 Aspect_Interrupt_Priority,
115 Aspect_Invariant, -- GNAT
116 Aspect_Iterator_Element,
117 Aspect_Iterable, -- GNAT
118 Aspect_Link_Name,
119 Aspect_Linker_Section, -- GNAT
120 Aspect_Machine_Radix,
121 Aspect_Max_Entry_Queue_Depth, -- GNAT
122 Aspect_Max_Entry_Queue_Length,
123 Aspect_Max_Queue_Length, -- GNAT
124 Aspect_No_Caching, -- GNAT
125 Aspect_Object_Size, -- GNAT
126 Aspect_Obsolescent, -- GNAT
127 Aspect_Output,
128 Aspect_Part_Of, -- GNAT
129 Aspect_Post,
130 Aspect_Postcondition,
131 Aspect_Pre,
132 Aspect_Precondition,
133 Aspect_Predicate, -- GNAT
134 Aspect_Predicate_Failure,
135 Aspect_Priority,
136 Aspect_Put_Image,
137 Aspect_Read,
138 Aspect_Real_Literal,
139 Aspect_Refined_Depends, -- GNAT
140 Aspect_Refined_Global, -- GNAT
141 Aspect_Refined_Post, -- GNAT
142 Aspect_Refined_State, -- GNAT
143 Aspect_Relative_Deadline,
144 Aspect_Relaxed_Initialization, -- GNAT
145 Aspect_Scalar_Storage_Order, -- GNAT
146 Aspect_Secondary_Stack_Size, -- GNAT
147 Aspect_Simple_Storage_Pool, -- GNAT
148 Aspect_Size,
149 Aspect_Small,
150 Aspect_SPARK_Mode, -- GNAT
151 Aspect_Static_Predicate,
152 Aspect_Storage_Pool,
153 Aspect_Storage_Size,
154 Aspect_Stream_Size,
155 Aspect_String_Literal,
156 Aspect_Subprogram_Variant, -- GNAT
157 Aspect_Suppress,
158 Aspect_Synchronization,
159 Aspect_Test_Case, -- GNAT
160 Aspect_Type_Invariant,
161 Aspect_Unimplemented, -- GNAT
162 Aspect_Unsuppress,
163 Aspect_Value_Size, -- GNAT
164 Aspect_Variable_Indexing,
165 Aspect_Volatile_Function, -- GNAT
166 Aspect_Warnings, -- GNAT
167 Aspect_Write,
168
169 -- The following aspects correspond to library unit pragmas
170
171 Aspect_All_Calls_Remote,
172 Aspect_Elaborate_Body,
173 Aspect_No_Elaboration_Code_All, -- GNAT
174 Aspect_Preelaborate,
175 Aspect_Pure,
176 Aspect_Remote_Call_Interface,
177 Aspect_Remote_Types,
178 Aspect_Shared_Passive,
179 Aspect_Universal_Data, -- GNAT
180
181 -- Remaining aspects have a static boolean value that turns the aspect
182 -- on or off. They all correspond to pragmas, but are only converted to
183 -- the pragmas where the value is True. A value of False normally means
184 -- that the aspect is ignored, except in the case of derived types where
185 -- the aspect value is inherited from the parent, in which case, we do
186 -- not allow False if we inherit a True value from the parent.
187
188 Aspect_Asynchronous,
189 Aspect_Atomic,
190 Aspect_Atomic_Components,
191 Aspect_Disable_Controlled, -- GNAT
192 Aspect_Discard_Names,
193 Aspect_CUDA_Global, -- GNAT
194 Aspect_Exclusive_Functions,
195 Aspect_Export,
196 Aspect_Favor_Top_Level, -- GNAT
197 Aspect_Independent,
198 Aspect_Independent_Components,
199 Aspect_Import,
200 Aspect_Inline,
201 Aspect_Inline_Always, -- GNAT
202 Aspect_Interrupt_Handler,
203 Aspect_Lock_Free, -- GNAT
204 Aspect_No_Inline, -- GNAT
205 Aspect_No_Return,
206 Aspect_No_Tagged_Streams, -- GNAT
207 Aspect_Pack,
208 Aspect_Persistent_BSS, -- GNAT
209 Aspect_Preelaborable_Initialization,
210 Aspect_Pure_Function, -- GNAT
211 Aspect_Remote_Access_Type, -- GNAT
212 Aspect_Shared, -- GNAT (equivalent to Atomic)
213 Aspect_Simple_Storage_Pool_Type, -- GNAT
214 Aspect_Static,
215 Aspect_Suppress_Debug_Info, -- GNAT
216 Aspect_Suppress_Initialization, -- GNAT
217 Aspect_Thread_Local_Storage, -- GNAT
218 Aspect_Unchecked_Union,
219 Aspect_Universal_Aliasing, -- GNAT
220 Aspect_Unmodified, -- GNAT
221 Aspect_Unreferenced, -- GNAT
222 Aspect_Unreferenced_Objects, -- GNAT
223 Aspect_Volatile,
224 Aspect_Volatile_Components,
225 Aspect_Volatile_Full_Access, -- GNAT
226 Aspect_Yield);
227
228 subtype Aspect_Id_Exclude_No_Aspect is
229 Aspect_Id range Aspect_Id'Succ (No_Aspect) .. Aspect_Id'Last;
230 -- Aspect_Id's excluding No_Aspect
231
232 -- The following array indicates aspects that accept 'Class
233
234 Class_Aspect_OK : constant array (Aspect_Id) of Boolean :=
235 (Aspect_Input => True,
236 Aspect_Invariant => True,
237 Aspect_Output => True,
238 Aspect_Pre => True,
239 Aspect_Predicate => True,
240 Aspect_Post => True,
241 Aspect_Read => True,
242 Aspect_Write => True,
243 Aspect_Type_Invariant => True,
244 others => False);
245
246 -- The following array identifies all implementation defined aspects
247
248 Implementation_Defined_Aspect : constant array (Aspect_Id) of Boolean :=
249 (Aspect_Abstract_State => True,
250 Aspect_Annotate => True,
251 Aspect_Async_Readers => True,
252 Aspect_Async_Writers => True,
253 Aspect_Constant_After_Elaboration => True,
254 Aspect_Contract_Cases => True,
255 Aspect_Depends => True,
256 Aspect_Dimension => True,
257 Aspect_Dimension_System => True,
258 Aspect_Effective_Reads => True,
259 Aspect_Effective_Writes => True,
260 Aspect_Extensions_Visible => True,
261 Aspect_Favor_Top_Level => True,
262 Aspect_Ghost => True,
263 Aspect_Global => True,
264 Aspect_Inline_Always => True,
265 Aspect_Invariant => True,
266 Aspect_Lock_Free => True,
267 Aspect_Max_Entry_Queue_Depth => True,
268 Aspect_Max_Entry_Queue_Length => True,
269 Aspect_Max_Queue_Length => True,
270 Aspect_Object_Size => True,
271 Aspect_Persistent_BSS => True,
272 Aspect_Predicate => True,
273 Aspect_Pure_Function => True,
274 Aspect_Relaxed_Initialization => True,
275 Aspect_Remote_Access_Type => True,
276 Aspect_Scalar_Storage_Order => True,
277 Aspect_Secondary_Stack_Size => True,
278 Aspect_Shared => True,
279 Aspect_Simple_Storage_Pool => True,
280 Aspect_Simple_Storage_Pool_Type => True,
281 Aspect_Suppress_Debug_Info => True,
282 Aspect_Suppress_Initialization => True,
283 Aspect_Thread_Local_Storage => True,
284 Aspect_Test_Case => True,
285 Aspect_Universal_Aliasing => True,
286 Aspect_Universal_Data => True,
287 Aspect_Unmodified => True,
288 Aspect_Unreferenced => True,
289 Aspect_Unreferenced_Objects => True,
290 Aspect_Value_Size => True,
291 Aspect_Volatile_Function => True,
292 Aspect_Warnings => True,
293 others => False);
294
295 -- The following array indicates aspects that specify operational
296 -- characteristics, and thus are view-specific. Representation
297 -- aspects break privacy, as they are needed during expansion and
298 -- code generation.
299 -- List is currently incomplete ???
300
301 Operational_Aspect : constant array (Aspect_Id) of Boolean :=
302 (Aspect_Constant_Indexing => True,
303 Aspect_Default_Iterator => True,
304 Aspect_Iterator_Element => True,
305 Aspect_Iterable => True,
306 Aspect_Variable_Indexing => True,
307 Aspect_Aggregate => True,
308 others => False);
309
310 -- The following array indicates aspects for which multiple occurrences of
311 -- the same aspect attached to the same declaration are allowed.
312
313 No_Duplicates_Allowed : constant array (Aspect_Id) of Boolean :=
314 (Aspect_Annotate => False,
315 Aspect_Test_Case => False,
316 others => True);
317
318 -- The following subtype defines aspects corresponding to library unit
319 -- pragmas, these can only validly appear as aspects for library units,
320 -- and result in a corresponding pragma being inserted immediately after
321 -- the occurrence of the aspect.
322
323 subtype Library_Unit_Aspects is
324 Aspect_Id range Aspect_All_Calls_Remote .. Aspect_Universal_Data;
325
326 -- The following subtype defines aspects accepting an optional static
327 -- boolean parameter indicating if the aspect should be active or
328 -- cancelling. If the parameter is missing the effective value is True,
329 -- enabling the aspect. If the parameter is present it must be a static
330 -- expression of type Standard.Boolean. If the value is True, then the
331 -- aspect is enabled. If it is False, the aspect is disabled.
332
333 subtype Boolean_Aspects is
334 Aspect_Id range Aspect_Asynchronous .. Aspect_Id'Last;
335
336 subtype Pre_Post_Aspects is
337 Aspect_Id range Aspect_Post .. Aspect_Precondition;
338
339 -- The following type is used for indicating allowed expression forms
340
341 type Aspect_Expression is
342 (Expression, -- Required expression
343 Name, -- Required name
344 Optional_Expression, -- Optional boolean expression
345 Optional_Name); -- Optional name
346
347 -- The following array indicates what argument type is required
348
349 Aspect_Argument : constant array (Aspect_Id) of Aspect_Expression :=
350 (No_Aspect => Optional_Expression,
351 Aspect_Abstract_State => Expression,
352 Aspect_Address => Expression,
353 Aspect_Aggregate => Expression,
354 Aspect_Alignment => Expression,
355 Aspect_Annotate => Expression,
356 Aspect_Async_Readers => Optional_Expression,
357 Aspect_Async_Writers => Optional_Expression,
358 Aspect_Attach_Handler => Expression,
359 Aspect_Bit_Order => Expression,
360 Aspect_Component_Size => Expression,
361 Aspect_Constant_After_Elaboration => Optional_Expression,
362 Aspect_Constant_Indexing => Name,
363 Aspect_Contract_Cases => Expression,
364 Aspect_Convention => Name,
365 Aspect_CPU => Expression,
366 Aspect_Default_Component_Value => Expression,
367 Aspect_Default_Initial_Condition => Optional_Expression,
368 Aspect_Default_Iterator => Name,
369 Aspect_Default_Storage_Pool => Expression,
370 Aspect_Default_Value => Expression,
371 Aspect_Depends => Expression,
372 Aspect_Dimension => Expression,
373 Aspect_Dimension_System => Expression,
374 Aspect_Dispatching_Domain => Expression,
375 Aspect_Dynamic_Predicate => Expression,
376 Aspect_Effective_Reads => Optional_Expression,
377 Aspect_Effective_Writes => Optional_Expression,
378 Aspect_Extensions_Visible => Optional_Expression,
379 Aspect_External_Name => Expression,
380 Aspect_External_Tag => Expression,
381 Aspect_Ghost => Optional_Expression,
382 Aspect_Global => Expression,
383 Aspect_Implicit_Dereference => Name,
384 Aspect_Initial_Condition => Expression,
385 Aspect_Initializes => Expression,
386 Aspect_Input => Name,
387 Aspect_Integer_Literal => Name,
388 Aspect_Interrupt_Priority => Expression,
389 Aspect_Invariant => Expression,
390 Aspect_Iterable => Expression,
391 Aspect_Iterator_Element => Name,
392 Aspect_Link_Name => Expression,
393 Aspect_Linker_Section => Expression,
394 Aspect_Machine_Radix => Expression,
395 Aspect_Max_Entry_Queue_Depth => Expression,
396 Aspect_Max_Entry_Queue_Length => Expression,
397 Aspect_Max_Queue_Length => Expression,
398 Aspect_No_Caching => Optional_Expression,
399 Aspect_Object_Size => Expression,
400 Aspect_Obsolescent => Optional_Expression,
401 Aspect_Output => Name,
402 Aspect_Part_Of => Expression,
403 Aspect_Post => Expression,
404 Aspect_Postcondition => Expression,
405 Aspect_Pre => Expression,
406 Aspect_Precondition => Expression,
407 Aspect_Predicate => Expression,
408 Aspect_Predicate_Failure => Expression,
409 Aspect_Priority => Expression,
410 Aspect_Put_Image => Name,
411 Aspect_Read => Name,
412 Aspect_Real_Literal => Name,
413 Aspect_Refined_Depends => Expression,
414 Aspect_Refined_Global => Expression,
415 Aspect_Refined_Post => Expression,
416 Aspect_Refined_State => Expression,
417 Aspect_Relative_Deadline => Expression,
418 Aspect_Relaxed_Initialization => Optional_Expression,
419 Aspect_Scalar_Storage_Order => Expression,
420 Aspect_Secondary_Stack_Size => Expression,
421 Aspect_Simple_Storage_Pool => Name,
422 Aspect_Size => Expression,
423 Aspect_Small => Expression,
424 Aspect_SPARK_Mode => Optional_Name,
425 Aspect_Static_Predicate => Expression,
426 Aspect_Storage_Pool => Name,
427 Aspect_Storage_Size => Expression,
428 Aspect_Stream_Size => Expression,
429 Aspect_String_Literal => Name,
430 Aspect_Subprogram_Variant => Expression,
431 Aspect_Suppress => Name,
432 Aspect_Synchronization => Name,
433 Aspect_Test_Case => Expression,
434 Aspect_Type_Invariant => Expression,
435 Aspect_Unimplemented => Optional_Expression,
436 Aspect_Unsuppress => Name,
437 Aspect_Value_Size => Expression,
438 Aspect_Variable_Indexing => Name,
439 Aspect_Volatile_Function => Optional_Expression,
440 Aspect_Warnings => Name,
441 Aspect_Write => Name,
442
443 Boolean_Aspects => Optional_Expression,
444 Library_Unit_Aspects => Optional_Expression);
445
446 -- The following array indicates what aspects are representation aspects
447
448 Is_Representation_Aspect : constant array (Aspect_Id) of Boolean :=
449 (No_Aspect => False,
450 Aspect_Abstract_State => False,
451 Aspect_Address => True,
452 Aspect_Aggregate => False,
453 Aspect_Alignment => True,
454 Aspect_Annotate => False,
455 Aspect_Async_Readers => False,
456 Aspect_Async_Writers => False,
457 Aspect_Attach_Handler => False,
458 Aspect_Bit_Order => True,
459 Aspect_Component_Size => True,
460 Aspect_Constant_After_Elaboration => False,
461 Aspect_Constant_Indexing => False,
462 Aspect_Contract_Cases => False,
463 Aspect_Convention => True,
464 Aspect_CPU => False,
465 Aspect_CUDA_Global => False,
466 Aspect_Default_Component_Value => True,
467 Aspect_Default_Initial_Condition => False,
468 Aspect_Default_Iterator => False,
469 Aspect_Default_Storage_Pool => True,
470 Aspect_Default_Value => True,
471 Aspect_Depends => False,
472 Aspect_Dimension => False,
473 Aspect_Dimension_System => False,
474 Aspect_Dispatching_Domain => False,
475 Aspect_Dynamic_Predicate => False,
476 Aspect_Effective_Reads => False,
477 Aspect_Effective_Writes => False,
478 Aspect_Exclusive_Functions => False,
479 Aspect_Extensions_Visible => False,
480 Aspect_External_Name => False,
481 Aspect_External_Tag => False,
482 Aspect_Ghost => False,
483 Aspect_Global => False,
484 Aspect_Implicit_Dereference => False,
485 Aspect_Initial_Condition => False,
486 Aspect_Initializes => False,
487 Aspect_Input => False,
488 Aspect_Integer_Literal => False,
489 Aspect_Interrupt_Priority => False,
490 Aspect_Invariant => False,
491 Aspect_Iterable => False,
492 Aspect_Iterator_Element => False,
493 Aspect_Link_Name => True,
494 Aspect_Linker_Section => True,
495 Aspect_Machine_Radix => True,
496 Aspect_Max_Entry_Queue_Depth => False,
497 Aspect_Max_Entry_Queue_Length => False,
498 Aspect_Max_Queue_Length => False,
499 Aspect_No_Caching => False,
500 Aspect_Object_Size => True,
501 Aspect_Obsolescent => False,
502 Aspect_Output => False,
503 Aspect_Part_Of => False,
504 Aspect_Post => False,
505 Aspect_Postcondition => False,
506 Aspect_Pre => False,
507 Aspect_Precondition => False,
508 Aspect_Predicate => False,
509 Aspect_Predicate_Failure => False,
510 Aspect_Priority => False,
511 Aspect_Put_Image => False,
512 Aspect_Read => False,
513 Aspect_Real_Literal => False,
514 Aspect_Refined_Depends => False,
515 Aspect_Refined_Global => False,
516 Aspect_Refined_Post => False,
517 Aspect_Refined_State => False,
518 Aspect_Relative_Deadline => False,
519 Aspect_Relaxed_Initialization => False,
520 Aspect_Scalar_Storage_Order => True,
521 Aspect_Secondary_Stack_Size => True,
522 Aspect_Simple_Storage_Pool => True,
523 Aspect_Size => True,
524 Aspect_Small => True,
525 Aspect_SPARK_Mode => False,
526 Aspect_Static_Predicate => False,
527 Aspect_Storage_Pool => True,
528 Aspect_Storage_Size => True,
529 Aspect_Stream_Size => True,
530 Aspect_String_Literal => False,
531 Aspect_Subprogram_Variant => False,
532 Aspect_Suppress => False,
533 Aspect_Synchronization => False,
534 Aspect_Test_Case => False,
535 Aspect_Type_Invariant => False,
536 Aspect_Unimplemented => False,
537 Aspect_Unsuppress => False,
538 Aspect_Value_Size => True,
539 Aspect_Variable_Indexing => False,
540 Aspect_Volatile_Function => False,
541 Aspect_Warnings => False,
542 Aspect_Write => False,
543
544 Library_Unit_Aspects => False,
545
546 Aspect_Asynchronous => True,
547 Aspect_Atomic => True,
548 Aspect_Atomic_Components => True,
549 Aspect_Disable_Controlled => False,
550 Aspect_Discard_Names => True,
551 Aspect_Export => True,
552 Aspect_Favor_Top_Level => False,
553 Aspect_Independent => True,
554 Aspect_Independent_Components => True,
555 Aspect_Import => True,
556 Aspect_Inline => False,
557 Aspect_Inline_Always => False,
558 Aspect_Interrupt_Handler => False,
559 Aspect_Lock_Free => False,
560 Aspect_No_Inline => False,
561 Aspect_No_Return => False,
562 Aspect_No_Tagged_Streams => False,
563 Aspect_Pack => True,
564 Aspect_Persistent_BSS => True,
565 Aspect_Preelaborable_Initialization => False,
566 Aspect_Pure_Function => False,
567 Aspect_Remote_Access_Type => False,
568 Aspect_Shared => True,
569 Aspect_Simple_Storage_Pool_Type => True,
570 Aspect_Static => False,
571 Aspect_Suppress_Debug_Info => False,
572 Aspect_Suppress_Initialization => False,
573 Aspect_Thread_Local_Storage => True,
574 Aspect_Unchecked_Union => True,
575 Aspect_Universal_Aliasing => False,
576 Aspect_Unmodified => False,
577 Aspect_Unreferenced => False,
578 Aspect_Unreferenced_Objects => False,
579 Aspect_Volatile => True,
580 Aspect_Volatile_Components => True,
581 Aspect_Volatile_Full_Access => True,
582 Aspect_Yield => False);
583
584 -----------------------------------------
585 -- Table Linking Names and Aspect_Id's --
586 -----------------------------------------
587
588 -- Table linking aspect names and id's
589
590 Aspect_Names : constant array (Aspect_Id) of Name_Id :=
591 (No_Aspect => No_Name,
592 Aspect_Abstract_State => Name_Abstract_State,
593 Aspect_Address => Name_Address,
594 Aspect_Aggregate => Name_Aggregate,
595 Aspect_Alignment => Name_Alignment,
596 Aspect_All_Calls_Remote => Name_All_Calls_Remote,
597 Aspect_Annotate => Name_Annotate,
598 Aspect_Async_Readers => Name_Async_Readers,
599 Aspect_Async_Writers => Name_Async_Writers,
600 Aspect_Asynchronous => Name_Asynchronous,
601 Aspect_Atomic => Name_Atomic,
602 Aspect_Atomic_Components => Name_Atomic_Components,
603 Aspect_Attach_Handler => Name_Attach_Handler,
604 Aspect_Bit_Order => Name_Bit_Order,
605 Aspect_Component_Size => Name_Component_Size,
606 Aspect_Constant_After_Elaboration => Name_Constant_After_Elaboration,
607 Aspect_Constant_Indexing => Name_Constant_Indexing,
608 Aspect_Contract_Cases => Name_Contract_Cases,
609 Aspect_Convention => Name_Convention,
610 Aspect_CPU => Name_CPU,
611 Aspect_CUDA_Global => Name_CUDA_Global,
612 Aspect_Default_Component_Value => Name_Default_Component_Value,
613 Aspect_Default_Initial_Condition => Name_Default_Initial_Condition,
614 Aspect_Default_Iterator => Name_Default_Iterator,
615 Aspect_Default_Storage_Pool => Name_Default_Storage_Pool,
616 Aspect_Default_Value => Name_Default_Value,
617 Aspect_Depends => Name_Depends,
618 Aspect_Dimension => Name_Dimension,
619 Aspect_Dimension_System => Name_Dimension_System,
620 Aspect_Disable_Controlled => Name_Disable_Controlled,
621 Aspect_Discard_Names => Name_Discard_Names,
622 Aspect_Dispatching_Domain => Name_Dispatching_Domain,
623 Aspect_Dynamic_Predicate => Name_Dynamic_Predicate,
624 Aspect_Effective_Reads => Name_Effective_Reads,
625 Aspect_Effective_Writes => Name_Effective_Writes,
626 Aspect_Elaborate_Body => Name_Elaborate_Body,
627 Aspect_Exclusive_Functions => Name_Exclusive_Functions,
628 Aspect_Export => Name_Export,
629 Aspect_Extensions_Visible => Name_Extensions_Visible,
630 Aspect_External_Name => Name_External_Name,
631 Aspect_External_Tag => Name_External_Tag,
632 Aspect_Favor_Top_Level => Name_Favor_Top_Level,
633 Aspect_Ghost => Name_Ghost,
634 Aspect_Global => Name_Global,
635 Aspect_Implicit_Dereference => Name_Implicit_Dereference,
636 Aspect_Import => Name_Import,
637 Aspect_Independent => Name_Independent,
638 Aspect_Independent_Components => Name_Independent_Components,
639 Aspect_Inline => Name_Inline,
640 Aspect_Inline_Always => Name_Inline_Always,
641 Aspect_Initial_Condition => Name_Initial_Condition,
642 Aspect_Initializes => Name_Initializes,
643 Aspect_Input => Name_Input,
644 Aspect_Integer_Literal => Name_Integer_Literal,
645 Aspect_Interrupt_Handler => Name_Interrupt_Handler,
646 Aspect_Interrupt_Priority => Name_Interrupt_Priority,
647 Aspect_Invariant => Name_Invariant,
648 Aspect_Iterator_Element => Name_Iterator_Element,
649 Aspect_Iterable => Name_Iterable,
650 Aspect_Link_Name => Name_Link_Name,
651 Aspect_Linker_Section => Name_Linker_Section,
652 Aspect_Lock_Free => Name_Lock_Free,
653 Aspect_Machine_Radix => Name_Machine_Radix,
654 Aspect_Max_Entry_Queue_Depth => Name_Max_Entry_Queue_Depth,
655 Aspect_Max_Entry_Queue_Length => Name_Max_Entry_Queue_Length,
656 Aspect_Max_Queue_Length => Name_Max_Queue_Length,
657 Aspect_No_Caching => Name_No_Caching,
658 Aspect_No_Elaboration_Code_All => Name_No_Elaboration_Code_All,
659 Aspect_No_Inline => Name_No_Inline,
660 Aspect_No_Return => Name_No_Return,
661 Aspect_No_Tagged_Streams => Name_No_Tagged_Streams,
662 Aspect_Object_Size => Name_Object_Size,
663 Aspect_Obsolescent => Name_Obsolescent,
664 Aspect_Output => Name_Output,
665 Aspect_Pack => Name_Pack,
666 Aspect_Part_Of => Name_Part_Of,
667 Aspect_Persistent_BSS => Name_Persistent_BSS,
668 Aspect_Post => Name_Post,
669 Aspect_Postcondition => Name_Postcondition,
670 Aspect_Pre => Name_Pre,
671 Aspect_Precondition => Name_Precondition,
672 Aspect_Predicate => Name_Predicate,
673 Aspect_Predicate_Failure => Name_Predicate_Failure,
674 Aspect_Preelaborable_Initialization => Name_Preelaborable_Initialization,
675 Aspect_Preelaborate => Name_Preelaborate,
676 Aspect_Priority => Name_Priority,
677 Aspect_Pure => Name_Pure,
678 Aspect_Pure_Function => Name_Pure_Function,
679 Aspect_Put_Image => Name_Put_Image,
680 Aspect_Read => Name_Read,
681 Aspect_Real_Literal => Name_Real_Literal,
682 Aspect_Refined_Depends => Name_Refined_Depends,
683 Aspect_Refined_Global => Name_Refined_Global,
684 Aspect_Refined_Post => Name_Refined_Post,
685 Aspect_Refined_State => Name_Refined_State,
686 Aspect_Relative_Deadline => Name_Relative_Deadline,
687 Aspect_Relaxed_Initialization => Name_Relaxed_Initialization,
688 Aspect_Remote_Access_Type => Name_Remote_Access_Type,
689 Aspect_Remote_Call_Interface => Name_Remote_Call_Interface,
690 Aspect_Remote_Types => Name_Remote_Types,
691 Aspect_Scalar_Storage_Order => Name_Scalar_Storage_Order,
692 Aspect_Secondary_Stack_Size => Name_Secondary_Stack_Size,
693 Aspect_Shared => Name_Shared,
694 Aspect_Shared_Passive => Name_Shared_Passive,
695 Aspect_Simple_Storage_Pool => Name_Simple_Storage_Pool,
696 Aspect_Simple_Storage_Pool_Type => Name_Simple_Storage_Pool_Type,
697 Aspect_Size => Name_Size,
698 Aspect_Small => Name_Small,
699 Aspect_SPARK_Mode => Name_SPARK_Mode,
700 Aspect_Static => Name_Static,
701 Aspect_Static_Predicate => Name_Static_Predicate,
702 Aspect_Storage_Pool => Name_Storage_Pool,
703 Aspect_Storage_Size => Name_Storage_Size,
704 Aspect_Stream_Size => Name_Stream_Size,
705 Aspect_String_Literal => Name_String_Literal,
706 Aspect_Subprogram_Variant => Name_Subprogram_Variant,
707 Aspect_Suppress => Name_Suppress,
708 Aspect_Suppress_Debug_Info => Name_Suppress_Debug_Info,
709 Aspect_Suppress_Initialization => Name_Suppress_Initialization,
710 Aspect_Thread_Local_Storage => Name_Thread_Local_Storage,
711 Aspect_Synchronization => Name_Synchronization,
712 Aspect_Test_Case => Name_Test_Case,
713 Aspect_Type_Invariant => Name_Type_Invariant,
714 Aspect_Unchecked_Union => Name_Unchecked_Union,
715 Aspect_Unimplemented => Name_Unimplemented,
716 Aspect_Universal_Aliasing => Name_Universal_Aliasing,
717 Aspect_Universal_Data => Name_Universal_Data,
718 Aspect_Unmodified => Name_Unmodified,
719 Aspect_Unreferenced => Name_Unreferenced,
720 Aspect_Unreferenced_Objects => Name_Unreferenced_Objects,
721 Aspect_Unsuppress => Name_Unsuppress,
722 Aspect_Value_Size => Name_Value_Size,
723 Aspect_Variable_Indexing => Name_Variable_Indexing,
724 Aspect_Volatile => Name_Volatile,
725 Aspect_Volatile_Components => Name_Volatile_Components,
726 Aspect_Volatile_Full_Access => Name_Volatile_Full_Access,
727 Aspect_Volatile_Function => Name_Volatile_Function,
728 Aspect_Warnings => Name_Warnings,
729 Aspect_Write => Name_Write,
730 Aspect_Yield => Name_Yield);
731
732 function Get_Aspect_Id (Name : Name_Id) return Aspect_Id;
733 pragma Inline (Get_Aspect_Id);
734 -- Given a name Nam, returns the corresponding aspect id value. If the name
735 -- does not match any aspect, then No_Aspect is returned as the result.
736
737 function Get_Aspect_Id (Aspect : Node_Id) return Aspect_Id;
738 pragma Inline (Get_Aspect_Id);
739 -- Given an aspect specification, return the corresponding aspect_id value.
740 -- If the name does not match any aspect, return No_Aspect.
741
742 ------------------------------------
743 -- Delaying Evaluation of Aspects --
744 ------------------------------------
745
746 -- The RM requires that all language defined aspects taking an expression
747 -- delay evaluation of the expression till the freeze point of the entity
748 -- to which the aspect applies. This allows forward references, and is of
749 -- use for example in connection with preconditions and postconditions
750 -- where the requirement of making all references in contracts to local
751 -- functions be backwards references would be onerous.
752
753 -- For consistency, even attributes like Size are delayed, so we can do:
754
755 -- type A is range 1 .. 10
756 -- with Size => Not_Defined_Yet;
757 -- ..
758 -- Not_Defined_Yet : constant := 64;
759
760 -- Resulting in A having a size of 64, which gets set when A is frozen.
761 -- Furthermore, we can have a situation like
762
763 -- type A is range 1 .. 10
764 -- with Size => Not_Defined_Yet;
765 -- ..
766 -- type B is new A;
767 -- ..
768 -- Not_Defined_Yet : constant := 64;
769
770 -- where the Size of A is considered to have been previously specified at
771 -- the point of derivation, even though the actual value of the size is
772 -- not known yet, and in this example B inherits the size value of 64.
773
774 -- Our normal implementation model (prior to Ada 2012) was simply to copy
775 -- inheritable attributes at the point of derivation. Then any subsequent
776 -- representation items apply either to the parent type, not affecting the
777 -- derived type, or to the derived type, not affecting the parent type.
778
779 -- To deal with the delayed aspect case, we use two flags. The first is
780 -- set on the parent type if it has delayed representation aspects. This
781 -- flag Has_Delayed_Rep_Aspects indicates that if we derive from this type
782 -- we have to worry about making sure we inherit any delayed aspects. The
783 -- second flag is set on a derived type: May_Have_Inherited_Rep_Aspects
784 -- is set if the parent type has Has_Delayed_Rep_Aspects set.
785
786 -- When we freeze a derived type, if the May_Have_Inherited_Rep_Aspects
787 -- flag is set, then we call Freeze.Inherit_Delayed_Rep_Aspects when
788 -- the derived type is frozen, which deals with the necessary copying of
789 -- information from the parent type, which must be frozen at that point
790 -- (since freezing the derived type first freezes the parent type).
791
792 -- SPARK 2014 aspects do not follow the general delay mechanism as they
793 -- act as annotations and cannot modify the attributes of their related
794 -- constructs. To handle forward references in such aspects, the compiler
795 -- delays the analysis of their respective pragmas by collecting them in
796 -- N_Contract nodes. The pragmas are then analyzed at the end of the
797 -- declarative region containing the related construct. For details,
798 -- see routines Analyze_xxx_In_Decl_Part.
799
800 -- The following shows which aspects are delayed. There are three cases:
801
802 type Delay_Type is
803 (Always_Delay,
804 -- This aspect is not a representation aspect that can be inherited and
805 -- is always delayed, as required by the language definition.
806
807 Never_Delay,
808 -- There are two cases. There are language defined aspects like
809 -- Convention where the "expression" is simply an uninterpreted
810 -- identifier, and there is no issue of evaluating it and thus no
811 -- issue of delaying the evaluation. The second case is implementation
812 -- defined aspects where we have decided that we don't want to allow
813 -- delays (and for our own aspects we can do what we like).
814
815 Rep_Aspect);
816 -- These are the cases of representation aspects that are in general
817 -- delayed, and where there is a potential issue of derived types that
818 -- inherit delayed representation values.
819
820 -- Note: even if this table indicates that an aspect is delayed, we never
821 -- delay Boolean aspects that have a missing expression (taken as True),
822 -- or expressions for delayed rep items that consist of an integer literal
823 -- (most cases of Size etc. in practice), since in these cases we know we
824 -- can get the value of the expression without delay. Note that we still
825 -- need to delay Boolean aspects that are specifically set to True:
826
827 -- type R is array (0 .. 31) of Boolean
828 -- with Pack => True;
829 -- True : constant Boolean := False;
830
831 -- This is nonsense, but we need to make it work and result in R not
832 -- being packed, and if we have something like:
833
834 -- type R is array (0 .. 31) of Boolean
835 -- with Pack => True;
836 -- RR : R;
837 -- True : constant Boolean := False;
838
839 -- This is illegal because the visibility of True changes after the freeze
840 -- point, which is not allowed, and we need the delay mechanism to properly
841 -- diagnose this error.
842
843 Aspect_Delay : constant array (Aspect_Id) of Delay_Type :=
844 (No_Aspect => Always_Delay,
845 Aspect_Address => Always_Delay,
846 Aspect_Aggregate => Always_Delay,
847 Aspect_All_Calls_Remote => Always_Delay,
848 Aspect_Asynchronous => Always_Delay,
849 Aspect_Attach_Handler => Always_Delay,
850 Aspect_Constant_Indexing => Always_Delay,
851 Aspect_CPU => Always_Delay,
852 Aspect_CUDA_Global => Always_Delay,
853 Aspect_Default_Iterator => Always_Delay,
854 Aspect_Default_Storage_Pool => Always_Delay,
855 Aspect_Default_Value => Always_Delay,
856 Aspect_Default_Component_Value => Always_Delay,
857 Aspect_Discard_Names => Always_Delay,
858 Aspect_Dispatching_Domain => Always_Delay,
859 Aspect_Dynamic_Predicate => Always_Delay,
860 Aspect_Elaborate_Body => Always_Delay,
861 Aspect_Exclusive_Functions => Always_Delay,
862 Aspect_External_Name => Always_Delay,
863 Aspect_External_Tag => Always_Delay,
864 Aspect_Favor_Top_Level => Always_Delay,
865 Aspect_Implicit_Dereference => Always_Delay,
866 Aspect_Independent => Always_Delay,
867 Aspect_Independent_Components => Always_Delay,
868 Aspect_Inline => Always_Delay,
869 Aspect_Inline_Always => Always_Delay,
870 Aspect_Input => Always_Delay,
871 Aspect_Integer_Literal => Always_Delay,
872 Aspect_Interrupt_Handler => Always_Delay,
873 Aspect_Interrupt_Priority => Always_Delay,
874 Aspect_Invariant => Always_Delay,
875 Aspect_Iterable => Always_Delay,
876 Aspect_Iterator_Element => Always_Delay,
877 Aspect_Link_Name => Always_Delay,
878 Aspect_Linker_Section => Always_Delay,
879 Aspect_Lock_Free => Always_Delay,
880 Aspect_No_Inline => Always_Delay,
881 Aspect_No_Return => Always_Delay,
882 Aspect_Output => Always_Delay,
883 Aspect_Persistent_BSS => Always_Delay,
884 Aspect_Post => Always_Delay,
885 Aspect_Postcondition => Always_Delay,
886 Aspect_Pre => Always_Delay,
887 Aspect_Precondition => Always_Delay,
888 Aspect_Predicate => Always_Delay,
889 Aspect_Predicate_Failure => Always_Delay,
890 Aspect_Preelaborable_Initialization => Always_Delay,
891 Aspect_Preelaborate => Always_Delay,
892 Aspect_Priority => Always_Delay,
893 Aspect_Pure => Always_Delay,
894 Aspect_Pure_Function => Always_Delay,
895 Aspect_Put_Image => Always_Delay,
896 Aspect_Read => Always_Delay,
897 Aspect_Real_Literal => Always_Delay,
898 Aspect_Relative_Deadline => Always_Delay,
899 Aspect_Remote_Access_Type => Always_Delay,
900 Aspect_Remote_Call_Interface => Always_Delay,
901 Aspect_Remote_Types => Always_Delay,
902 Aspect_Secondary_Stack_Size => Always_Delay,
903 Aspect_Shared => Always_Delay,
904 Aspect_Shared_Passive => Always_Delay,
905 Aspect_Simple_Storage_Pool => Always_Delay,
906 Aspect_Simple_Storage_Pool_Type => Always_Delay,
907 Aspect_Static_Predicate => Always_Delay,
908 Aspect_Storage_Pool => Always_Delay,
909 Aspect_Stream_Size => Always_Delay,
910 Aspect_String_Literal => Always_Delay,
911 Aspect_Suppress => Always_Delay,
912 Aspect_Suppress_Debug_Info => Always_Delay,
913 Aspect_Suppress_Initialization => Always_Delay,
914 Aspect_Thread_Local_Storage => Always_Delay,
915 Aspect_Type_Invariant => Always_Delay,
916 Aspect_Unchecked_Union => Always_Delay,
917 Aspect_Universal_Aliasing => Always_Delay,
918 Aspect_Universal_Data => Always_Delay,
919 Aspect_Unmodified => Always_Delay,
920 Aspect_Unreferenced => Always_Delay,
921 Aspect_Unreferenced_Objects => Always_Delay,
922 Aspect_Unsuppress => Always_Delay,
923 Aspect_Variable_Indexing => Always_Delay,
924 Aspect_Write => Always_Delay,
925
926 Aspect_Abstract_State => Never_Delay,
927 Aspect_Annotate => Never_Delay,
928 Aspect_Async_Readers => Never_Delay,
929 Aspect_Async_Writers => Never_Delay,
930 Aspect_Constant_After_Elaboration => Never_Delay,
931 Aspect_Contract_Cases => Never_Delay,
932 Aspect_Convention => Never_Delay,
933 Aspect_Default_Initial_Condition => Never_Delay,
934 Aspect_Depends => Never_Delay,
935 Aspect_Dimension => Never_Delay,
936 Aspect_Dimension_System => Never_Delay,
937 Aspect_Disable_Controlled => Never_Delay,
938 Aspect_Effective_Reads => Never_Delay,
939 Aspect_Effective_Writes => Never_Delay,
940 Aspect_Export => Never_Delay,
941 Aspect_Extensions_Visible => Never_Delay,
942 Aspect_Ghost => Never_Delay,
943 Aspect_Global => Never_Delay,
944 Aspect_Import => Never_Delay,
945 Aspect_Initial_Condition => Never_Delay,
946 Aspect_Initializes => Never_Delay,
947 Aspect_Max_Entry_Queue_Depth => Never_Delay,
948 Aspect_Max_Entry_Queue_Length => Never_Delay,
949 Aspect_Max_Queue_Length => Never_Delay,
950 Aspect_No_Caching => Never_Delay,
951 Aspect_No_Elaboration_Code_All => Never_Delay,
952 Aspect_No_Tagged_Streams => Never_Delay,
953 Aspect_Obsolescent => Never_Delay,
954 Aspect_Part_Of => Never_Delay,
955 Aspect_Refined_Depends => Never_Delay,
956 Aspect_Refined_Global => Never_Delay,
957 Aspect_Refined_Post => Never_Delay,
958 Aspect_Refined_State => Never_Delay,
959 Aspect_Relaxed_Initialization => Never_Delay,
960 Aspect_SPARK_Mode => Never_Delay,
961 Aspect_Static => Never_Delay,
962 Aspect_Subprogram_Variant => Never_Delay,
963 Aspect_Synchronization => Never_Delay,
964 Aspect_Test_Case => Never_Delay,
965 Aspect_Unimplemented => Never_Delay,
966 Aspect_Volatile_Function => Never_Delay,
967 Aspect_Warnings => Never_Delay,
968 Aspect_Yield => Never_Delay,
969
970 Aspect_Alignment => Rep_Aspect,
971 Aspect_Atomic => Rep_Aspect,
972 Aspect_Atomic_Components => Rep_Aspect,
973 Aspect_Bit_Order => Rep_Aspect,
974 Aspect_Component_Size => Rep_Aspect,
975 Aspect_Machine_Radix => Rep_Aspect,
976 Aspect_Object_Size => Rep_Aspect,
977 Aspect_Pack => Rep_Aspect,
978 Aspect_Scalar_Storage_Order => Rep_Aspect,
979 Aspect_Size => Rep_Aspect,
980 Aspect_Small => Rep_Aspect,
981 Aspect_Storage_Size => Rep_Aspect,
982 Aspect_Value_Size => Rep_Aspect,
983 Aspect_Volatile => Rep_Aspect,
984 Aspect_Volatile_Components => Rep_Aspect,
985 Aspect_Volatile_Full_Access => Rep_Aspect);
986
987 ------------------------------------------------
988 -- Handling of Aspect Specifications on Stubs --
989 ------------------------------------------------
990
991 -- Aspects that appear on the following stub nodes
992
993 -- N_Package_Body_Stub
994 -- N_Protected_Body_Stub
995 -- N_Subprogram_Body_Stub
996 -- N_Task_Body_Stub
997
998 -- are treated as if they apply to the corresponding proper body. Their
999 -- analysis is postponed until the analysis of the proper body takes place
1000 -- (see Analyze_Proper_Body). The delay is required because the analysis
1001 -- may generate extra code which would be harder to relocate to the body.
1002 -- If the proper body is present, the aspect specifications are relocated
1003 -- to the corresponding body node:
1004
1005 -- N_Package_Body
1006 -- N_Protected_Body
1007 -- N_Subprogram_Body
1008 -- N_Task_Body
1009
1010 -- The subsequent analysis takes care of the aspect-to-pragma conversions
1011 -- and verification of pragma legality. In the case where the proper body
1012 -- is not available, the aspect specifications are analyzed on the spot
1013 -- (see Analyze_Proper_Body) to catch potential errors.
1014
1015 -- The following table lists all aspects that can apply to a subprogram
1016 -- body [stub]. For instance, the following example is legal:
1017
1018 -- package P with SPARK_Mode ...;
1019 -- package body P with SPARK_Mode is ...;
1020
1021 -- The table should be synchronized with Pragma_On_Body_Or_Stub_OK in unit
1022 -- Sem_Prag.
1023
1024 Aspect_On_Body_Or_Stub_OK : constant array (Aspect_Id) of Boolean :=
1025 (Aspect_Refined_Depends => True,
1026 Aspect_Refined_Global => True,
1027 Aspect_Refined_Post => True,
1028 Aspect_SPARK_Mode => True,
1029 Aspect_Warnings => True,
1030 others => False);
1031
1032 -------------------------------------------------------------------
1033 -- Handling of Aspects Specifications on Single Concurrent Types --
1034 -------------------------------------------------------------------
1035
1036 -- Certain aspects that appear on the following nodes
1037
1038 -- N_Single_Protected_Declaration
1039 -- N_Single_Task_Declaration
1040
1041 -- are treated as if they apply to the anonymous object produced by the
1042 -- analysis of a single concurrent type. The following table lists all
1043 -- aspects that should apply to the anonymous object. The table should
1044 -- be synchronized with Pragma_On_Anonymous_Object_OK in unit Sem_Prag.
1045
1046 Aspect_On_Anonymous_Object_OK : constant array (Aspect_Id) of Boolean :=
1047 (Aspect_Depends => True,
1048 Aspect_Global => True,
1049 Aspect_Part_Of => True,
1050 others => False);
1051
1052 ---------------------------------------------------
1053 -- Handling of Aspect Specifications in the Tree --
1054 ---------------------------------------------------
1055
1056 -- Several kinds of declaration node permit aspect specifications in Ada
1057 -- 2012 mode. If there was room in all the corresponding declaration nodes,
1058 -- we could just have a field Aspect_Specifications pointing to a list of
1059 -- nodes for the aspects (N_Aspect_Specification nodes). But there isn't
1060 -- room, so we adopt a different approach.
1061
1062 -- The following subprograms provide access to a specialized interface
1063 -- implemented internally with a hash table in the body, that provides
1064 -- access to aspect specifications.
1065
1066 function Aspect_Specifications (N : Node_Id) return List_Id;
1067 -- Given a node N, returns the list of N_Aspect_Specification nodes that
1068 -- are attached to this declaration node. If the node is in the class of
1069 -- declaration nodes that permit aspect specifications, as defined by the
1070 -- predicate above, and if their Has_Aspects flag is set to True, then this
1071 -- will always be a non-empty list. If this flag is set to False, then
1072 -- No_List is returned. Normally, the only nodes that have Has_Aspects set
1073 -- True are the nodes for which Permits_Aspect_Specifications would return
1074 -- True (i.e. the declaration nodes defined in the RM as permitting the
1075 -- presence of Aspect_Specifications). However, it is possible for the
1076 -- flag Has_Aspects to be set on other nodes as a result of Rewrite and
1077 -- Replace calls, and this function may be used to retrieve the aspect
1078 -- specifications for the original rewritten node in such cases.
1079
1080 function Aspects_On_Body_Or_Stub_OK (N : Node_Id) return Boolean;
1081 -- N denotes a body [stub] with aspects. Determine whether all aspects of N
1082 -- are allowed to appear on a body [stub].
1083
1084 procedure Exchange_Aspects (N1 : Node_Id; N2 : Node_Id);
1085 -- Exchange the aspect specifications of two nodes. If either node lacks an
1086 -- aspect specification list, the routine has no effect. It is assumed that
1087 -- both nodes can support aspects.
1088
1089 function Find_Aspect (Id : Entity_Id; A : Aspect_Id) return Node_Id;
1090 -- Find the aspect specification of aspect A associated with entity I.
1091 -- Return Empty if Id does not have the requested aspect.
1092
1093 function Find_Value_Of_Aspect
1094 (Id : Entity_Id;
1095 A : Aspect_Id) return Node_Id;
1096 -- Find the value of aspect A associated with entity Id. Return Empty if
1097 -- Id does not have the requested aspect.
1098
1099 function Has_Aspect (Id : Entity_Id; A : Aspect_Id) return Boolean;
1100 -- Determine whether entity Id has aspect A
1101
1102 procedure Move_Aspects (From : Node_Id; To : Node_Id);
1103 -- Relocate the aspect specifications of node From to node To. On entry it
1104 -- is assumed that To does not have aspect specifications. If From has no
1105 -- aspects, the routine has no effect.
1106
1107 procedure Move_Or_Merge_Aspects (From : Node_Id; To : Node_Id);
1108 -- Relocate the aspect specifications of node From to node To. If To has
1109 -- aspects, the aspects of From are appended to the aspects of To. If From
1110 -- has no aspects, the routine has no effect. Special behavior:
1111 -- * When node From denotes a subprogram body stub without a previous
1112 -- declaration, the only aspects relocated to node To are those found
1113 -- in table Aspect_On_Body_Or_Stub_OK.
1114 -- * When node From denotes a single synchronized type declaration, the
1115 -- only aspects relocated to node To are those found in table
1116 -- Aspect_On_Anonymous_Object_OK.
1117
1118 function Permits_Aspect_Specifications (N : Node_Id) return Boolean;
1119 -- Returns True if the node N is a declaration node that permits aspect
1120 -- specifications in the grammar. It is possible for other nodes to have
1121 -- aspect specifications as a result of Rewrite or Replace calls.
1122
1123 procedure Remove_Aspects (N : Node_Id);
1124 -- Delete the aspect specifications associated with node N. If the node has
1125 -- no aspects, the routine has no effect.
1126
1127 function Same_Aspect (A1 : Aspect_Id; A2 : Aspect_Id) return Boolean;
1128 -- Returns True if A1 and A2 are (essentially) the same aspect. This is not
1129 -- a simple equality test because e.g. Post and Postcondition are the same.
1130 -- This is used for detecting duplicate aspects.
1131
1132 procedure Set_Aspect_Specifications (N : Node_Id; L : List_Id);
1133 -- The node N must be in the class of declaration nodes that permit aspect
1134 -- specifications and the Has_Aspects flag must be False on entry. L must
1135 -- be a non-empty list of N_Aspect_Specification nodes. This procedure sets
1136 -- the Has_Aspects flag to True, and makes an entry that can be retrieved
1137 -- by a subsequent Aspect_Specifications call. It is an error to call this
1138 -- procedure with a node that does not permit aspect specifications, or a
1139 -- node that has its Has_Aspects flag set True on entry, or with L being an
1140 -- empty list or No_List.
1141
1142 end Aspects;