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