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