Debian Codegraph @

gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst

raw
1 .. _Standard_and_Implementation_Defined_Restrictions:
2
3 ************************************************
4 Standard and Implementation Defined Restrictions
5 ************************************************
6
7 All Ada Reference Manual-defined Restriction identifiers are implemented:
8
9 * language-defined restrictions (see 13.12.1)
10 * tasking restrictions (see D.7)
11 * high integrity restrictions (see H.4)
12
13 GNAT implements additional restriction identifiers. All restrictions, whether
14 language defined or GNAT-specific, are listed in the following.
15
16 .. _Partition-Wide_Restrictions:
17
18 Partition-Wide Restrictions
19 ===========================
20
21 There are two separate lists of restriction identifiers. The first
22 set requires consistency throughout a partition (in other words, if the
23 restriction identifier is used for any compilation unit in the partition,
24 then all compilation units in the partition must obey the restriction).
25
26 Immediate_Reclamation
27 ---------------------
28 .. index:: Immediate_Reclamation
29
30 [RM H.4] This restriction ensures that, except for storage occupied by
31 objects created by allocators and not deallocated via unchecked
32 deallocation, any storage reserved at run time for an object is
33 immediately reclaimed when the object no longer exists.
34
35 Max_Asynchronous_Select_Nesting
36 -------------------------------
37 .. index:: Max_Asynchronous_Select_Nesting
38
39 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
40 selects. Violations of this restriction with a value of zero are
41 detected at compile time. Violations of this restriction with values
42 other than zero cause Storage_Error to be raised.
43
44 Max_Entry_Queue_Length
45 ----------------------
46 .. index:: Max_Entry_Queue_Length
47
48 [RM D.7] This restriction is a declaration that any protected entry compiled in
49 the scope of the restriction has at most the specified number of
50 tasks waiting on the entry at any one time, and so no queue is required.
51 Note that this restriction is checked at run time. Violation of this
52 restriction results in the raising of Program_Error exception at the point of
53 the call.
54
55 .. index:: Max_Entry_Queue_Depth
56
57 The restriction ``Max_Entry_Queue_Depth`` is recognized as a
58 synonym for ``Max_Entry_Queue_Length``. This is retained for historical
59 compatibility purposes (and a warning will be generated for its use if
60 warnings on obsolescent features are activated).
61
62 Max_Protected_Entries
63 ---------------------
64 .. index:: Max_Protected_Entries
65
66 [RM D.7] Specifies the maximum number of entries per protected type. The
67 bounds of every entry family of a protected unit shall be static, or shall be
68 defined by a discriminant of a subtype whose corresponding bound is static.
69
70 Max_Select_Alternatives
71 -----------------------
72 .. index:: Max_Select_Alternatives
73
74 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
75
76 Max_Storage_At_Blocking
77 -----------------------
78 .. index:: Max_Storage_At_Blocking
79
80 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
81 Storage_Size that can be retained by a blocked task. A violation of this
82 restriction causes Storage_Error to be raised.
83
84 Max_Task_Entries
85 ----------------
86 .. index:: Max_Task_Entries
87
88 [RM D.7] Specifies the maximum number of entries
89 per task. The bounds of every entry family
90 of a task unit shall be static, or shall be
91 defined by a discriminant of a subtype whose
92 corresponding bound is static.
93
94 Max_Tasks
95 ---------
96 .. index:: Max_Tasks
97
98 [RM D.7] Specifies the maximum number of task that may be created, not
99 counting the creation of the environment task. Violations of this
100 restriction with a value of zero are detected at compile
101 time. Violations of this restriction with values other than zero cause
102 Storage_Error to be raised.
103
104 No_Abort_Statements
105 -------------------
106 .. index:: No_Abort_Statements
107
108 [RM D.7] There are no abort_statements, and there are
109 no calls to Task_Identification.Abort_Task.
110
111 No_Access_Parameter_Allocators
112 ------------------------------
113 .. index:: No_Access_Parameter_Allocators
114
115 [RM H.4] This restriction ensures at compile time that there are no
116 occurrences of an allocator as the actual parameter to an access
117 parameter.
118
119 No_Access_Subprograms
120 ---------------------
121 .. index:: No_Access_Subprograms
122
123 [RM H.4] This restriction ensures at compile time that there are no
124 declarations of access-to-subprogram types.
125
126 No_Allocators
127 -------------
128 .. index:: No_Allocators
129
130 [RM H.4] This restriction ensures at compile time that there are no
131 occurrences of an allocator.
132
133 No_Anonymous_Allocators
134 -----------------------
135 .. index:: No_Anonymous_Allocators
136
137 [RM H.4] This restriction ensures at compile time that there are no
138 occurrences of an allocator of anonymous access type.
139
140 No_Asynchronous_Control
141 -----------------------
142 .. index:: No_Asynchronous_Control
143
144 [RM J.13] This restriction ensures at compile time that there are no semantic
145 dependences on the predefined package Asynchronous_Task_Control.
146
147 No_Calendar
148 -----------
149 .. index:: No_Calendar
150
151 [GNAT] This restriction ensures at compile time that there are no semantic
152 dependences on package Calendar.
153
154 No_Coextensions
155 ---------------
156 .. index:: No_Coextensions
157
158 [RM H.4] This restriction ensures at compile time that there are no
159 coextensions. See 3.10.2.
160
161 No_Default_Initialization
162 -------------------------
163 .. index:: No_Default_Initialization
164
165 [GNAT] This restriction prohibits any instance of default initialization
166 of variables. The binder implements a consistency rule which prevents
167 any unit compiled without the restriction from with'ing a unit with the
168 restriction (this allows the generation of initialization procedures to
169 be skipped, since you can be sure that no call is ever generated to an
170 initialization procedure in a unit with the restriction active). If used
171 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
172 is to prohibit all cases of variables declared without a specific
173 initializer (including the case of OUT scalar parameters).
174
175 No_Delay
176 --------
177 .. index:: No_Delay
178
179 [RM H.4] This restriction ensures at compile time that there are no
180 delay statements and no semantic dependences on package Calendar.
181
182 No_Dependence
183 -------------
184 .. index:: No_Dependence
185
186 [RM 13.12.1] This restriction ensures at compile time that there are no
187 dependences on a library unit. For GNAT, this includes implicit implementation
188 dependences on units of the runtime library that are created by the compiler
189 to support specific constructs of the language.
190
191 No_Direct_Boolean_Operators
192 ---------------------------
193 .. index:: No_Direct_Boolean_Operators
194
195 [GNAT] This restriction ensures that no logical operators (and/or/xor)
196 are used on operands of type Boolean (or any type derived from Boolean).
197 This is intended for use in safety critical programs where the certification
198 protocol requires the use of short-circuit (and then, or else) forms for all
199 composite boolean operations.
200
201 No_Dispatch
202 -----------
203 .. index:: No_Dispatch
204
205 [RM H.4] This restriction ensures at compile time that there are no
206 occurrences of ``T'Class``, for any (tagged) subtype ``T``.
207
208 No_Dispatching_Calls
209 --------------------
210 .. index:: No_Dispatching_Calls
211
212 [GNAT] This restriction ensures at compile time that the code generated by the
213 compiler involves no dispatching calls. The use of this restriction allows the
214 safe use of record extensions, classwide membership tests and other classwide
215 features not involving implicit dispatching. This restriction ensures that
216 the code contains no indirect calls through a dispatching mechanism. Note that
217 this includes internally-generated calls created by the compiler, for example
218 in the implementation of class-wide objects assignments. The
219 membership test is allowed in the presence of this restriction, because its
220 implementation requires no dispatching.
221 This restriction is comparable to the official Ada restriction
222 ``No_Dispatch`` except that it is a bit less restrictive in that it allows
223 all classwide constructs that do not imply dispatching.
224 The following example indicates constructs that violate this restriction.
225
226
227 .. code-block:: ada
228
229 package Pkg is
230 type T is tagged record
231 Data : Natural;
232 end record;
233 procedure P (X : T);
234
235 type DT is new T with record
236 More_Data : Natural;
237 end record;
238 procedure Q (X : DT);
239 end Pkg;
240
241 with Pkg; use Pkg;
242 procedure Example is
243 procedure Test (O : T'Class) is
244 N : Natural := O'Size; -- Error: Dispatching call
245 C : T'Class := O; -- Error: implicit Dispatching Call
246 begin
247 if O in DT'Class then -- OK : Membership test
248 Q (DT (O)); -- OK : Type conversion plus direct call
249 else
250 P (O); -- Error: Dispatching call
251 end if;
252 end Test;
253
254 Obj : DT;
255 begin
256 P (Obj); -- OK : Direct call
257 P (T (Obj)); -- OK : Type conversion plus direct call
258 P (T'Class (Obj)); -- Error: Dispatching call
259
260 Test (Obj); -- OK : Type conversion
261
262 if Obj in T'Class then -- OK : Membership test
263 null;
264 end if;
265 end Example;
266
267
268 No_Dynamic_Attachment
269 ---------------------
270 .. index:: No_Dynamic_Attachment
271
272 [RM D.7] This restriction ensures that there is no call to any of the
273 operations defined in package Ada.Interrupts
274 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
275 Detach_Handler, and Reference).
276
277 .. index:: No_Dynamic_Interrupts
278
279 The restriction ``No_Dynamic_Interrupts`` is recognized as a
280 synonym for ``No_Dynamic_Attachment``. This is retained for historical
281 compatibility purposes (and a warning will be generated for its use if
282 warnings on obsolescent features are activated).
283
284 No_Dynamic_Priorities
285 ---------------------
286 .. index:: No_Dynamic_Priorities
287
288 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
289
290 No_Entry_Calls_In_Elaboration_Code
291 ----------------------------------
292 .. index:: No_Entry_Calls_In_Elaboration_Code
293
294 [GNAT] This restriction ensures at compile time that no task or protected entry
295 calls are made during elaboration code. As a result of the use of this
296 restriction, the compiler can assume that no code past an accept statement
297 in a task can be executed at elaboration time.
298
299 No_Enumeration_Maps
300 -------------------
301 .. index:: No_Enumeration_Maps
302
303 [GNAT] This restriction ensures at compile time that no operations requiring
304 enumeration maps are used (that is Image and Value attributes applied
305 to enumeration types).
306
307 No_Exception_Handlers
308 ---------------------
309 .. index:: No_Exception_Handlers
310
311 [GNAT] This restriction ensures at compile time that there are no explicit
312 exception handlers. It also indicates that no exception propagation will
313 be provided. In this mode, exceptions may be raised but will result in
314 an immediate call to the last chance handler, a routine that the user
315 must define with the following profile:
316
317
318 .. code-block:: ada
319
320 procedure Last_Chance_Handler
321 (Source_Location : System.Address; Line : Integer);
322 pragma Export (C, Last_Chance_Handler,
323 "__gnat_last_chance_handler");
324
325
326 The parameter is a C null-terminated string representing a message to be
327 associated with the exception (typically the source location of the raise
328 statement generated by the compiler). The Line parameter when nonzero
329 represents the line number in the source program where the raise occurs.
330
331 No_Exception_Propagation
332 ------------------------
333 .. index:: No_Exception_Propagation
334
335 [GNAT] This restriction guarantees that exceptions are never propagated
336 to an outer subprogram scope. The only case in which an exception may
337 be raised is when the handler is statically in the same subprogram, so
338 that the effect of a raise is essentially like a goto statement. Any
339 other raise statement (implicit or explicit) will be considered
340 unhandled. Exception handlers are allowed, but may not contain an
341 exception occurrence identifier (exception choice). In addition, use of
342 the package GNAT.Current_Exception is not permitted, and reraise
343 statements (raise with no operand) are not permitted.
344
345 No_Exception_Registration
346 -------------------------
347 .. index:: No_Exception_Registration
348
349 [GNAT] This restriction ensures at compile time that no stream operations for
350 types Exception_Id or Exception_Occurrence are used. This also makes it
351 impossible to pass exceptions to or from a partition with this restriction
352 in a distributed environment. If this restriction is active, the generated
353 code is simplified by omitting the otherwise-required global registration
354 of exceptions when they are declared.
355
356 No_Exceptions
357 -------------
358 .. index:: No_Exceptions
359
360 [RM H.4] This restriction ensures at compile time that there are no
361 raise statements and no exception handlers and also suppresses the
362 generation of language-defined run-time checks.
363
364
365 No_Finalization
366 ---------------
367 .. index:: No_Finalization
368
369 [GNAT] This restriction disables the language features described in
370 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
371 performed by the compiler to support these features. The following types
372 are no longer considered controlled when this restriction is in effect:
373
374 *
375 ``Ada.Finalization.Controlled``
376 *
377 ``Ada.Finalization.Limited_Controlled``
378 *
379 Derivations from ``Controlled`` or ``Limited_Controlled``
380 *
381 Class-wide types
382 *
383 Protected types
384 *
385 Task types
386 *
387 Array and record types with controlled components
388
389 The compiler no longer generates code to initialize, finalize or adjust an
390 object or a nested component, either declared on the stack or on the heap. The
391 deallocation of a controlled object no longer finalizes its contents.
392
393 No_Fixed_Point
394 --------------
395 .. index:: No_Fixed_Point
396
397 [RM H.4] This restriction ensures at compile time that there are no
398 occurrences of fixed point types and operations.
399
400 No_Floating_Point
401 -----------------
402 .. index:: No_Floating_Point
403
404 [RM H.4] This restriction ensures at compile time that there are no
405 occurrences of floating point types and operations.
406
407 No_Implicit_Conditionals
408 ------------------------
409 .. index:: No_Implicit_Conditionals
410
411 [GNAT] This restriction ensures that the generated code does not contain any
412 implicit conditionals, either by modifying the generated code where possible,
413 or by rejecting any construct that would otherwise generate an implicit
414 conditional. Note that this check does not include run time constraint
415 checks, which on some targets may generate implicit conditionals as
416 well. To control the latter, constraint checks can be suppressed in the
417 normal manner. Constructs generating implicit conditionals include comparisons
418 of composite objects and the Max/Min attributes.
419
420 No_Implicit_Dynamic_Code
421 ------------------------
422 .. index:: No_Implicit_Dynamic_Code
423 .. index:: trampoline
424
425 [GNAT] This restriction prevents the compiler from building 'trampolines'.
426 This is a structure that is built on the stack and contains dynamic
427 code to be executed at run time. On some targets, a trampoline is
428 built for the following features: ``Access``,
429 ``Unrestricted_Access``, or ``Address`` of a nested subprogram;
430 nested task bodies; primitive operations of nested tagged types.
431 Trampolines do not work on machines that prevent execution of stack
432 data. For example, on windows systems, enabling DEP (data execution
433 protection) will cause trampolines to raise an exception.
434 Trampolines are also quite slow at run time.
435
436 On many targets, trampolines have been largely eliminated. Look at the
437 version of system.ads for your target --- if it has
438 Always_Compatible_Rep equal to False, then trampolines are largely
439 eliminated. In particular, a trampoline is built for the following
440 features: ``Address`` of a nested subprogram;
441 ``Access`` or ``Unrestricted_Access`` of a nested subprogram,
442 but only if pragma Favor_Top_Level applies, or the access type has a
443 foreign-language convention; primitive operations of nested tagged
444 types.
445
446 No_Implicit_Heap_Allocations
447 ----------------------------
448 .. index:: No_Implicit_Heap_Allocations
449
450 [RM D.7] No constructs are allowed to cause implicit heap allocation.
451
452 No_Implicit_Protected_Object_Allocations
453 ----------------------------------------
454 .. index:: No_Implicit_Protected_Object_Allocations
455
456 [GNAT] No constructs are allowed to cause implicit heap allocation of a
457 protected object.
458
459 No_Implicit_Task_Allocations
460 ----------------------------
461 .. index:: No_Implicit_Task_Allocations
462
463 [GNAT] No constructs are allowed to cause implicit heap allocation of a task.
464
465 No_Initialize_Scalars
466 ---------------------
467 .. index:: No_Initialize_Scalars
468
469 [GNAT] This restriction ensures that no unit in the partition is compiled with
470 pragma Initialize_Scalars. This allows the generation of more efficient
471 code, and in particular eliminates dummy null initialization routines that
472 are otherwise generated for some record and array types.
473
474 No_IO
475 -----
476 .. index:: No_IO
477
478 [RM H.4] This restriction ensures at compile time that there are no
479 dependences on any of the library units Sequential_IO, Direct_IO,
480 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
481
482 No_Local_Allocators
483 -------------------
484 .. index:: No_Local_Allocators
485
486 [RM H.4] This restriction ensures at compile time that there are no
487 occurrences of an allocator in subprograms, generic subprograms, tasks,
488 and entry bodies.
489
490 No_Local_Protected_Objects
491 --------------------------
492 .. index:: No_Local_Protected_Objects
493
494 [RM D.7] This restriction ensures at compile time that protected objects are
495 only declared at the library level.
496
497 No_Local_Tagged_Types
498 ---------------------
499 .. index:: No_Local_Tagged_Types
500
501 [GNAT] This restriction ensures at compile time that tagged types are only
502 declared at the library level.
503
504 No_Local_Timing_Events
505 ----------------------
506 .. index:: No_Local_Timing_Events
507
508 [RM D.7] All objects of type Ada.Real_Time.Timing_Events.Timing_Event are
509 declared at the library level.
510
511 No_Long_Long_Integers
512 ---------------------
513 .. index:: No_Long_Long_Integers
514
515 [GNAT] This partition-wide restriction forbids any explicit reference to
516 type Standard.Long_Long_Integer, and also forbids declaring range types whose
517 implicit base type is Long_Long_Integer, and modular types whose size exceeds
518 Long_Integer'Size.
519
520 No_Multiple_Elaboration
521 -----------------------
522 .. index:: No_Multiple_Elaboration
523
524 [GNAT] When this restriction is active and the static elaboration model is
525 used, and -fpreserve-control-flow is not used, the compiler is allowed to
526 suppress the elaboration counter normally associated with the unit, even if
527 the unit has elaboration code. This counter is typically used to check for
528 access before elaboration and to control multiple elaboration attempts. If the
529 restriction is used, then the situations in which multiple elaboration is
530 possible, including non-Ada main programs and Stand Alone libraries, are not
531 permitted and will be diagnosed by the binder.
532
533 No_Nested_Finalization
534 ----------------------
535 .. index:: No_Nested_Finalization
536
537 [RM D.7] All objects requiring finalization are declared at the library level.
538
539 No_Protected_Type_Allocators
540 ----------------------------
541 .. index:: No_Protected_Type_Allocators
542
543 [RM D.7] This restriction ensures at compile time that there are no allocator
544 expressions that attempt to allocate protected objects.
545
546 No_Protected_Types
547 ------------------
548 .. index:: No_Protected_Types
549
550 [RM H.4] This restriction ensures at compile time that there are no
551 declarations of protected types or protected objects.
552
553 No_Recursion
554 ------------
555 .. index:: No_Recursion
556
557 [RM H.4] A program execution is erroneous if a subprogram is invoked as
558 part of its execution.
559
560 No_Reentrancy
561 -------------
562 .. index:: No_Reentrancy
563
564 [RM H.4] A program execution is erroneous if a subprogram is executed by
565 two tasks at the same time.
566
567 No_Relative_Delay
568 -----------------
569 .. index:: No_Relative_Delay
570
571 [RM D.7] This restriction ensures at compile time that there are no delay
572 relative statements and prevents expressions such as ``delay 1.23;`` from
573 appearing in source code.
574
575 No_Requeue_Statements
576 ---------------------
577 .. index:: No_Requeue_Statements
578
579 [RM D.7] This restriction ensures at compile time that no requeue statements
580 are permitted and prevents keyword ``requeue`` from being used in source
581 code.
582
583 .. index:: No_Requeue
584
585 The restriction ``No_Requeue`` is recognized as a
586 synonym for ``No_Requeue_Statements``. This is retained for historical
587 compatibility purposes (and a warning will be generated for its use if
588 warnings on oNobsolescent features are activated).
589
590 No_Secondary_Stack
591 ------------------
592 .. index:: No_Secondary_Stack
593
594 [GNAT] This restriction ensures at compile time that the generated code
595 does not contain any reference to the secondary stack. The secondary
596 stack is used to implement functions returning unconstrained objects
597 (arrays or records) on some targets. Suppresses the allocation of
598 secondary stacks for tasks (excluding the environment task) at run time.
599
600 No_Select_Statements
601 --------------------
602 .. index:: No_Select_Statements
603
604 [RM D.7] This restriction ensures at compile time no select statements of any
605 kind are permitted, that is the keyword ``select`` may not appear.
606
607 No_Specific_Termination_Handlers
608 --------------------------------
609 .. index:: No_Specific_Termination_Handlers
610
611 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
612 or to Ada.Task_Termination.Specific_Handler.
613
614 No_Specification_of_Aspect
615 --------------------------
616 .. index:: No_Specification_of_Aspect
617
618 [RM 13.12.1] This restriction checks at compile time that no aspect
619 specification, attribute definition clause, or pragma is given for a
620 given aspect.
621
622 No_Standard_Allocators_After_Elaboration
623 ----------------------------------------
624 .. index:: No_Standard_Allocators_After_Elaboration
625
626 [RM D.7] Specifies that an allocator using a standard storage pool
627 should never be evaluated at run time after the elaboration of the
628 library items of the partition has completed. Otherwise, Storage_Error
629 is raised.
630
631 No_Standard_Storage_Pools
632 -------------------------
633 .. index:: No_Standard_Storage_Pools
634
635 [GNAT] This restriction ensures at compile time that no access types
636 use the standard default storage pool. Any access type declared must
637 have an explicit Storage_Pool attribute defined specifying a
638 user-defined storage pool.
639
640 No_Stream_Optimizations
641 -----------------------
642 .. index:: No_Stream_Optimizations
643
644 [GNAT] This restriction affects the performance of stream operations on types
645 ``String``, ``Wide_String`` and ``Wide_Wide_String``. By default, the
646 compiler uses block reads and writes when manipulating ``String`` objects
647 due to their superior performance. When this restriction is in effect, the
648 compiler performs all IO operations on a per-character basis.
649
650 No_Streams
651 ----------
652 .. index:: No_Streams
653
654 [GNAT] This restriction ensures at compile/bind time that there are no
655 stream objects created and no use of stream attributes.
656 This restriction does not forbid dependences on the package
657 ``Ada.Streams``. So it is permissible to with
658 ``Ada.Streams`` (or another package that does so itself)
659 as long as no actual stream objects are created and no
660 stream attributes are used.
661
662 Note that the use of restriction allows optimization of tagged types,
663 since they do not need to worry about dispatching stream operations.
664 To take maximum advantage of this space-saving optimization, any
665 unit declaring a tagged type should be compiled with the restriction,
666 though this is not required.
667
668 No_Tagged_Type_Registration
669 ---------------------------
670 .. index:: No_Tagged_Type_Registration
671
672 [GNAT] If this restriction is active, then class-wide streaming
673 attributes are not supported. In addition, the subprograms in
674 Ada.Tags are not supported.
675 If this restriction is active, the generated code is simplified by
676 omitting the otherwise-required global registration of tagged types when they
677 are declared. This restriction may be necessary in order to also apply
678 the No_Elaboration_Code restriction.
679
680 No_Task_Allocators
681 ------------------
682 .. index:: No_Task_Allocators
683
684 [RM D.7] There are no allocators for task types
685 or types containing task subcomponents.
686
687 No_Task_At_Interrupt_Priority
688 -----------------------------
689 .. index:: No_Task_At_Interrupt_Priority
690
691 [GNAT] This restriction ensures at compile time that there is no
692 Interrupt_Priority aspect or pragma for a task or a task type. As
693 a consequence, the tasks are always created with a priority below
694 that an interrupt priority.
695
696 No_Task_Attributes_Package
697 --------------------------
698 .. index:: No_Task_Attributes_Package
699
700 [GNAT] This restriction ensures at compile time that there are no implicit or
701 explicit dependencies on the package ``Ada.Task_Attributes``.
702
703 .. index:: No_Task_Attributes
704
705 The restriction ``No_Task_Attributes`` is recognized as a synonym
706 for ``No_Task_Attributes_Package``. This is retained for historical
707 compatibility purposes (and a warning will be generated for its use if
708 warnings on obsolescent features are activated).
709
710 No_Task_Hierarchy
711 -----------------
712 .. index:: No_Task_Hierarchy
713
714 [RM D.7] All (non-environment) tasks depend
715 directly on the environment task of the partition.
716
717 No_Task_Termination
718 -------------------
719 .. index:: No_Task_Termination
720
721 [RM D.7] Tasks that terminate are erroneous.
722
723 No_Tasking
724 ----------
725 .. index:: No_Tasking
726
727 [GNAT] This restriction prevents the declaration of tasks or task types
728 throughout the partition. It is similar in effect to the use of
729 ``Max_Tasks => 0`` except that violations are caught at compile time
730 and cause an error message to be output either by the compiler or
731 binder.
732
733 No_Terminate_Alternatives
734 -------------------------
735 .. index:: No_Terminate_Alternatives
736
737 [RM D.7] There are no selective accepts with terminate alternatives.
738
739 No_Unchecked_Access
740 -------------------
741 .. index:: No_Unchecked_Access
742
743 [RM H.4] This restriction ensures at compile time that there are no
744 occurrences of the Unchecked_Access attribute.
745
746 No_Unchecked_Conversion
747 -----------------------
748 .. index:: No_Unchecked_Conversion
749
750 [RM J.13] This restriction ensures at compile time that there are no semantic
751 dependences on the predefined generic function Unchecked_Conversion.
752
753 No_Unchecked_Deallocation
754 -------------------------
755 .. index:: No_Unchecked_Deallocation
756
757 [RM J.13] This restriction ensures at compile time that there are no semantic
758 dependences on the predefined generic procedure Unchecked_Deallocation.
759
760 No_Use_Of_Entity
761 ----------------
762 .. index:: No_Use_Of_Entity
763
764 [GNAT] This restriction ensures at compile time that there are no references
765 to the entity given in the form ::
766
767 No_Use_Of_Entity => Name
768
769 where ``Name`` is the fully qualified entity, for example ::
770
771 No_Use_Of_Entity => Ada.Text_IO.Put_Line
772
773 Pure_Barriers
774 -------------
775 .. index:: Pure_Barriers
776
777 [GNAT] This restriction ensures at compile time that protected entry
778 barriers are restricted to:
779
780 * components of the protected object (excluding selection from dereferences),
781 * constant declarations,
782 * named numbers,
783 * enumeration literals,
784 * integer literals,
785 * real literals,
786 * character literals,
787 * implicitly defined comparison operators,
788 * uses of the Standard."not" operator,
789 * short-circuit operator,
790 * the Count attribute
791
792 This restriction is a relaxation of the Simple_Barriers restriction,
793 but still ensures absence of side effects, exceptions, and recursion
794 during the evaluation of the barriers.
795
796 Simple_Barriers
797 ---------------
798 .. index:: Simple_Barriers
799
800 [RM D.7] This restriction ensures at compile time that barriers in entry
801 declarations for protected types are restricted to either static boolean
802 expressions or references to simple boolean variables defined in the private
803 part of the protected type. No other form of entry barriers is permitted.
804
805 .. index:: Boolean_Entry_Barriers
806
807 The restriction ``Boolean_Entry_Barriers`` is recognized as a
808 synonym for ``Simple_Barriers``. This is retained for historical
809 compatibility purposes (and a warning will be generated for its use if
810 warnings on obsolescent features are activated).
811
812 Static_Priorities
813 -----------------
814 .. index:: Static_Priorities
815
816 [GNAT] This restriction ensures at compile time that all priority expressions
817 are static, and that there are no dependences on the package
818 ``Ada.Dynamic_Priorities``.
819
820 Static_Storage_Size
821 -------------------
822 .. index:: Static_Storage_Size
823
824 [GNAT] This restriction ensures at compile time that any expression appearing
825 in a Storage_Size pragma or attribute definition clause is static.
826
827 .. _Program_Unit_Level_Restrictions:
828
829
830 Program Unit Level Restrictions
831 ===============================
832
833 The second set of restriction identifiers
834 does not require partition-wide consistency.
835 The restriction may be enforced for a single
836 compilation unit without any effect on any of the
837 other compilation units in the partition.
838
839 No_Elaboration_Code
840 -------------------
841 .. index:: No_Elaboration_Code
842
843 [GNAT] This restriction ensures at compile time that no elaboration code is
844 generated. Note that this is not the same condition as is enforced
845 by pragma ``Preelaborate``. There are cases in which pragma
846 ``Preelaborate`` still permits code to be generated (e.g., code
847 to initialize a large array to all zeroes), and there are cases of units
848 which do not meet the requirements for pragma ``Preelaborate``,
849 but for which no elaboration code is generated. Generally, it is
850 the case that preelaborable units will meet the restrictions, with
851 the exception of large aggregates initialized with an others_clause,
852 and exception declarations (which generate calls to a run-time
853 registry procedure). This restriction is enforced on
854 a unit by unit basis, it need not be obeyed consistently
855 throughout a partition.
856
857 In the case of aggregates with others, if the aggregate has a dynamic
858 size, there is no way to eliminate the elaboration code (such dynamic
859 bounds would be incompatible with ``Preelaborate`` in any case). If
860 the bounds are static, then use of this restriction actually modifies
861 the code choice of the compiler to avoid generating a loop, and instead
862 generate the aggregate statically if possible, no matter how many times
863 the data for the others clause must be repeatedly generated.
864
865 It is not possible to precisely document
866 the constructs which are compatible with this restriction, since,
867 unlike most other restrictions, this is not a restriction on the
868 source code, but a restriction on the generated object code. For
869 example, if the source contains a declaration:
870
871
872 .. code-block:: ada
873
874 Val : constant Integer := X;
875
876
877 where X is not a static constant, it may be possible, depending
878 on complex optimization circuitry, for the compiler to figure
879 out the value of X at compile time, in which case this initialization
880 can be done by the loader, and requires no initialization code. It
881 is not possible to document the precise conditions under which the
882 optimizer can figure this out.
883
884 Note that this the implementation of this restriction requires full
885 code generation. If it is used in conjunction with "semantics only"
886 checking, then some cases of violations may be missed.
887
888 When this restriction is active, we are not requesting control-flow
889 preservation with -fpreserve-control-flow, and the static elaboration model is
890 used, the compiler is allowed to suppress the elaboration counter normally
891 associated with the unit. This counter is typically used to check for access
892 before elaboration and to control multiple elaboration attempts.
893
894 No_Dynamic_Accessibility_Checks
895 -------------------------------
896 .. index:: No_Dynamic_Accessibility_Checks
897
898 [GNAT] No dynamic accessibility checks are generated when this restriction is
899 in effect. Instead, dangling references are prevented via more conservative
900 compile-time checking. More specifically, existing compile-time checks are
901 enforced but with more conservative assumptions about the accessibility levels
902 of the relevant entities. These conservative assumptions eliminate the need for
903 dynamic accessibility checks.
904
905 These new rules for computing (at compile-time) the accessibility level of an
906 anonymous access type T are as follows:
907
908 *
909 If T is a function result type then, from the caller's perspective, its level
910 is that of the innermost master enclosing the function call. From the callee's
911 perspective, the level of parameters and local variables of the callee is
912 statically deeper than the level of T.
913
914 For any other accessibility level L such that the level of parameters and local
915 variables of the callee is statically deeper than L, the level of T (from the
916 callee's perspective) is also statically deeper than L.
917 *
918 If T is the type of a formal parameter then, from the caller's perspective,
919 its level is at least as deep as that of the type of the corresponding actual
920 parameter (whatever that actual parameter might be). From the callee's
921 perspective, the level of parameters and local variables of the callee is
922 statically deeper than the level of T.
923 *
924 If T is the type of a discriminant then its level is that of the discriminated
925 type.
926 *
927 If T is the type of a stand-alone object then its level is the level of the
928 object.
929 *
930 In all other cases, the level of T is as defined by the existing rules of Ada.
931
932 No_Dynamic_Sized_Objects
933 ------------------------
934 .. index:: No_Dynamic_Sized_Objects
935
936 [GNAT] This restriction disallows certain constructs that might lead to the
937 creation of dynamic-sized composite objects (or array or discriminated type).
938 An array subtype indication is illegal if the bounds are not static
939 or references to discriminants of an enclosing type.
940 A discriminated subtype indication is illegal if the type has
941 discriminant-dependent array components or a variant part, and the
942 discriminants are not static. In addition, array and record aggregates are
943 illegal in corresponding cases. Note that this restriction does not forbid
944 access discriminants. It is often a good idea to combine this restriction
945 with No_Secondary_Stack.
946
947 No_Entry_Queue
948 --------------
949 .. index:: No_Entry_Queue
950
951 [GNAT] This restriction is a declaration that any protected entry compiled in
952 the scope of the restriction has at most one task waiting on the entry
953 at any one time, and so no queue is required. This restriction is not
954 checked at compile time. A program execution is erroneous if an attempt
955 is made to queue a second task on such an entry.
956
957 No_Implementation_Aspect_Specifications
958 ---------------------------------------
959 .. index:: No_Implementation_Aspect_Specifications
960
961 [RM 13.12.1] This restriction checks at compile time that no
962 GNAT-defined aspects are present. With this restriction, the only
963 aspects that can be used are those defined in the Ada Reference Manual.
964
965 No_Implementation_Attributes
966 ----------------------------
967 .. index:: No_Implementation_Attributes
968
969 [RM 13.12.1] This restriction checks at compile time that no
970 GNAT-defined attributes are present. With this restriction, the only
971 attributes that can be used are those defined in the Ada Reference
972 Manual.
973
974 No_Implementation_Identifiers
975 -----------------------------
976 .. index:: No_Implementation_Identifiers
977
978 [RM 13.12.1] This restriction checks at compile time that no
979 implementation-defined identifiers (marked with pragma Implementation_Defined)
980 occur within language-defined packages.
981
982 No_Implementation_Pragmas
983 -------------------------
984 .. index:: No_Implementation_Pragmas
985
986 [RM 13.12.1] This restriction checks at compile time that no
987 GNAT-defined pragmas are present. With this restriction, the only
988 pragmas that can be used are those defined in the Ada Reference Manual.
989
990 No_Implementation_Restrictions
991 ------------------------------
992 .. index:: No_Implementation_Restrictions
993
994 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
995 identifiers (other than ``No_Implementation_Restrictions`` itself)
996 are present. With this restriction, the only other restriction identifiers
997 that can be used are those defined in the Ada Reference Manual.
998
999 No_Implementation_Units
1000 -----------------------
1001 .. index:: No_Implementation_Units
1002
1003 [RM 13.12.1] This restriction checks at compile time that there is no
1004 mention in the context clause of any implementation-defined descendants
1005 of packages Ada, Interfaces, or System.
1006
1007 No_Implicit_Aliasing
1008 --------------------
1009 .. index:: No_Implicit_Aliasing
1010
1011 [GNAT] This restriction, which is not required to be partition-wide consistent,
1012 requires an explicit aliased keyword for an object to which 'Access,
1013 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
1014 the 'Unrestricted_Access attribute for objects. Note: the reason that
1015 Unrestricted_Access is forbidden is that it would require the prefix
1016 to be aliased, and in such cases, it can always be replaced by
1017 the standard attribute Unchecked_Access which is preferable.
1018
1019 No_Implicit_Loops
1020 -----------------
1021 .. index:: No_Implicit_Loops
1022
1023 [GNAT] This restriction ensures that the generated code of the unit marked
1024 with this restriction does not contain any implicit ``for`` loops, either by
1025 modifying the generated code where possible, or by rejecting any construct
1026 that would otherwise generate an implicit ``for`` loop. If this restriction is
1027 active, it is possible to build large array aggregates with all static
1028 components without generating an intermediate temporary, and without generating
1029 a loop to initialize individual components. Otherwise, a loop is created for
1030 arrays larger than about 5000 scalar components. Note that if this restriction
1031 is set in the spec of a package, it will not apply to its body.
1032
1033 No_Obsolescent_Features
1034 -----------------------
1035 .. index:: No_Obsolescent_Features
1036
1037 [RM 13.12.1] This restriction checks at compile time that no obsolescent
1038 features are used, as defined in Annex J of the Ada Reference Manual.
1039
1040 No_Wide_Characters
1041 ------------------
1042 .. index:: No_Wide_Characters
1043
1044 [GNAT] This restriction ensures at compile time that no uses of the types
1045 ``Wide_Character`` or ``Wide_String`` or corresponding wide
1046 wide types
1047 appear, and that no wide or wide wide string or character literals
1048 appear in the program (that is literals representing characters not in
1049 type ``Character``).
1050
1051 Static_Dispatch_Tables
1052 ----------------------
1053 .. index:: Static_Dispatch_Tables
1054
1055 [GNAT] This restriction checks at compile time that all the artifacts
1056 associated with dispatch tables can be placed in read-only memory.
1057
1058 SPARK_05
1059 --------
1060 .. index:: SPARK_05
1061
1062 [GNAT] This restriction no longer has any effect and is superseded by
1063 SPARK 2014, whose restrictions are checked by the tool GNATprove. To check that
1064 a codebase respects SPARK 2014 restrictions, mark the code with pragma or
1065 aspect ``SPARK_Mode``, and run the tool GNATprove at Stone assurance level, as
1066 follows::
1067
1068 gnatprove -P project.gpr --mode=stone
1069
1070 or equivalently::
1071
1072 gnatprove -P project.gpr --mode=check_all