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