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