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