[multiple changes]
[gcc.git] / gcc / ada / aspects.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A S P E C T S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2010-2013, 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 ------------------------------------------------------------------------------
31
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.
36
37 ------------------------
38 -- Adding New Aspects --
39 ------------------------
40
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.
46
47 -- To add a new aspect, you need to do the following
48
49 -- 1. Create a name in snames.ads-tmpl
50
51 -- 2. Create a value in type Aspect_Id in this unit
52
53 -- 3. Add a value for the aspect in the global arrays defined in this unit
54
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.
58
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.
66
67 with Namet; use Namet;
68 with Snames; use Snames;
69 with Types; use Types;
70
71 package Aspects is
72
73 -- Type defining recognized aspects
74
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_Attach_Handler,
81 Aspect_Bit_Order,
82 Aspect_Component_Size,
83 Aspect_Constant_Indexing,
84 Aspect_Contract_Cases, -- GNAT
85 Aspect_Convention,
86 Aspect_CPU,
87 Aspect_Default_Component_Value,
88 Aspect_Default_Iterator,
89 Aspect_Default_Value,
90 Aspect_Depends, -- GNAT
91 Aspect_Dimension, -- GNAT
92 Aspect_Dimension_System, -- GNAT
93 Aspect_Dispatching_Domain,
94 Aspect_Dynamic_Predicate,
95 Aspect_External_Name,
96 Aspect_External_Tag,
97 Aspect_Global, -- GNAT
98 Aspect_Implicit_Dereference,
99 Aspect_Input,
100 Aspect_Interrupt_Priority,
101 Aspect_Invariant, -- GNAT
102 Aspect_Iterator_Element,
103 Aspect_Link_Name,
104 Aspect_Machine_Radix,
105 Aspect_Object_Size, -- GNAT
106 Aspect_Output,
107 Aspect_Post,
108 Aspect_Postcondition,
109 Aspect_Pre,
110 Aspect_Precondition,
111 Aspect_Predicate, -- GNAT
112 Aspect_Priority,
113 Aspect_Read,
114 Aspect_Relative_Deadline,
115 Aspect_Scalar_Storage_Order, -- GNAT
116 Aspect_Simple_Storage_Pool, -- GNAT
117 Aspect_Size,
118 Aspect_Small,
119 Aspect_SPARK_Mode, -- GNAT
120 Aspect_Static_Predicate,
121 Aspect_Storage_Pool,
122 Aspect_Storage_Size,
123 Aspect_Stream_Size,
124 Aspect_Suppress,
125 Aspect_Synchronization,
126 Aspect_Test_Case, -- GNAT
127 Aspect_Type_Invariant,
128 Aspect_Unsuppress,
129 Aspect_Value_Size, -- GNAT
130 Aspect_Variable_Indexing,
131 Aspect_Warnings, -- GNAT
132 Aspect_Write,
133
134 -- The following aspects correspond to library unit pragmas
135
136 Aspect_All_Calls_Remote,
137 Aspect_Compiler_Unit, -- GNAT
138 Aspect_Elaborate_Body,
139 Aspect_Preelaborate,
140 Aspect_Preelaborate_05, -- GNAT
141 Aspect_Pure,
142 Aspect_Pure_05, -- GNAT
143 Aspect_Pure_12, -- GNAT
144 Aspect_Remote_Call_Interface,
145 Aspect_Remote_Types,
146 Aspect_Shared_Passive,
147 Aspect_Universal_Data, -- GNAT
148
149 -- Remaining aspects have a static boolean value that turns the aspect
150 -- on or off. They all correspond to pragmas, but are only converted to
151 -- the pragmas where the value is True. A value of False normally means
152 -- that the aspect is ignored, except in the case of derived types where
153 -- the aspect value is inherited from the parent, in which case, we do
154 -- not allow False if we inherit a True value from the parent.
155
156 Aspect_Ada_2005, -- GNAT
157 Aspect_Ada_2012, -- GNAT
158 Aspect_Asynchronous,
159 Aspect_Atomic,
160 Aspect_Atomic_Components,
161 Aspect_Discard_Names,
162 Aspect_Export,
163 Aspect_Favor_Top_Level, -- GNAT
164 Aspect_Independent,
165 Aspect_Independent_Components,
166 Aspect_Import,
167 Aspect_Inline,
168 Aspect_Inline_Always, -- GNAT
169 Aspect_Interrupt_Handler,
170 Aspect_No_Return,
171 Aspect_Pack,
172 Aspect_Persistent_BSS, -- GNAT
173 Aspect_Preelaborable_Initialization,
174 Aspect_Pure_Function, -- GNAT
175 Aspect_Remote_Access_Type, -- GNAT
176 Aspect_Shared, -- GNAT (equivalent to Atomic)
177 Aspect_Simple_Storage_Pool_Type, -- GNAT
178 Aspect_Suppress_Debug_Info, -- GNAT
179 Aspect_Unchecked_Union,
180 Aspect_Universal_Aliasing, -- GNAT
181 Aspect_Unmodified, -- GNAT
182 Aspect_Unreferenced, -- GNAT
183 Aspect_Unreferenced_Objects, -- GNAT
184 Aspect_Volatile,
185 Aspect_Volatile_Components,
186
187 -- Aspects that have a static boolean value but don't correspond to
188 -- pragmas
189
190 Aspect_Lock_Free); -- GNAT
191
192 subtype Aspect_Id_Exclude_No_Aspect is
193 Aspect_Id range Aspect_Id'Succ (No_Aspect) .. Aspect_Id'Last;
194 -- Aspect_Id's excluding No_Aspect
195
196 -- The following array indicates aspects that accept 'Class
197
198 Class_Aspect_OK : constant array (Aspect_Id) of Boolean :=
199 (Aspect_Invariant => True,
200 Aspect_Pre => True,
201 Aspect_Predicate => True,
202 Aspect_Post => True,
203 Aspect_Type_Invariant => True,
204 others => False);
205
206 -- The following array identifies all implementation defined aspects
207
208 Implementation_Defined_Aspect : constant array (Aspect_Id) of Boolean :=
209 (Aspect_Abstract_State => True,
210 Aspect_Ada_2005 => True,
211 Aspect_Ada_2012 => True,
212 Aspect_Compiler_Unit => True,
213 Aspect_Contract_Cases => True,
214 Aspect_Depends => True,
215 Aspect_Dimension => True,
216 Aspect_Dimension_System => True,
217 Aspect_Favor_Top_Level => True,
218 Aspect_Global => True,
219 Aspect_Inline_Always => True,
220 Aspect_Invariant => True,
221 Aspect_Lock_Free => True,
222 Aspect_Object_Size => True,
223 Aspect_Persistent_BSS => True,
224 Aspect_Predicate => True,
225 Aspect_Preelaborate_05 => True,
226 Aspect_Pure_05 => True,
227 Aspect_Pure_12 => True,
228 Aspect_Pure_Function => True,
229 Aspect_Remote_Access_Type => True,
230 Aspect_Scalar_Storage_Order => True,
231 Aspect_Shared => True,
232 Aspect_Simple_Storage_Pool => True,
233 Aspect_Simple_Storage_Pool_Type => True,
234 Aspect_Suppress_Debug_Info => True,
235 Aspect_Test_Case => True,
236 Aspect_Universal_Aliasing => True,
237 Aspect_Universal_Data => True,
238 Aspect_Unmodified => True,
239 Aspect_Unreferenced => True,
240 Aspect_Unreferenced_Objects => True,
241 Aspect_Value_Size => True,
242 Aspect_Warnings => True,
243 others => False);
244
245 -- The following array indicates aspects for which multiple occurrences of
246 -- the same aspect attached to the same declaration are allowed.
247
248 No_Duplicates_Allowed : constant array (Aspect_Id) of Boolean :=
249 (Aspect_Test_Case => False,
250 others => True);
251
252 -- The following subtype defines aspects corresponding to library unit
253 -- pragmas, these can only validly appear as aspects for library units,
254 -- and result in a corresponding pragma being inserted immediately after
255 -- the occurrence of the aspect.
256
257 subtype Library_Unit_Aspects is
258 Aspect_Id range Aspect_All_Calls_Remote .. Aspect_Universal_Data;
259
260 -- The following subtype defines aspects accepting an optional static
261 -- boolean parameter indicating if the aspect should be active or
262 -- cancelling. If the parameter is missing the effective value is True,
263 -- enabling the aspect. If the parameter is present it must be a static
264 -- expression of type Standard.Boolean. If the value is True, then the
265 -- aspect is enabled. If it is False, the aspect is disabled.
266
267 subtype Boolean_Aspects is
268 Aspect_Id range Aspect_Ada_2005 .. Aspect_Id'Last;
269
270 subtype Pre_Post_Aspects is
271 Aspect_Id range Aspect_Post .. Aspect_Precondition;
272
273 -- The following type is used for indicating allowed expression forms
274
275 type Aspect_Expression is
276 (Expression, -- Required expression
277 Name, -- Required name
278 Optional_Expression, -- Optional boolean expression
279 Optional_Name); -- Optional name
280
281 -- The following array indicates what argument type is required
282
283 Aspect_Argument : constant array (Aspect_Id) of Aspect_Expression :=
284 (No_Aspect => Optional_Expression,
285 Aspect_Abstract_State => Expression,
286 Aspect_Address => Expression,
287 Aspect_Alignment => Expression,
288 Aspect_Attach_Handler => Expression,
289 Aspect_Bit_Order => Expression,
290 Aspect_Component_Size => Expression,
291 Aspect_Constant_Indexing => Name,
292 Aspect_Contract_Cases => Expression,
293 Aspect_Convention => Name,
294 Aspect_CPU => Expression,
295 Aspect_Default_Component_Value => Expression,
296 Aspect_Default_Iterator => Name,
297 Aspect_Default_Value => Expression,
298 Aspect_Depends => Expression,
299 Aspect_Dimension => Expression,
300 Aspect_Dimension_System => Expression,
301 Aspect_Dispatching_Domain => Expression,
302 Aspect_Dynamic_Predicate => Expression,
303 Aspect_External_Name => Expression,
304 Aspect_External_Tag => Expression,
305 Aspect_Global => Expression,
306 Aspect_Implicit_Dereference => Name,
307 Aspect_Input => Name,
308 Aspect_Interrupt_Priority => Expression,
309 Aspect_Invariant => Expression,
310 Aspect_Iterator_Element => Name,
311 Aspect_Link_Name => Expression,
312 Aspect_Machine_Radix => Expression,
313 Aspect_Object_Size => Expression,
314 Aspect_Output => Name,
315 Aspect_Post => Expression,
316 Aspect_Postcondition => Expression,
317 Aspect_Pre => Expression,
318 Aspect_Precondition => Expression,
319 Aspect_Predicate => Expression,
320 Aspect_Priority => Expression,
321 Aspect_Read => Name,
322 Aspect_Relative_Deadline => Expression,
323 Aspect_Scalar_Storage_Order => Expression,
324 Aspect_Simple_Storage_Pool => Name,
325 Aspect_Size => Expression,
326 Aspect_Small => Expression,
327 Aspect_SPARK_Mode => Optional_Name,
328 Aspect_Static_Predicate => Expression,
329 Aspect_Storage_Pool => Name,
330 Aspect_Storage_Size => Expression,
331 Aspect_Stream_Size => Expression,
332 Aspect_Suppress => Name,
333 Aspect_Synchronization => Name,
334 Aspect_Test_Case => Expression,
335 Aspect_Type_Invariant => Expression,
336 Aspect_Unsuppress => Name,
337 Aspect_Value_Size => Expression,
338 Aspect_Variable_Indexing => Name,
339 Aspect_Warnings => Name,
340 Aspect_Write => Name,
341
342 Boolean_Aspects => Optional_Expression,
343 Library_Unit_Aspects => Optional_Expression);
344
345 -----------------------------------------
346 -- Table Linking Names and Aspect_Id's --
347 -----------------------------------------
348
349 -- Table linking aspect names and id's
350
351 Aspect_Names : constant array (Aspect_Id) of Name_Id :=
352 (No_Aspect => No_Name,
353 Aspect_Abstract_State => Name_Abstract_State,
354 Aspect_Ada_2005 => Name_Ada_2005,
355 Aspect_Ada_2012 => Name_Ada_2012,
356 Aspect_Address => Name_Address,
357 Aspect_Alignment => Name_Alignment,
358 Aspect_All_Calls_Remote => Name_All_Calls_Remote,
359 Aspect_Asynchronous => Name_Asynchronous,
360 Aspect_Atomic => Name_Atomic,
361 Aspect_Atomic_Components => Name_Atomic_Components,
362 Aspect_Attach_Handler => Name_Attach_Handler,
363 Aspect_Bit_Order => Name_Bit_Order,
364 Aspect_Compiler_Unit => Name_Compiler_Unit,
365 Aspect_Component_Size => Name_Component_Size,
366 Aspect_Constant_Indexing => Name_Constant_Indexing,
367 Aspect_Contract_Cases => Name_Contract_Cases,
368 Aspect_Convention => Name_Convention,
369 Aspect_CPU => Name_CPU,
370 Aspect_Default_Iterator => Name_Default_Iterator,
371 Aspect_Default_Value => Name_Default_Value,
372 Aspect_Default_Component_Value => Name_Default_Component_Value,
373 Aspect_Depends => Name_Depends,
374 Aspect_Dimension => Name_Dimension,
375 Aspect_Dimension_System => Name_Dimension_System,
376 Aspect_Discard_Names => Name_Discard_Names,
377 Aspect_Dispatching_Domain => Name_Dispatching_Domain,
378 Aspect_Dynamic_Predicate => Name_Dynamic_Predicate,
379 Aspect_Elaborate_Body => Name_Elaborate_Body,
380 Aspect_External_Name => Name_External_Name,
381 Aspect_External_Tag => Name_External_Tag,
382 Aspect_Export => Name_Export,
383 Aspect_Favor_Top_Level => Name_Favor_Top_Level,
384 Aspect_Global => Name_Global,
385 Aspect_Implicit_Dereference => Name_Implicit_Dereference,
386 Aspect_Import => Name_Import,
387 Aspect_Independent => Name_Independent,
388 Aspect_Independent_Components => Name_Independent_Components,
389 Aspect_Inline => Name_Inline,
390 Aspect_Inline_Always => Name_Inline_Always,
391 Aspect_Input => Name_Input,
392 Aspect_Interrupt_Handler => Name_Interrupt_Handler,
393 Aspect_Interrupt_Priority => Name_Interrupt_Priority,
394 Aspect_Invariant => Name_Invariant,
395 Aspect_Iterator_Element => Name_Iterator_Element,
396 Aspect_Link_Name => Name_Link_Name,
397 Aspect_Lock_Free => Name_Lock_Free,
398 Aspect_Machine_Radix => Name_Machine_Radix,
399 Aspect_No_Return => Name_No_Return,
400 Aspect_Object_Size => Name_Object_Size,
401 Aspect_Output => Name_Output,
402 Aspect_Pack => Name_Pack,
403 Aspect_Persistent_BSS => Name_Persistent_BSS,
404 Aspect_Post => Name_Post,
405 Aspect_Postcondition => Name_Postcondition,
406 Aspect_Pre => Name_Pre,
407 Aspect_Precondition => Name_Precondition,
408 Aspect_Predicate => Name_Predicate,
409 Aspect_Preelaborable_Initialization => Name_Preelaborable_Initialization,
410 Aspect_Preelaborate => Name_Preelaborate,
411 Aspect_Preelaborate_05 => Name_Preelaborate_05,
412 Aspect_Priority => Name_Priority,
413 Aspect_Pure => Name_Pure,
414 Aspect_Pure_05 => Name_Pure_05,
415 Aspect_Pure_12 => Name_Pure_12,
416 Aspect_Pure_Function => Name_Pure_Function,
417 Aspect_Read => Name_Read,
418 Aspect_Relative_Deadline => Name_Relative_Deadline,
419 Aspect_Remote_Access_Type => Name_Remote_Access_Type,
420 Aspect_Remote_Call_Interface => Name_Remote_Call_Interface,
421 Aspect_Remote_Types => Name_Remote_Types,
422 Aspect_Scalar_Storage_Order => Name_Scalar_Storage_Order,
423 Aspect_Shared => Name_Shared,
424 Aspect_Shared_Passive => Name_Shared_Passive,
425 Aspect_Simple_Storage_Pool => Name_Simple_Storage_Pool,
426 Aspect_Simple_Storage_Pool_Type => Name_Simple_Storage_Pool_Type,
427 Aspect_Size => Name_Size,
428 Aspect_Small => Name_Small,
429 Aspect_SPARK_Mode => Name_SPARK_Mode,
430 Aspect_Static_Predicate => Name_Static_Predicate,
431 Aspect_Storage_Pool => Name_Storage_Pool,
432 Aspect_Storage_Size => Name_Storage_Size,
433 Aspect_Stream_Size => Name_Stream_Size,
434 Aspect_Suppress => Name_Suppress,
435 Aspect_Suppress_Debug_Info => Name_Suppress_Debug_Info,
436 Aspect_Synchronization => Name_Synchronization,
437 Aspect_Test_Case => Name_Test_Case,
438 Aspect_Type_Invariant => Name_Type_Invariant,
439 Aspect_Unchecked_Union => Name_Unchecked_Union,
440 Aspect_Universal_Aliasing => Name_Universal_Aliasing,
441 Aspect_Universal_Data => Name_Universal_Data,
442 Aspect_Unmodified => Name_Unmodified,
443 Aspect_Unreferenced => Name_Unreferenced,
444 Aspect_Unreferenced_Objects => Name_Unreferenced_Objects,
445 Aspect_Unsuppress => Name_Unsuppress,
446 Aspect_Value_Size => Name_Value_Size,
447 Aspect_Variable_Indexing => Name_Variable_Indexing,
448 Aspect_Volatile => Name_Volatile,
449 Aspect_Volatile_Components => Name_Volatile_Components,
450 Aspect_Warnings => Name_Warnings,
451 Aspect_Write => Name_Write);
452
453 function Get_Aspect_Id (Name : Name_Id) return Aspect_Id;
454 pragma Inline (Get_Aspect_Id);
455 -- Given a name Nam, returns the corresponding aspect id value. If the name
456 -- does not match any aspect, then No_Aspect is returned as the result.
457
458 function Get_Aspect_Id (Aspect : Node_Id) return Aspect_Id;
459 pragma Inline (Get_Aspect_Id);
460 -- Given an aspect specification, return the corresponding aspect_id value.
461 -- If the name does not match any aspect, return No_Aspect.
462
463 ------------------------------------
464 -- Delaying Evaluation of Aspects --
465 ------------------------------------
466
467 -- The RM requires that all language defined aspects taking an expression
468 -- delay evaluation of the expression till the freeze point of the entity
469 -- to which the aspect applies. This allows forward references, and is of
470 -- use for example in connection with preconditions and postconditions
471 -- where the requirement of making all references in contracts to local
472 -- functions be backwards references would be onerous.
473
474 -- For consistency, even attributes like Size are delayed, so we can do:
475
476 -- type A is range 1 .. 10
477 -- with Size => Not_Defined_Yet;
478 -- ..
479 -- Not_Defined_Yet : constant := 64;
480
481 -- Resulting in A having a size of 64, which gets set when A is frozen.
482 -- Furthermore, we can have a situation like
483
484 -- type A is range 1 .. 10
485 -- with Size => Not_Defined_Yet;
486 -- ..
487 -- type B is new A;
488 -- ..
489 -- Not_Defined_Yet : constant := 64;
490
491 -- where the Size of A is considered to have been previously specified at
492 -- the point of derivation, even though the actual value of the size is
493 -- not known yet, and in this example B inherits the size value of 64.
494
495 -- Our normal implementation model (prior to Ada 2012) was simply to copy
496 -- inheritable attributes at the point of derivation. Then any subsequent
497 -- representation items apply either to the parent type, not affecting the
498 -- derived type, or to the derived type, not affecting the parent type.
499
500 -- To deal with the delayed aspect case, we use two flags. The first is
501 -- set on the parent type if it has delayed representation aspects. This
502 -- flag Has_Delayed_Rep_Aspects indicates that if we derive from this type
503 -- we have to worry about making sure we inherit any delayed aspects. The
504 -- second flag is set on a derived type: May_Have_Inherited_Rep_Aspects
505 -- is set if the parent type has Has_Delayed_Rep_Aspects set.
506
507 -- When we freeze a derived type, if the May_Have_Inherited_Rep_Aspects
508 -- flag is set, then we call Freeze.Inherit_Delayed_Rep_Aspects when
509 -- the derived type is frozen, which deals with the necessary copying of
510 -- information from the parent type, which must be frozen at that point
511 -- (since freezing the derived type first freezes the parent type).
512
513 -- The following shows which aspects are delayed. There are three cases:
514
515 type Delay_Type is
516 (Always_Delay,
517 -- This aspect is not a representation aspect that can be inherited and
518 -- is always delayed, as required by the language definition.
519
520 Never_Delay,
521 -- There are two cases. There are language defined aspects like
522 -- Convention where the "expression" is simply an uninterpreted
523 -- identifier, and there is no issue of evaluating it and thus no
524 -- issue of delaying the evaluation. The second case is implementation
525 -- defined aspects where we have decided that we don't want to allow
526 -- delays (and for our own aspects we can do what we like!).
527
528 Rep_Aspect);
529 -- These are the cases of representation aspects that are in general
530 -- delayed, and where there is a potential issue of derived types that
531 -- inherit delayed representation values.
532
533 -- Note: even if this table indicates that an aspect is delayed, we never
534 -- delay Boolean aspects that have a missing expression (taken as True),
535 -- or expressions for delayed rep items that consist of an integer literal
536 -- (most cases of Size etc. in practice), since in these cases we know we
537 -- can get the value of the expression without delay. Note that we still
538 -- need to delay Boolean aspects that are specifically set to True:
539
540 -- type R is array (0 .. 31) of Boolean
541 -- with Pack => True;
542 -- True : constant Boolean := False;
543
544 -- This is nonsense, but we need to make it work and result in R not
545 -- being packed, and if we have something like:
546
547 -- type R is array (0 .. 31) of Boolean
548 -- with Pack => True;
549 -- RR : R;
550 -- True : constant Boolean := False;
551
552 -- This is illegal because the visibility of True changes after the freeze
553 -- point, which is not allowed, and we need the delay mechanism to properly
554 -- diagnose this error.
555
556 Aspect_Delay : constant array (Aspect_Id) of Delay_Type :=
557 (No_Aspect => Always_Delay,
558 Aspect_Address => Always_Delay,
559 Aspect_All_Calls_Remote => Always_Delay,
560 Aspect_Asynchronous => Always_Delay,
561 Aspect_Attach_Handler => Always_Delay,
562 Aspect_Compiler_Unit => Always_Delay,
563 Aspect_Constant_Indexing => Always_Delay,
564 Aspect_Contract_Cases => Always_Delay,
565 Aspect_CPU => Always_Delay,
566 Aspect_Default_Iterator => Always_Delay,
567 Aspect_Default_Value => Always_Delay,
568 Aspect_Default_Component_Value => Always_Delay,
569 Aspect_Depends => Always_Delay,
570 Aspect_Discard_Names => Always_Delay,
571 Aspect_Dispatching_Domain => Always_Delay,
572 Aspect_Dynamic_Predicate => Always_Delay,
573 Aspect_Elaborate_Body => Always_Delay,
574 Aspect_External_Name => Always_Delay,
575 Aspect_External_Tag => Always_Delay,
576 Aspect_Export => Always_Delay,
577 Aspect_Favor_Top_Level => Always_Delay,
578 Aspect_Global => Always_Delay,
579 Aspect_Implicit_Dereference => Always_Delay,
580 Aspect_Import => Always_Delay,
581 Aspect_Independent => Always_Delay,
582 Aspect_Independent_Components => Always_Delay,
583 Aspect_Inline => Always_Delay,
584 Aspect_Inline_Always => Always_Delay,
585 Aspect_Input => Always_Delay,
586 Aspect_Interrupt_Handler => Always_Delay,
587 Aspect_Interrupt_Priority => Always_Delay,
588 Aspect_Invariant => Always_Delay,
589 Aspect_Iterator_Element => Always_Delay,
590 Aspect_Link_Name => Always_Delay,
591 Aspect_Lock_Free => Always_Delay,
592 Aspect_No_Return => Always_Delay,
593 Aspect_Output => Always_Delay,
594 Aspect_Persistent_BSS => Always_Delay,
595 Aspect_Post => Always_Delay,
596 Aspect_Postcondition => Always_Delay,
597 Aspect_Pre => Always_Delay,
598 Aspect_Precondition => Always_Delay,
599 Aspect_Predicate => Always_Delay,
600 Aspect_Preelaborable_Initialization => Always_Delay,
601 Aspect_Preelaborate => Always_Delay,
602 Aspect_Preelaborate_05 => Always_Delay,
603 Aspect_Priority => Always_Delay,
604 Aspect_Pure => Always_Delay,
605 Aspect_Pure_05 => Always_Delay,
606 Aspect_Pure_12 => Always_Delay,
607 Aspect_Pure_Function => Always_Delay,
608 Aspect_Read => Always_Delay,
609 Aspect_Relative_Deadline => Always_Delay,
610 Aspect_Remote_Access_Type => Always_Delay,
611 Aspect_Remote_Call_Interface => Always_Delay,
612 Aspect_Remote_Types => Always_Delay,
613 Aspect_Shared => Always_Delay,
614 Aspect_Shared_Passive => Always_Delay,
615 Aspect_Simple_Storage_Pool => Always_Delay,
616 Aspect_Simple_Storage_Pool_Type => Always_Delay,
617 Aspect_Static_Predicate => Always_Delay,
618 Aspect_Storage_Pool => Always_Delay,
619 Aspect_Stream_Size => Always_Delay,
620 Aspect_Suppress => Always_Delay,
621 Aspect_Suppress_Debug_Info => Always_Delay,
622 Aspect_Type_Invariant => Always_Delay,
623 Aspect_Unchecked_Union => Always_Delay,
624 Aspect_Universal_Aliasing => Always_Delay,
625 Aspect_Universal_Data => Always_Delay,
626 Aspect_Unmodified => Always_Delay,
627 Aspect_Unreferenced => Always_Delay,
628 Aspect_Unreferenced_Objects => Always_Delay,
629 Aspect_Unsuppress => Always_Delay,
630 Aspect_Variable_Indexing => Always_Delay,
631 Aspect_Write => Always_Delay,
632
633 Aspect_Abstract_State => Never_Delay,
634 Aspect_Ada_2005 => Never_Delay,
635 Aspect_Ada_2012 => Never_Delay,
636 Aspect_Convention => Never_Delay,
637 Aspect_Dimension => Never_Delay,
638 Aspect_Dimension_System => Never_Delay,
639 Aspect_SPARK_Mode => Never_Delay,
640 Aspect_Synchronization => Never_Delay,
641 Aspect_Test_Case => Never_Delay,
642 Aspect_Warnings => Never_Delay,
643
644 Aspect_Alignment => Rep_Aspect,
645 Aspect_Atomic => Rep_Aspect,
646 Aspect_Atomic_Components => Rep_Aspect,
647 Aspect_Bit_Order => Rep_Aspect,
648 Aspect_Component_Size => Rep_Aspect,
649 Aspect_Machine_Radix => Rep_Aspect,
650 Aspect_Object_Size => Rep_Aspect,
651 Aspect_Pack => Rep_Aspect,
652 Aspect_Scalar_Storage_Order => Rep_Aspect,
653 Aspect_Size => Rep_Aspect,
654 Aspect_Small => Rep_Aspect,
655 Aspect_Storage_Size => Rep_Aspect,
656 Aspect_Value_Size => Rep_Aspect,
657 Aspect_Volatile => Rep_Aspect,
658 Aspect_Volatile_Components => Rep_Aspect);
659
660 -- The following table indicates which aspects can apply simultaneously to
661 -- both subprogram/package specs and bodies. For instance, the following is
662 -- legal:
663
664 -- package P with SPARK_Mode ...;
665 -- package body P with SPARK_Mode is ...;
666
667 Aspect_On_Body_OK : constant array (Aspect_Id) of Boolean :=
668 (Aspect_SPARK_Mode => True,
669 others => False);
670
671 ---------------------------------------------------
672 -- Handling of Aspect Specifications in the Tree --
673 ---------------------------------------------------
674
675 -- Several kinds of declaration node permit aspect specifications in Ada
676 -- 2012 mode. If there was room in all the corresponding declaration nodes,
677 -- we could just have a field Aspect_Specifications pointing to a list of
678 -- nodes for the aspects (N_Aspect_Specification nodes). But there isn't
679 -- room, so we adopt a different approach.
680
681 -- The following subprograms provide access to a specialized interface
682 -- implemented internally with a hash table in the body, that provides
683 -- access to aspect specifications.
684
685 function Aspect_Specifications (N : Node_Id) return List_Id;
686 -- Given a node N, returns the list of N_Aspect_Specification nodes that
687 -- are attached to this declaration node. If the node is in the class of
688 -- declaration nodes that permit aspect specifications, as defined by the
689 -- predicate above, and if their Has_Aspects flag is set to True, then this
690 -- will always be a non-empty list. If this flag is set to False, then
691 -- No_List is returned. Normally, the only nodes that have Has_Aspects set
692 -- True are the nodes for which Permits_Aspect_Specifications would return
693 -- True (i.e. the declaration nodes defined in the RM as permitting the
694 -- presence of Aspect_Specifications). However, it is possible for the
695 -- flag Has_Aspects to be set on other nodes as a result of Rewrite and
696 -- Replace calls, and this function may be used to retrieve the aspect
697 -- specifications for the original rewritten node in such cases.
698
699 function Aspects_On_Body_OK (N : Node_Id) return Boolean;
700 -- N denotes a body [stub] with aspects. Determine whether all aspects of N
701 -- can appear simultaneously in bodies and specs.
702
703 function Find_Aspect (Id : Entity_Id; A : Aspect_Id) return Node_Id;
704 -- Find the aspect specification of aspect A associated with entity I.
705 -- Return Empty if Id does not have the requested aspect.
706
707 function Find_Value_Of_Aspect
708 (Id : Entity_Id;
709 A : Aspect_Id) return Node_Id;
710 -- Find the value of aspect A associated with entity Id. Return Empty if
711 -- Id does not have the requested aspect.
712
713 function Has_Aspect (Id : Entity_Id; A : Aspect_Id) return Boolean;
714 -- Determine whether entity Id has aspect A
715
716 procedure Move_Aspects (From : Node_Id; To : Node_Id);
717 -- Relocate the aspect specifications of node From to node To. On entry it
718 -- is assumed that To does not have aspect specifications. If From has no
719 -- aspects, the routine has no effect.
720
721 procedure Move_Or_Merge_Aspects (From : Node_Id; To : Node_Id);
722 -- Relocate the aspect specifications of node From to node To. If To has
723 -- aspects, the aspects of From are added to the aspects of To. If From has
724 -- no aspects, the routine has no effect.
725
726 function Permits_Aspect_Specifications (N : Node_Id) return Boolean;
727 -- Returns True if the node N is a declaration node that permits aspect
728 -- specifications in the grammar. It is possible for other nodes to have
729 -- aspect specifications as a result of Rewrite or Replace calls.
730
731 procedure Remove_Aspects (N : Node_Id);
732 -- Delete the aspect specifications associated with node N. If the node has
733 -- no aspects, the routine has no effect.
734
735 function Same_Aspect (A1 : Aspect_Id; A2 : Aspect_Id) return Boolean;
736 -- Returns True if A1 and A2 are (essentially) the same aspect. This is not
737 -- a simple equality test because e.g. Post and Postcondition are the same.
738 -- This is used for detecting duplicate aspects.
739
740 procedure Set_Aspect_Specifications (N : Node_Id; L : List_Id);
741 -- The node N must be in the class of declaration nodes that permit aspect
742 -- specifications and the Has_Aspects flag must be False on entry. L must
743 -- be a non-empty list of N_Aspect_Specification nodes. This procedure sets
744 -- the Has_Aspects flag to True, and makes an entry that can be retrieved
745 -- by a subsequent Aspect_Specifications call. It is an error to call this
746 -- procedure with a node that does not permit aspect specifications, or a
747 -- node that has its Has_Aspects flag set True on entry, or with L being an
748 -- empty list or No_List.
749
750 procedure Tree_Read;
751 -- Reads contents of Aspect_Specifications hash table from the tree file
752
753 procedure Tree_Write;
754 -- Writes contents of Aspect_Specifications hash table to the tree file
755
756 end Aspects;