Debian Codegraph @

gcc/ada/aspects.ads

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