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