Debian Codegraph @

gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst

raw
1 .. role:: switch(samp)
2
3 .. _Implementation_Defined_Pragmas:
4
5 ******************************
6 Implementation Defined Pragmas
7 ******************************
8
9 Ada defines a set of pragmas that can be used to supply additional
10 information to the compiler. These language defined pragmas are
11 implemented in GNAT and work as described in the Ada Reference Manual.
12
13 In addition, Ada allows implementations to define additional pragmas
14 whose meaning is defined by the implementation. GNAT provides a number
15 of these implementation-defined pragmas, which can be used to extend
16 and enhance the functionality of the compiler. This section of the GNAT
17 Reference Manual describes these additional pragmas.
18
19 Note that any program using these pragmas might not be portable to other
20 compilers (although GNAT implements this set of pragmas on all
21 platforms). Therefore if portability to other compilers is an important
22 consideration, the use of these pragmas should be minimized.
23
24 Pragma Abort_Defer
25 ==================
26
27 .. index:: Deferring aborts
28
29 Syntax:
30
31 .. code-block:: ada
32
33 pragma Abort_Defer;
34
35
36 This pragma must appear at the start of the statement sequence of a
37 handled sequence of statements (right after the ``begin``). It has
38 the effect of deferring aborts for the sequence of statements (but not
39 for the declarations or handlers, if any, associated with this statement
40 sequence). This can also be useful for adding a polling point in Ada code,
41 where asynchronous abort of tasks is checked when leaving the statement
42 sequence, and is lighter than, for example, using ``delay 0.0;``, since with
43 zero-cost exception handling, propagating exceptions (implicitly used to
44 implement task abort) cannot be done reliably in an asynchronous way.
45
46 An example of usage would be:
47
48 .. code-block:: ada
49
50 -- Add a polling point to check for task aborts
51
52 begin
53 pragma Abort_Defer;
54 end;
55
56 .. _Pragma-Abstract_State:
57
58 Pragma Abstract_State
59 =====================
60
61 Syntax:
62
63 .. code-block:: ada
64
65 pragma Abstract_State (ABSTRACT_STATE_LIST);
66
67 ABSTRACT_STATE_LIST ::=
68 null
69 | STATE_NAME_WITH_OPTIONS
70 | (STATE_NAME_WITH_OPTIONS {, STATE_NAME_WITH_OPTIONS} )
71
72 STATE_NAME_WITH_OPTIONS ::=
73 STATE_NAME
74 | (STATE_NAME with OPTION_LIST)
75
76 OPTION_LIST ::= OPTION {, OPTION}
77
78 OPTION ::=
79 SIMPLE_OPTION
80 | NAME_VALUE_OPTION
81
82 SIMPLE_OPTION ::= Ghost | Synchronous
83
84 NAME_VALUE_OPTION ::=
85 Part_Of => ABSTRACT_STATE
86 | External [=> EXTERNAL_PROPERTY_LIST]
87
88 EXTERNAL_PROPERTY_LIST ::=
89 EXTERNAL_PROPERTY
90 | (EXTERNAL_PROPERTY {, EXTERNAL_PROPERTY} )
91
92 EXTERNAL_PROPERTY ::=
93 Async_Readers [=> boolean_EXPRESSION]
94 | Async_Writers [=> boolean_EXPRESSION]
95 | Effective_Reads [=> boolean_EXPRESSION]
96 | Effective_Writes [=> boolean_EXPRESSION]
97 others => boolean_EXPRESSION
98
99 STATE_NAME ::= defining_identifier
100
101 ABSTRACT_STATE ::= name
102
103 For the semantics of this pragma, see the entry for aspect ``Abstract_State`` in
104 the SPARK 2014 Reference Manual, section 7.1.4.
105
106 Pragma Ada_83
107 =============
108
109 Syntax:
110
111 .. code-block:: ada
112
113 pragma Ada_83;
114
115
116 A configuration pragma that establishes Ada 83 mode for the unit to
117 which it applies, regardless of the mode set by the command line
118 switches. In Ada 83 mode, GNAT attempts to be as compatible with
119 the syntax and semantics of Ada 83, as defined in the original Ada
120 83 Reference Manual as possible. In particular, the keywords added by Ada 95
121 and Ada 2005 are not recognized, optional package bodies are allowed,
122 and generics may name types with unknown discriminants without using
123 the ``(<>)`` notation. In addition, some but not all of the additional
124 restrictions of Ada 83 are enforced.
125
126 Ada 83 mode is intended for two purposes. Firstly, it allows existing
127 Ada 83 code to be compiled and adapted to GNAT with less effort.
128 Secondly, it aids in keeping code backwards compatible with Ada 83.
129 However, there is no guarantee that code that is processed correctly
130 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
131 83 compiler, since GNAT does not enforce all the additional checks
132 required by Ada 83.
133
134 Pragma Ada_95
135 =============
136
137 Syntax:
138
139 .. code-block:: ada
140
141 pragma Ada_95;
142
143
144 A configuration pragma that establishes Ada 95 mode for the unit to which
145 it applies, regardless of the mode set by the command line switches.
146 This mode is set automatically for the ``Ada`` and ``System``
147 packages and their children, so you need not specify it in these
148 contexts. This pragma is useful when writing a reusable component that
149 itself uses Ada 95 features, but which is intended to be usable from
150 either Ada 83 or Ada 95 programs.
151
152 Pragma Ada_05
153 =============
154
155 Syntax:
156
157 .. code-block:: ada
158
159 pragma Ada_05;
160 pragma Ada_05 (local_NAME);
161
162
163 A configuration pragma that establishes Ada 2005 mode for the unit to which
164 it applies, regardless of the mode set by the command line switches.
165 This pragma is useful when writing a reusable component that
166 itself uses Ada 2005 features, but which is intended to be usable from
167 either Ada 83 or Ada 95 programs.
168
169 The one argument form (which is not a configuration pragma)
170 is used for managing the transition from
171 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
172 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
173 mode will generate a warning. In addition, in Ada_83 or Ada_95
174 mode, a preference rule is established which does not choose
175 such an entity unless it is unambiguously specified. This avoids
176 extra subprograms marked this way from generating ambiguities in
177 otherwise legal pre-Ada_2005 programs. The one argument form is
178 intended for exclusive use in the GNAT run-time library.
179
180 Pragma Ada_2005
181 ===============
182
183 Syntax:
184
185 .. code-block:: ada
186
187 pragma Ada_2005;
188
189
190 This configuration pragma is a synonym for pragma Ada_05 and has the
191 same syntax and effect.
192
193 Pragma Ada_12
194 =============
195
196 Syntax:
197
198 .. code-block:: ada
199
200 pragma Ada_12;
201 pragma Ada_12 (local_NAME);
202
203
204 A configuration pragma that establishes Ada 2012 mode for the unit to which
205 it applies, regardless of the mode set by the command line switches.
206 This mode is set automatically for the ``Ada`` and ``System``
207 packages and their children, so you need not specify it in these
208 contexts. This pragma is useful when writing a reusable component that
209 itself uses Ada 2012 features, but which is intended to be usable from
210 Ada 83, Ada 95, or Ada 2005 programs.
211
212 The one argument form, which is not a configuration pragma,
213 is used for managing the transition from Ada
214 2005 to Ada 2012 in the run-time library. If an entity is marked
215 as Ada_2012 only, then referencing the entity in any pre-Ada_2012
216 mode will generate a warning. In addition, in any pre-Ada_2012
217 mode, a preference rule is established which does not choose
218 such an entity unless it is unambiguously specified. This avoids
219 extra subprograms marked this way from generating ambiguities in
220 otherwise legal pre-Ada_2012 programs. The one argument form is
221 intended for exclusive use in the GNAT run-time library.
222
223 Pragma Ada_2012
224 ===============
225
226 Syntax:
227
228 .. code-block:: ada
229
230 pragma Ada_2012;
231
232
233 This configuration pragma is a synonym for pragma Ada_12 and has the
234 same syntax and effect.
235
236 Pragma Aggregate_Individually_Assign
237 ====================================
238
239 Syntax:
240
241 .. code-block:: ada
242
243 pragma Aggregate_Individually_Assign;
244
245 Where possible, GNAT will store the binary representation of a record aggregate
246 in memory for space and performance reasons. This configuration pragma changes
247 this behavior so that record aggregates are instead always converted into
248 individual assignment statements.
249
250
251 Pragma Allow_Integer_Address
252 ============================
253
254 Syntax:
255
256 .. code-block:: ada
257
258 pragma Allow_Integer_Address;
259
260
261 In almost all versions of GNAT, ``System.Address`` is a private
262 type in accordance with the implementation advice in the RM. This
263 means that integer values,
264 in particular integer literals, are not allowed as address values.
265 If the configuration pragma
266 ``Allow_Integer_Address`` is given, then integer expressions may
267 be used anywhere a value of type ``System.Address`` is required.
268 The effect is to introduce an implicit unchecked conversion from the
269 integer value to type ``System.Address``. The reverse case of using
270 an address where an integer type is required is handled analogously.
271 The following example compiles without errors:
272
273
274 .. code-block:: ada
275
276 pragma Allow_Integer_Address;
277 with System; use System;
278 package AddrAsInt is
279 X : Integer;
280 Y : Integer;
281 for X'Address use 16#1240#;
282 for Y use at 16#3230#;
283 m : Address := 16#4000#;
284 n : constant Address := 4000;
285 p : constant Address := Address (X + Y);
286 v : Integer := y'Address;
287 w : constant Integer := Integer (Y'Address);
288 type R is new integer;
289 RR : R := 1000;
290 Z : Integer;
291 for Z'Address use RR;
292 end AddrAsInt;
293
294
295 Note that pragma ``Allow_Integer_Address`` is ignored if ``System.Address``
296 is not a private type. In implementations of ``GNAT`` where
297 System.Address is a visible integer type,
298 this pragma serves no purpose but is ignored
299 rather than rejected to allow common sets of sources to be used
300 in the two situations.
301
302 .. _Pragma-Annotate:
303
304 Pragma Annotate
305 ===============
306
307 Syntax::
308
309 pragma Annotate (IDENTIFIER [, IDENTIFIER {, ARG}] [, entity => local_NAME]);
310
311 ARG ::= NAME | EXPRESSION
312
313
314 This pragma is used to annotate programs. IDENTIFIER identifies
315 the type of annotation. GNAT verifies that it is an identifier, but does
316 not otherwise analyze it. The second optional identifier is also left
317 unanalyzed, and by convention is used to control the action of the tool to
318 which the annotation is addressed. The remaining ARG arguments
319 can be either string literals or more generally expressions.
320 String literals (and concatenations of string literals) are assumed to be
321 either of type
322 ``Standard.String`` or else ``Wide_String`` or ``Wide_Wide_String``
323 depending on the character literals they contain.
324 All other kinds of arguments are analyzed as expressions, and must be
325 unambiguous. The last argument if present must have the identifier
326 ``Entity`` and GNAT verifies that a local name is given.
327
328 The analyzed pragma is retained in the tree, but not otherwise processed
329 by any part of the GNAT compiler, except to generate corresponding note
330 lines in the generated ALI file. For the format of these note lines, see
331 the compiler source file lib-writ.ads. This pragma is intended for use by
332 external tools, including ASIS. The use of pragma Annotate does not
333 affect the compilation process in any way. This pragma may be used as
334 a configuration pragma.
335
336 Pragma Assert
337 =============
338
339 Syntax::
340
341 pragma Assert (
342 boolean_EXPRESSION
343 [, string_EXPRESSION]);
344
345
346 The effect of this pragma depends on whether the corresponding command
347 line switch is set to activate assertions. The pragma expands into code
348 equivalent to the following:
349
350 .. code-block:: ada
351
352 if assertions-enabled then
353 if not boolean_EXPRESSION then
354 System.Assertions.Raise_Assert_Failure
355 (string_EXPRESSION);
356 end if;
357 end if;
358
359
360 The string argument, if given, is the message that will be associated
361 with the exception occurrence if the exception is raised. If no second
362 argument is given, the default message is ``file``:``nnn``,
363 where ``file`` is the name of the source file containing the assert,
364 and ``nnn`` is the line number of the assert.
365
366 Note that, as with the ``if`` statement to which it is equivalent, the
367 type of the expression is either ``Standard.Boolean``, or any type derived
368 from this standard type.
369
370 Assert checks can be either checked or ignored. By default they are ignored.
371 They will be checked if either the command line switch *-gnata* is
372 used, or if an ``Assertion_Policy`` or ``Check_Policy`` pragma is used
373 to enable ``Assert_Checks``.
374
375 If assertions are ignored, then there
376 is no run-time effect (and in particular, any side effects from the
377 expression will not occur at run time). (The expression is still
378 analyzed at compile time, and may cause types to be frozen if they are
379 mentioned here for the first time).
380
381 If assertions are checked, then the given expression is tested, and if
382 it is ``False`` then ``System.Assertions.Raise_Assert_Failure`` is called
383 which results in the raising of ``Assert_Failure`` with the given message.
384
385 You should generally avoid side effects in the expression arguments of
386 this pragma, because these side effects will turn on and off with the
387 setting of the assertions mode, resulting in assertions that have an
388 effect on the program. However, the expressions are analyzed for
389 semantic correctness whether or not assertions are enabled, so turning
390 assertions on and off cannot affect the legality of a program.
391
392 Note that the implementation defined policy ``DISABLE``, given in a
393 pragma ``Assertion_Policy``, can be used to suppress this semantic analysis.
394
395 Note: this is a standard language-defined pragma in versions
396 of Ada from 2005 on. In GNAT, it is implemented in all versions
397 of Ada, and the DISABLE policy is an implementation-defined
398 addition.
399
400 Pragma Assert_And_Cut
401 =====================
402
403 Syntax::
404
405 pragma Assert_And_Cut (
406 boolean_EXPRESSION
407 [, string_EXPRESSION]);
408
409
410 The effect of this pragma is identical to that of pragma ``Assert``,
411 except that in an ``Assertion_Policy`` pragma, the identifier
412 ``Assert_And_Cut`` is used to control whether it is ignored or checked
413 (or disabled).
414
415 The intention is that this be used within a subprogram when the
416 given test expresion sums up all the work done so far in the
417 subprogram, so that the rest of the subprogram can be verified
418 (informally or formally) using only the entry preconditions,
419 and the expression in this pragma. This allows dividing up
420 a subprogram into sections for the purposes of testing or
421 formal verification. The pragma also serves as useful
422 documentation.
423
424 Pragma Assertion_Policy
425 =======================
426
427 Syntax::
428
429 pragma Assertion_Policy (CHECK | DISABLE | IGNORE | SUPPRESSIBLE);
430
431 pragma Assertion_Policy (
432 ASSERTION_KIND => POLICY_IDENTIFIER
433 {, ASSERTION_KIND => POLICY_IDENTIFIER});
434
435 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
436
437 RM_ASSERTION_KIND ::= Assert |
438 Static_Predicate |
439 Dynamic_Predicate |
440 Pre |
441 Pre'Class |
442 Post |
443 Post'Class |
444 Type_Invariant |
445 Type_Invariant'Class |
446 Default_Initial_Condition
447
448 ID_ASSERTION_KIND ::= Assertions |
449 Assert_And_Cut |
450 Assume |
451 Contract_Cases |
452 Debug |
453 Ghost |
454 Initial_Condition |
455 Invariant |
456 Invariant'Class |
457 Loop_Invariant |
458 Loop_Variant |
459 Postcondition |
460 Precondition |
461 Predicate |
462 Refined_Post |
463 Statement_Assertions |
464 Subprogram_Variant
465
466 POLICY_IDENTIFIER ::= Check | Disable | Ignore | Suppressible
467
468
469 This is a standard Ada 2012 pragma that is available as an
470 implementation-defined pragma in earlier versions of Ada.
471 The assertion kinds ``RM_ASSERTION_KIND`` are those defined in
472 the Ada standard. The assertion kinds ``ID_ASSERTION_KIND``
473 are implementation defined additions recognized by the GNAT compiler.
474
475 The pragma applies in both cases to pragmas and aspects with matching
476 names, e.g. ``Pre`` applies to the Pre aspect, and ``Precondition``
477 applies to both the ``Precondition`` pragma
478 and the aspect ``Precondition``. Note that the identifiers for
479 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
480 Pre_Class and Post_Class), since these pragmas are intended to be
481 identical to the corresponding aspects).
482
483 If the policy is ``CHECK``, then assertions are enabled, i.e.
484 the corresponding pragma or aspect is activated.
485 If the policy is ``IGNORE``, then assertions are ignored, i.e.
486 the corresponding pragma or aspect is deactivated.
487 This pragma overrides the effect of the *-gnata* switch on the
488 command line.
489 If the policy is ``SUPPRESSIBLE``, then assertions are enabled by default,
490 however, if the *-gnatp* switch is specified all assertions are ignored.
491
492 The implementation defined policy ``DISABLE`` is like
493 ``IGNORE`` except that it completely disables semantic
494 checking of the corresponding pragma or aspect. This is
495 useful when the pragma or aspect argument references subprograms
496 in a with'ed package which is replaced by a dummy package
497 for the final build.
498
499 The implementation defined assertion kind ``Assertions`` applies to all
500 assertion kinds. The form with no assertion kind given implies this
501 choice, so it applies to all assertion kinds (RM defined, and
502 implementation defined).
503
504 The implementation defined assertion kind ``Statement_Assertions``
505 applies to ``Assert``, ``Assert_And_Cut``,
506 ``Assume``, ``Loop_Invariant``, and ``Loop_Variant``.
507
508 Pragma Assume
509 =============
510
511 Syntax:
512
513 ::
514
515 pragma Assume (
516 boolean_EXPRESSION
517 [, string_EXPRESSION]);
518
519
520 The effect of this pragma is identical to that of pragma ``Assert``,
521 except that in an ``Assertion_Policy`` pragma, the identifier
522 ``Assume`` is used to control whether it is ignored or checked
523 (or disabled).
524
525 The intention is that this be used for assumptions about the
526 external environment. So you cannot expect to verify formally
527 or informally that the condition is met, this must be
528 established by examining things outside the program itself.
529 For example, we may have code that depends on the size of
530 ``Long_Long_Integer`` being at least 64. So we could write:
531
532 .. code-block:: ada
533
534 pragma Assume (Long_Long_Integer'Size >= 64);
535
536
537 This assumption cannot be proved from the program itself,
538 but it acts as a useful run-time check that the assumption
539 is met, and documents the need to ensure that it is met by
540 reference to information outside the program.
541
542 Pragma Assume_No_Invalid_Values
543 ===============================
544 .. index:: Invalid representations
545
546 .. index:: Invalid values
547
548 Syntax:
549
550 .. code-block:: ada
551
552 pragma Assume_No_Invalid_Values (On | Off);
553
554
555 This is a configuration pragma that controls the assumptions made by the
556 compiler about the occurrence of invalid representations (invalid values)
557 in the code.
558
559 The default behavior (corresponding to an Off argument for this pragma), is
560 to assume that values may in general be invalid unless the compiler can
561 prove they are valid. Consider the following example:
562
563 .. code-block:: ada
564
565 V1 : Integer range 1 .. 10;
566 V2 : Integer range 11 .. 20;
567 ...
568 for J in V2 .. V1 loop
569 ...
570 end loop;
571
572
573 if V1 and V2 have valid values, then the loop is known at compile
574 time not to execute since the lower bound must be greater than the
575 upper bound. However in default mode, no such assumption is made,
576 and the loop may execute. If ``Assume_No_Invalid_Values (On)``
577 is given, the compiler will assume that any occurrence of a variable
578 other than in an explicit ``'Valid`` test always has a valid
579 value, and the loop above will be optimized away.
580
581 The use of ``Assume_No_Invalid_Values (On)`` is appropriate if
582 you know your code is free of uninitialized variables and other
583 possible sources of invalid representations, and may result in
584 more efficient code. A program that accesses an invalid representation
585 with this pragma in effect is erroneous, so no guarantees can be made
586 about its behavior.
587
588 It is peculiar though permissible to use this pragma in conjunction
589 with validity checking (-gnatVa). In such cases, accessing invalid
590 values will generally give an exception, though formally the program
591 is erroneous so there are no guarantees that this will always be the
592 case, and it is recommended that these two options not be used together.
593
594 .. _Pragma-Async_Readers:
595
596 Pragma Async_Readers
597 ====================
598
599 Syntax:
600
601 .. code-block:: ada
602
603 pragma Async_Readers [ (boolean_EXPRESSION) ];
604
605 For the semantics of this pragma, see the entry for aspect ``Async_Readers`` in
606 the SPARK 2014 Reference Manual, section 7.1.2.
607
608 .. _Pragma-Async_Writers:
609
610 Pragma Async_Writers
611 ====================
612
613 Syntax:
614
615 .. code-block:: ada
616
617 pragma Async_Writers [ (boolean_EXPRESSION) ];
618
619 For the semantics of this pragma, see the entry for aspect ``Async_Writers`` in
620 the SPARK 2014 Reference Manual, section 7.1.2.
621
622 Pragma Attribute_Definition
623 ===========================
624
625 Syntax:
626
627 ::
628
629 pragma Attribute_Definition
630 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
631 [Entity =>] LOCAL_NAME,
632 [Expression =>] EXPRESSION | NAME);
633
634
635 If ``Attribute`` is a known attribute name, this pragma is equivalent to
636 the attribute definition clause:
637
638
639 .. code-block:: ada
640
641 for Entity'Attribute use Expression;
642
643
644 If ``Attribute`` is not a recognized attribute name, the pragma is
645 ignored, and a warning is emitted. This allows source
646 code to be written that takes advantage of some new attribute, while remaining
647 compilable with earlier compilers.
648
649 Pragma C_Pass_By_Copy
650 =====================
651 .. index:: Passing by copy
652
653
654 Syntax:
655
656 ::
657
658 pragma C_Pass_By_Copy
659 ([Max_Size =>] static_integer_EXPRESSION);
660
661
662 Normally the default mechanism for passing C convention records to C
663 convention subprograms is to pass them by reference, as suggested by RM
664 B.3(69). Use the configuration pragma ``C_Pass_By_Copy`` to change
665 this default, by requiring that record formal parameters be passed by
666 copy if all of the following conditions are met:
667
668 *
669 The size of the record type does not exceed the value specified for
670 ``Max_Size``.
671 *
672 The record type has ``Convention C``.
673 *
674 The formal parameter has this record type, and the subprogram has a
675 foreign (non-Ada) convention.
676
677 If these conditions are met the argument is passed by copy; i.e., in a
678 manner consistent with what C expects if the corresponding formal in the
679 C prototype is a struct (rather than a pointer to a struct).
680
681 You can also pass records by copy by specifying the convention
682 ``C_Pass_By_Copy`` for the record type, or by using the extended
683 ``Import`` and ``Export`` pragmas, which allow specification of
684 passing mechanisms on a parameter by parameter basis.
685
686 Pragma Check
687 ============
688 .. index:: Assertions
689
690 .. index:: Named assertions
691
692
693 Syntax:
694
695 ::
696
697 pragma Check (
698 [Name =>] CHECK_KIND,
699 [Check =>] Boolean_EXPRESSION
700 [, [Message =>] string_EXPRESSION] );
701
702 CHECK_KIND ::= IDENTIFIER |
703 Pre'Class |
704 Post'Class |
705 Type_Invariant'Class |
706 Invariant'Class
707
708
709 This pragma is similar to the predefined pragma ``Assert`` except that an
710 extra identifier argument is present. In conjunction with pragma
711 ``Check_Policy``, this can be used to define groups of assertions that can
712 be independently controlled. The identifier ``Assertion`` is special, it
713 refers to the normal set of pragma ``Assert`` statements.
714
715 Checks introduced by this pragma are normally deactivated by default. They can
716 be activated either by the command line option *-gnata*, which turns on
717 all checks, or individually controlled using pragma ``Check_Policy``.
718
719 The identifiers ``Assertions`` and ``Statement_Assertions`` are not
720 permitted as check kinds, since this would cause confusion with the use
721 of these identifiers in ``Assertion_Policy`` and ``Check_Policy``
722 pragmas, where they are used to refer to sets of assertions.
723
724 Pragma Check_Float_Overflow
725 ===========================
726 .. index:: Floating-point overflow
727
728
729 Syntax:
730
731 .. code-block:: ada
732
733 pragma Check_Float_Overflow;
734
735
736 In Ada, the predefined floating-point types (``Short_Float``,
737 ``Float``, ``Long_Float``, ``Long_Long_Float``) are
738 defined to be *unconstrained*. This means that even though each
739 has a well-defined base range, an operation that delivers a result
740 outside this base range is not required to raise an exception.
741 This implementation permission accommodates the notion
742 of infinities in IEEE floating-point, and corresponds to the
743 efficient execution mode on most machines. GNAT will not raise
744 overflow exceptions on these machines; instead it will generate
745 infinities and NaN's as defined in the IEEE standard.
746
747 Generating infinities, although efficient, is not always desirable.
748 Often the preferable approach is to check for overflow, even at the
749 (perhaps considerable) expense of run-time performance.
750 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
751 range constraints -- and indeed such a subtype
752 can have the same base range as its base type. For example:
753
754
755 .. code-block:: ada
756
757 subtype My_Float is Float range Float'Range;
758
759
760 Here ``My_Float`` has the same range as
761 ``Float`` but is constrained, so operations on
762 ``My_Float`` values will be checked for overflow
763 against this range.
764
765 This style will achieve the desired goal, but
766 it is often more convenient to be able to simply use
767 the standard predefined floating-point types as long
768 as overflow checking could be guaranteed.
769 The ``Check_Float_Overflow``
770 configuration pragma achieves this effect. If a unit is compiled
771 subject to this configuration pragma, then all operations
772 on predefined floating-point types including operations on
773 base types of these floating-point types will be treated as
774 though those types were constrained, and overflow checks
775 will be generated. The ``Constraint_Error``
776 exception is raised if the result is out of range.
777
778 This mode can also be set by use of the compiler
779 switch *-gnateF*.
780
781 Pragma Check_Name
782 =================
783 .. index:: Defining check names
784
785 .. index:: Check names, defining
786
787
788 Syntax:
789
790 .. code-block:: ada
791
792 pragma Check_Name (check_name_IDENTIFIER);
793
794
795 This is a configuration pragma that defines a new implementation
796 defined check name (unless IDENTIFIER matches one of the predefined
797 check names, in which case the pragma has no effect). Check names
798 are global to a partition, so if two or more configuration pragmas
799 are present in a partition mentioning the same name, only one new
800 check name is introduced.
801
802 An implementation defined check name introduced with this pragma may
803 be used in only three contexts: ``pragma Suppress``,
804 ``pragma Unsuppress``,
805 and as the prefix of a ``Check_Name'Enabled`` attribute reference. For
806 any of these three cases, the check name must be visible. A check
807 name is visible if it is in the configuration pragmas applying to
808 the current unit, or if it appears at the start of any unit that
809 is part of the dependency set of the current unit (e.g., units that
810 are mentioned in ``with`` clauses).
811
812 Check names introduced by this pragma are subject to control by compiler
813 switches (in particular -gnatp) in the usual manner.
814
815 Pragma Check_Policy
816 ===================
817 .. index:: Controlling assertions
818
819 .. index:: Assertions, control
820
821 .. index:: Check pragma control
822
823 .. index:: Named assertions
824
825
826 Syntax:
827
828 ::
829
830 pragma Check_Policy
831 ([Name =>] CHECK_KIND,
832 [Policy =>] POLICY_IDENTIFIER);
833
834 pragma Check_Policy (
835 CHECK_KIND => POLICY_IDENTIFIER
836 {, CHECK_KIND => POLICY_IDENTIFIER});
837
838 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
839
840 CHECK_KIND ::= IDENTIFIER |
841 Pre'Class |
842 Post'Class |
843 Type_Invariant'Class |
844 Invariant'Class
845
846 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
847 avoids confusion between the two possible syntax forms for this pragma.
848
849 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
850
851
852 This pragma is used to set the checking policy for assertions (specified
853 by aspects or pragmas), the ``Debug`` pragma, or additional checks
854 to be checked using the ``Check`` pragma. It may appear either as
855 a configuration pragma, or within a declarative part of package. In the
856 latter case, it applies from the point where it appears to the end of
857 the declarative region (like pragma ``Suppress``).
858
859 The ``Check_Policy`` pragma is similar to the
860 predefined ``Assertion_Policy`` pragma,
861 and if the check kind corresponds to one of the assertion kinds that
862 are allowed by ``Assertion_Policy``, then the effect is identical.
863
864 If the first argument is Debug, then the policy applies to Debug pragmas,
865 disabling their effect if the policy is ``OFF``, ``DISABLE``, or
866 ``IGNORE``, and allowing them to execute with normal semantics if
867 the policy is ``ON`` or ``CHECK``. In addition if the policy is
868 ``DISABLE``, then the procedure call in ``Debug`` pragmas will
869 be totally ignored and not analyzed semantically.
870
871 Finally the first argument may be some other identifier than the above
872 possibilities, in which case it controls a set of named assertions
873 that can be checked using pragma ``Check``. For example, if the pragma:
874
875
876 .. code-block:: ada
877
878 pragma Check_Policy (Critical_Error, OFF);
879
880
881 is given, then subsequent ``Check`` pragmas whose first argument is also
882 ``Critical_Error`` will be disabled.
883
884 The check policy is ``OFF`` to turn off corresponding checks, and ``ON``
885 to turn on corresponding checks. The default for a set of checks for which no
886 ``Check_Policy`` is given is ``OFF`` unless the compiler switch
887 *-gnata* is given, which turns on all checks by default.
888
889 The check policy settings ``CHECK`` and ``IGNORE`` are recognized
890 as synonyms for ``ON`` and ``OFF``. These synonyms are provided for
891 compatibility with the standard ``Assertion_Policy`` pragma. The check
892 policy setting ``DISABLE`` causes the second argument of a corresponding
893 ``Check`` pragma to be completely ignored and not analyzed.
894
895 Pragma Comment
896 ==============
897
898 Syntax:
899
900
901 .. code-block:: ada
902
903 pragma Comment (static_string_EXPRESSION);
904
905
906 This is almost identical in effect to pragma ``Ident``. It allows the
907 placement of a comment into the object file and hence into the
908 executable file if the operating system permits such usage. The
909 difference is that ``Comment``, unlike ``Ident``, has
910 no limitations on placement of the pragma (it can be placed
911 anywhere in the main source unit), and if more than one pragma
912 is used, all comments are retained.
913
914 Pragma Common_Object
915 ====================
916
917 Syntax:
918
919
920 ::
921
922 pragma Common_Object (
923 [Internal =>] LOCAL_NAME
924 [, [External =>] EXTERNAL_SYMBOL]
925 [, [Size =>] EXTERNAL_SYMBOL] );
926
927 EXTERNAL_SYMBOL ::=
928 IDENTIFIER
929 | static_string_EXPRESSION
930
931
932 This pragma enables the shared use of variables stored in overlaid
933 linker areas corresponding to the use of ``COMMON``
934 in Fortran. The single
935 object ``LOCAL_NAME`` is assigned to the area designated by
936 the ``External`` argument.
937 You may define a record to correspond to a series
938 of fields. The ``Size`` argument
939 is syntax checked in GNAT, but otherwise ignored.
940
941 ``Common_Object`` is not supported on all platforms. If no
942 support is available, then the code generator will issue a message
943 indicating that the necessary attribute for implementation of this
944 pragma is not available.
945
946 .. _Compile_Time_Error:
947
948 Pragma Compile_Time_Error
949 =========================
950
951 Syntax:
952
953
954 .. code-block:: ada
955
956 pragma Compile_Time_Error
957 (boolean_EXPRESSION, static_string_EXPRESSION);
958
959
960 This pragma can be used to generate additional compile time
961 error messages. It
962 is particularly useful in generics, where errors can be issued for
963 specific problematic instantiations. The first parameter is a boolean
964 expression. The pragma ensures that the value of an expression
965 is known at compile time, and has the value False. The set of expressions
966 whose values are known at compile time includes all static boolean
967 expressions, and also other values which the compiler can determine
968 at compile time (e.g., the size of a record type set by an explicit
969 size representation clause, or the value of a variable which was
970 initialized to a constant and is known not to have been modified).
971 If these conditions are not met, an error message is generated using
972 the value given as the second argument. This string value may contain
973 embedded ASCII.LF characters to break the message into multiple lines.
974
975 Pragma Compile_Time_Warning
976 ===========================
977
978 Syntax:
979
980
981 .. code-block:: ada
982
983 pragma Compile_Time_Warning
984 (boolean_EXPRESSION, static_string_EXPRESSION);
985
986
987 Same as pragma Compile_Time_Error, except a warning is issued instead
988 of an error message. If switch *-gnatw_C* is used, a warning is only issued
989 if the value of the expression is known to be True at compile time, not when
990 the value of the expression is not known at compile time.
991 Note that if this pragma is used in a package that
992 is with'ed by a client, the client will get the warning even though it
993 is issued by a with'ed package (normally warnings in with'ed units are
994 suppressed, but this is a special exception to that rule).
995
996 One typical use is within a generic where compile time known characteristics
997 of formal parameters are tested, and warnings given appropriately. Another use
998 with a first parameter of True is to warn a client about use of a package,
999 for example that it is not fully implemented.
1000
1001 In previous versions of the compiler, combining *-gnatwe* with
1002 Compile_Time_Warning resulted in a fatal error. Now the compiler always emits
1003 a warning. You can use :ref:`Compile_Time_Error` to force the generation of
1004 an error.
1005
1006 Pragma Complete_Representation
1007 ==============================
1008
1009 Syntax:
1010
1011
1012 .. code-block:: ada
1013
1014 pragma Complete_Representation;
1015
1016
1017 This pragma must appear immediately within a record representation
1018 clause. Typical placements are before the first component clause
1019 or after the last component clause. The effect is to give an error
1020 message if any component is missing a component clause. This pragma
1021 may be used to ensure that a record representation clause is
1022 complete, and that this invariant is maintained if fields are
1023 added to the record in the future.
1024
1025 Pragma Complex_Representation
1026 =============================
1027
1028 Syntax:
1029
1030
1031 ::
1032
1033 pragma Complex_Representation
1034 ([Entity =>] LOCAL_NAME);
1035
1036
1037 The ``Entity`` argument must be the name of a record type which has
1038 two fields of the same floating-point type. The effect of this pragma is
1039 to force gcc to use the special internal complex representation form for
1040 this record, which may be more efficient. Note that this may result in
1041 the code for this type not conforming to standard ABI (application
1042 binary interface) requirements for the handling of record types. For
1043 example, in some environments, there is a requirement for passing
1044 records by pointer, and the use of this pragma may result in passing
1045 this type in floating-point registers.
1046
1047 Pragma Component_Alignment
1048 ==========================
1049 .. index:: Alignments of components
1050 .. index:: Pragma Component_Alignment
1051
1052
1053 Syntax:
1054
1055 ::
1056
1057 pragma Component_Alignment (
1058 [Form =>] ALIGNMENT_CHOICE
1059 [, [Name =>] type_LOCAL_NAME]);
1060
1061 ALIGNMENT_CHOICE ::=
1062 Component_Size
1063 | Component_Size_4
1064 | Storage_Unit
1065 | Default
1066
1067
1068 Specifies the alignment of components in array or record types.
1069 The meaning of the ``Form`` argument is as follows:
1070
1071
1072 .. index:: Component_Size (in pragma Component_Alignment)
1073
1074 *Component_Size*
1075 Aligns scalar components and subcomponents of the array or record type
1076 on boundaries appropriate to their inherent size (naturally
1077 aligned). For example, 1-byte components are aligned on byte boundaries,
1078 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1079 integer components are aligned on 4-byte boundaries and so on. These
1080 alignment rules correspond to the normal rules for C compilers on all
1081 machines except the VAX.
1082
1083 .. index:: Component_Size_4 (in pragma Component_Alignment)
1084
1085 *Component_Size_4*
1086 Naturally aligns components with a size of four or fewer
1087 bytes. Components that are larger than 4 bytes are placed on the next
1088 4-byte boundary.
1089
1090 .. index:: Storage_Unit (in pragma Component_Alignment)
1091
1092 *Storage_Unit*
1093 Specifies that array or record components are byte aligned, i.e.,
1094 aligned on boundaries determined by the value of the constant
1095 ``System.Storage_Unit``.
1096
1097 .. index:: Default (in pragma Component_Alignment)
1098
1099 *Default*
1100 Specifies that array or record components are aligned on default
1101 boundaries, appropriate to the underlying hardware or operating system or
1102 both. The ``Default`` choice is the same as ``Component_Size`` (natural
1103 alignment).
1104
1105 If the ``Name`` parameter is present, ``type_LOCAL_NAME`` must
1106 refer to a local record or array type, and the specified alignment
1107 choice applies to the specified type. The use of
1108 ``Component_Alignment`` together with a pragma ``Pack`` causes the
1109 ``Component_Alignment`` pragma to be ignored. The use of
1110 ``Component_Alignment`` together with a record representation clause
1111 is only effective for fields not specified by the representation clause.
1112
1113 If the ``Name`` parameter is absent, the pragma can be used as either
1114 a configuration pragma, in which case it applies to one or more units in
1115 accordance with the normal rules for configuration pragmas, or it can be
1116 used within a declarative part, in which case it applies to types that
1117 are declared within this declarative part, or within any nested scope
1118 within this declarative part. In either case it specifies the alignment
1119 to be applied to any record or array type which has otherwise standard
1120 representation.
1121
1122 If the alignment for a record or array type is not specified (using
1123 pragma ``Pack``, pragma ``Component_Alignment``, or a record rep
1124 clause), the GNAT uses the default alignment as described previously.
1125
1126 .. _Pragma-Constant_After_Elaboration:
1127
1128 Pragma Constant_After_Elaboration
1129 =================================
1130
1131 Syntax:
1132
1133 .. code-block:: ada
1134
1135 pragma Constant_After_Elaboration [ (boolean_EXPRESSION) ];
1136
1137 For the semantics of this pragma, see the entry for aspect
1138 ``Constant_After_Elaboration`` in the SPARK 2014 Reference Manual, section 3.3.1.
1139
1140 .. _Pragma-Contract_Cases:
1141
1142 Pragma Contract_Cases
1143 =====================
1144 .. index:: Contract cases
1145
1146 Syntax:
1147
1148 .. code-block:: ada
1149
1150 pragma Contract_Cases ((CONTRACT_CASE {, CONTRACT_CASE));
1151
1152 CONTRACT_CASE ::= CASE_GUARD => CONSEQUENCE
1153
1154 CASE_GUARD ::= boolean_EXPRESSION | others
1155
1156 CONSEQUENCE ::= boolean_EXPRESSION
1157
1158 The ``Contract_Cases`` pragma allows defining fine-grain specifications
1159 that can complement or replace the contract given by a precondition and a
1160 postcondition. Additionally, the ``Contract_Cases`` pragma can be used
1161 by testing and formal verification tools. The compiler checks its validity and,
1162 depending on the assertion policy at the point of declaration of the pragma,
1163 it may insert a check in the executable. For code generation, the contract
1164 cases
1165
1166
1167 .. code-block:: ada
1168
1169 pragma Contract_Cases (
1170 Cond1 => Pred1,
1171 Cond2 => Pred2);
1172
1173
1174 are equivalent to
1175
1176
1177 .. code-block:: ada
1178
1179 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
1180 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
1181 pragma Precondition ((C1 and not C2) or (C2 and not C1));
1182 pragma Postcondition (if C1 then Pred1);
1183 pragma Postcondition (if C2 then Pred2);
1184
1185
1186 The precondition ensures that one and only one of the case guards is
1187 satisfied on entry to the subprogram.
1188 The postcondition ensures that for the case guard that was True on entry,
1189 the corresponding consequence is True on exit. Other consequence expressions
1190 are not evaluated.
1191
1192 A precondition ``P`` and postcondition ``Q`` can also be
1193 expressed as contract cases:
1194
1195 .. code-block:: ada
1196
1197 pragma Contract_Cases (P => Q);
1198
1199
1200 The placement and visibility rules for ``Contract_Cases`` pragmas are
1201 identical to those described for preconditions and postconditions.
1202
1203 The compiler checks that boolean expressions given in case guards and
1204 consequences are valid, where the rules for case guards are the same as
1205 the rule for an expression in ``Precondition`` and the rules for
1206 consequences are the same as the rule for an expression in
1207 ``Postcondition``. In particular, attributes ``'Old`` and
1208 ``'Result`` can only be used within consequence expressions.
1209 The case guard for the last contract case may be ``others``, to denote
1210 any case not captured by the previous cases. The
1211 following is an example of use within a package spec:
1212
1213
1214 .. code-block:: ada
1215
1216 package Math_Functions is
1217 ...
1218 function Sqrt (Arg : Float) return Float;
1219 pragma Contract_Cases (((Arg in 0.0 .. 99.0) => Sqrt'Result < 10.0,
1220 Arg >= 100.0 => Sqrt'Result >= 10.0,
1221 others => Sqrt'Result = 0.0));
1222 ...
1223 end Math_Functions;
1224
1225
1226 The meaning of contract cases is that only one case should apply at each
1227 call, as determined by the corresponding case guard evaluating to True,
1228 and that the consequence for this case should hold when the subprogram
1229 returns.
1230
1231 Pragma Convention_Identifier
1232 ============================
1233 .. index:: Conventions, synonyms
1234
1235 Syntax:
1236
1237
1238 ::
1239
1240 pragma Convention_Identifier (
1241 [Name =>] IDENTIFIER,
1242 [Convention =>] convention_IDENTIFIER);
1243
1244
1245 This pragma provides a mechanism for supplying synonyms for existing
1246 convention identifiers. The ``Name`` identifier can subsequently
1247 be used as a synonym for the given convention in other pragmas (including
1248 for example pragma ``Import`` or another ``Convention_Identifier``
1249 pragma). As an example of the use of this, suppose you had legacy code
1250 which used Fortran77 as the identifier for Fortran. Then the pragma:
1251
1252
1253 .. code-block:: ada
1254
1255 pragma Convention_Identifier (Fortran77, Fortran);
1256
1257
1258 would allow the use of the convention identifier ``Fortran77`` in
1259 subsequent code, avoiding the need to modify the sources. As another
1260 example, you could use this to parameterize convention requirements
1261 according to systems. Suppose you needed to use ``Stdcall`` on
1262 windows systems, and ``C`` on some other system, then you could
1263 define a convention identifier ``Library`` and use a single
1264 ``Convention_Identifier`` pragma to specify which convention
1265 would be used system-wide.
1266
1267 Pragma CPP_Class
1268 ================
1269 .. index:: Interfacing with C++
1270
1271 Syntax:
1272
1273
1274 ::
1275
1276 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1277
1278
1279 The argument denotes an entity in the current declarative region that is
1280 declared as a record type. It indicates that the type corresponds to an
1281 externally declared C++ class type, and is to be laid out the same way
1282 that C++ would lay out the type. If the C++ class has virtual primitives
1283 then the record must be declared as a tagged record type.
1284
1285 Types for which ``CPP_Class`` is specified do not have assignment or
1286 equality operators defined (such operations can be imported or declared
1287 as subprograms as required). Initialization is allowed only by constructor
1288 functions (see pragma ``CPP_Constructor``). Such types are implicitly
1289 limited if not explicitly declared as limited or derived from a limited
1290 type, and an error is issued in that case.
1291
1292 See :ref:`Interfacing_to_C++` for related information.
1293
1294 Note: Pragma ``CPP_Class`` is currently obsolete. It is supported
1295 for backward compatibility but its functionality is available
1296 using pragma ``Import`` with ``Convention`` = ``CPP``.
1297
1298 Pragma CPP_Constructor
1299 ======================
1300 .. index:: Interfacing with C++
1301
1302
1303 Syntax:
1304
1305
1306 ::
1307
1308 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1309 [, [External_Name =>] static_string_EXPRESSION ]
1310 [, [Link_Name =>] static_string_EXPRESSION ]);
1311
1312
1313 This pragma identifies an imported function (imported in the usual way
1314 with pragma ``Import``) as corresponding to a C++ constructor. If
1315 ``External_Name`` and ``Link_Name`` are not specified then the
1316 ``Entity`` argument is a name that must have been previously mentioned
1317 in a pragma ``Import`` with ``Convention`` = ``CPP``. Such name
1318 must be of one of the following forms:
1319
1320 *
1321 **function** ``Fname`` **return** T`
1322
1323 *
1324 **function** ``Fname`` **return** T'Class
1325
1326 *
1327 **function** ``Fname`` (...) **return** T`
1328
1329 *
1330 **function** ``Fname`` (...) **return** T'Class
1331
1332 where ``T`` is a limited record type imported from C++ with pragma
1333 ``Import`` and ``Convention`` = ``CPP``.
1334
1335 The first two forms import the default constructor, used when an object
1336 of type ``T`` is created on the Ada side with no explicit constructor.
1337 The latter two forms cover all the non-default constructors of the type.
1338 See the GNAT User's Guide for details.
1339
1340 If no constructors are imported, it is impossible to create any objects
1341 on the Ada side and the type is implicitly declared abstract.
1342
1343 Pragma ``CPP_Constructor`` is intended primarily for automatic generation
1344 using an automatic binding generator tool (such as the :switch:`-fdump-ada-spec`
1345 GCC switch).
1346 See :ref:`Interfacing_to_C++` for more related information.
1347
1348 Note: The use of functions returning class-wide types for constructors is
1349 currently obsolete. They are supported for backward compatibility. The
1350 use of functions returning the type T leave the Ada sources more clear
1351 because the imported C++ constructors always return an object of type T;
1352 that is, they never return an object whose type is a descendant of type T.
1353
1354 Pragma CPP_Virtual
1355 ==================
1356 .. index:: Interfacing to C++
1357
1358
1359 This pragma is now obsolete and, other than generating a warning if warnings
1360 on obsolescent features are enabled, is completely ignored.
1361 It is retained for compatibility
1362 purposes. It used to be required to ensure compoatibility with C++, but
1363 is no longer required for that purpose because GNAT generates
1364 the same object layout as the G++ compiler by default.
1365
1366 See :ref:`Interfacing_to_C++` for related information.
1367
1368 Pragma CPP_Vtable
1369 =================
1370 .. index:: Interfacing with C++
1371
1372
1373 This pragma is now obsolete and, other than generating a warning if warnings
1374 on obsolescent features are enabled, is completely ignored.
1375 It used to be required to ensure compatibility with C++, but
1376 is no longer required for that purpose because GNAT generates
1377 the same object layout as the G++ compiler by default.
1378
1379 See :ref:`Interfacing_to_C++` for related information.
1380
1381 Pragma CPU
1382 ==========
1383
1384 Syntax:
1385
1386
1387 .. code-block:: ada
1388
1389 pragma CPU (EXPRESSION);
1390
1391
1392 This pragma is standard in Ada 2012, but is available in all earlier
1393 versions of Ada as an implementation-defined pragma.
1394 See Ada 2012 Reference Manual for details.
1395
1396 Pragma Deadline_Floor
1397 =====================
1398
1399 Syntax:
1400
1401
1402 .. code-block:: ada
1403
1404 pragma Deadline_Floor (time_span_EXPRESSION);
1405
1406
1407 This pragma applies only to protected types and specifies the floor
1408 deadline inherited by a task when the task enters a protected object.
1409 It is effective only when the EDF scheduling policy is used.
1410
1411 .. _Pragma-Default_Initial_Condition:
1412
1413 Pragma Default_Initial_Condition
1414 ================================
1415
1416 Syntax:
1417
1418 .. code-block:: ada
1419
1420 pragma Default_Initial_Condition [ (null | boolean_EXPRESSION) ];
1421
1422 For the semantics of this pragma, see the entry for aspect
1423 ``Default_Initial_Condition`` in the SPARK 2014 Reference Manual, section 7.3.3.
1424
1425 Pragma Debug
1426 ============
1427
1428 Syntax:
1429
1430
1431 ::
1432
1433 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1434
1435 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1436 PROCEDURE_NAME
1437 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1438
1439
1440 The procedure call argument has the syntactic form of an expression, meeting
1441 the syntactic requirements for pragmas.
1442
1443 If debug pragmas are not enabled or if the condition is present and evaluates
1444 to False, this pragma has no effect. If debug pragmas are enabled, the
1445 semantics of the pragma is exactly equivalent to the procedure call statement
1446 corresponding to the argument with a terminating semicolon. Pragmas are
1447 permitted in sequences of declarations, so you can use pragma ``Debug`` to
1448 intersperse calls to debug procedures in the middle of declarations. Debug
1449 pragmas can be enabled either by use of the command line switch *-gnata*
1450 or by use of the pragma ``Check_Policy`` with a first argument of
1451 ``Debug``.
1452
1453 Pragma Debug_Policy
1454 ===================
1455
1456 Syntax:
1457
1458
1459 .. code-block:: ada
1460
1461 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
1462
1463
1464 This pragma is equivalent to a corresponding ``Check_Policy`` pragma
1465 with a first argument of ``Debug``. It is retained for historical
1466 compatibility reasons.
1467
1468 Pragma Default_Scalar_Storage_Order
1469 ===================================
1470 .. index:: Default_Scalar_Storage_Order
1471
1472 .. index:: Scalar_Storage_Order
1473
1474
1475 Syntax:
1476
1477
1478 .. code-block:: ada
1479
1480 pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
1481
1482
1483 Normally if no explicit ``Scalar_Storage_Order`` is given for a record
1484 type or array type, then the scalar storage order defaults to the ordinary
1485 default for the target. But this default may be overridden using this pragma.
1486 The pragma may appear as a configuration pragma, or locally within a package
1487 spec or declarative part. In the latter case, it applies to all subsequent
1488 types declared within that package spec or declarative part.
1489
1490 The following example shows the use of this pragma:
1491
1492
1493 .. code-block:: ada
1494
1495 pragma Default_Scalar_Storage_Order (High_Order_First);
1496 with System; use System;
1497 package DSSO1 is
1498 type H1 is record
1499 a : Integer;
1500 end record;
1501
1502 type L2 is record
1503 a : Integer;
1504 end record;
1505 for L2'Scalar_Storage_Order use Low_Order_First;
1506
1507 type L2a is new L2;
1508
1509 package Inner is
1510 type H3 is record
1511 a : Integer;
1512 end record;
1513
1514 pragma Default_Scalar_Storage_Order (Low_Order_First);
1515
1516 type L4 is record
1517 a : Integer;
1518 end record;
1519 end Inner;
1520
1521 type H4a is new Inner.L4;
1522
1523 type H5 is record
1524 a : Integer;
1525 end record;
1526 end DSSO1;
1527
1528
1529 In this example record types with names starting with *L* have `Low_Order_First` scalar
1530 storage order, and record types with names starting with *H* have ``High_Order_First``.
1531 Note that in the case of ``H4a``, the order is not inherited
1532 from the parent type. Only an explicitly set ``Scalar_Storage_Order``
1533 gets inherited on type derivation.
1534
1535 If this pragma is used as a configuration pragma which appears within a
1536 configuration pragma file (as opposed to appearing explicitly at the start
1537 of a single unit), then the binder will require that all units in a partition
1538 be compiled in a similar manner, other than run-time units, which are not
1539 affected by this pragma. Note that the use of this form is discouraged because
1540 it may significantly degrade the run-time performance of the software, instead
1541 the default scalar storage order ought to be changed only on a local basis.
1542
1543 Pragma Default_Storage_Pool
1544 ===========================
1545 .. index:: Default_Storage_Pool
1546
1547
1548 Syntax:
1549
1550
1551 .. code-block:: ada
1552
1553 pragma Default_Storage_Pool (storage_pool_NAME | null);
1554
1555
1556 This pragma is standard in Ada 2012, but is available in all earlier
1557 versions of Ada as an implementation-defined pragma.
1558 See Ada 2012 Reference Manual for details.
1559
1560 .. _Pragma-Depends:
1561
1562 Pragma Depends
1563 ==============
1564
1565 Syntax:
1566
1567 .. code-block:: ada
1568
1569 pragma Depends (DEPENDENCY_RELATION);
1570
1571 DEPENDENCY_RELATION ::=
1572 null
1573 | (DEPENDENCY_CLAUSE {, DEPENDENCY_CLAUSE})
1574
1575 DEPENDENCY_CLAUSE ::=
1576 OUTPUT_LIST =>[+] INPUT_LIST
1577 | NULL_DEPENDENCY_CLAUSE
1578
1579 NULL_DEPENDENCY_CLAUSE ::= null => INPUT_LIST
1580
1581 OUTPUT_LIST ::= OUTPUT | (OUTPUT {, OUTPUT})
1582
1583 INPUT_LIST ::= null | INPUT | (INPUT {, INPUT})
1584
1585 OUTPUT ::= NAME | FUNCTION_RESULT
1586 INPUT ::= NAME
1587
1588 where FUNCTION_RESULT is a function Result attribute_reference
1589
1590 For the semantics of this pragma, see the entry for aspect ``Depends`` in the
1591 SPARK 2014 Reference Manual, section 6.1.5.
1592
1593 Pragma Detect_Blocking
1594 ======================
1595
1596 Syntax:
1597
1598 .. code-block:: ada
1599
1600 pragma Detect_Blocking;
1601
1602
1603 This is a standard pragma in Ada 2005, that is available in all earlier
1604 versions of Ada as an implementation-defined pragma.
1605
1606 This is a configuration pragma that forces the detection of potentially
1607 blocking operations within a protected operation, and to raise Program_Error
1608 if that happens.
1609
1610 Pragma Disable_Atomic_Synchronization
1611 =====================================
1612
1613 .. index:: Atomic Synchronization
1614
1615 Syntax:
1616
1617 ::
1618
1619 pragma Disable_Atomic_Synchronization [(Entity)];
1620
1621
1622 Ada requires that accesses (reads or writes) of an atomic variable be
1623 regarded as synchronization points in the case of multiple tasks.
1624 Particularly in the case of multi-processors this may require special
1625 handling, e.g. the generation of memory barriers. This capability may
1626 be turned off using this pragma in cases where it is known not to be
1627 required.
1628
1629 The placement and scope rules for this pragma are the same as those
1630 for ``pragma Suppress``. In particular it can be used as a
1631 configuration pragma, or in a declaration sequence where it applies
1632 till the end of the scope. If an ``Entity`` argument is present,
1633 the action applies only to that entity.
1634
1635 Pragma Dispatching_Domain
1636 =========================
1637
1638 Syntax:
1639
1640
1641 .. code-block:: ada
1642
1643 pragma Dispatching_Domain (EXPRESSION);
1644
1645
1646 This pragma is standard in Ada 2012, but is available in all earlier
1647 versions of Ada as an implementation-defined pragma.
1648 See Ada 2012 Reference Manual for details.
1649
1650 .. _Pragma-Effective_Reads:
1651
1652 Pragma Effective_Reads
1653 ======================
1654
1655 Syntax:
1656
1657 .. code-block:: ada
1658
1659 pragma Effective_Reads [ (boolean_EXPRESSION) ];
1660
1661 For the semantics of this pragma, see the entry for aspect ``Effective_Reads`` in
1662 the SPARK 2014 Reference Manual, section 7.1.2.
1663
1664 .. _Pragma-Effective_Writes:
1665
1666 Pragma Effective_Writes
1667 =======================
1668
1669 Syntax:
1670
1671 .. code-block:: ada
1672
1673 pragma Effective_Writes [ (boolean_EXPRESSION) ];
1674
1675 For the semantics of this pragma, see the entry for aspect ``Effective_Writes``
1676 in the SPARK 2014 Reference Manual, section 7.1.2.
1677
1678 Pragma Elaboration_Checks
1679 =========================
1680 .. index:: Elaboration control
1681
1682
1683 Syntax:
1684
1685
1686 .. code-block:: ada
1687
1688 pragma Elaboration_Checks (Dynamic | Static);
1689
1690
1691 This is a configuration pragma which specifies the elaboration model to be
1692 used during compilation. For more information on the elaboration models of
1693 GNAT, consult the chapter on elaboration order handling in the *GNAT User's
1694 Guide*.
1695
1696 The pragma may appear in the following contexts:
1697
1698 * Configuration pragmas file
1699
1700 * Prior to the context clauses of a compilation unit's initial declaration
1701
1702 Any other placement of the pragma will result in a warning and the effects of
1703 the offending pragma will be ignored.
1704
1705 If the pragma argument is ``Dynamic``, then the dynamic elaboration model is in
1706 effect. If the pragma argument is ``Static``, then the static elaboration model
1707 is in effect.
1708
1709 Pragma Eliminate
1710 ================
1711 .. index:: Elimination of unused subprograms
1712
1713
1714 Syntax:
1715
1716
1717 ::
1718
1719 pragma Eliminate (
1720 [ Unit_Name => ] IDENTIFIER | SELECTED_COMPONENT ,
1721 [ Entity => ] IDENTIFIER |
1722 SELECTED_COMPONENT |
1723 STRING_LITERAL
1724 [, Source_Location => SOURCE_TRACE ] );
1725
1726 SOURCE_TRACE ::= STRING_LITERAL
1727
1728
1729 This pragma indicates that the given entity is not used in the program to be
1730 compiled and built, thus allowing the compiler to
1731 eliminate the code or data associated with the named entity. Any reference to
1732 an eliminated entity causes a compile-time or link-time error.
1733
1734 The pragma has the following semantics, where ``U`` is the unit specified by
1735 the ``Unit_Name`` argument and ``E`` is the entity specified by the ``Entity``
1736 argument:
1737
1738 * ``E`` must be a subprogram that is explicitly declared either:
1739
1740 o Within ``U``, or
1741
1742 o Within a generic package that is instantiated in ``U``, or
1743
1744 o As an instance of generic subprogram instantiated in ``U``.
1745
1746 Otherwise the pragma is ignored.
1747
1748 * If ``E`` is overloaded within ``U`` then, in the absence of a
1749 ``Source_Location`` argument, all overloadings are eliminated.
1750
1751 * If ``E`` is overloaded within ``U`` and only some overloadings
1752 are to be eliminated, then each overloading to be eliminated
1753 must be specified in a corresponding pragma ``Eliminate``
1754 with a ``Source_Location`` argument identifying the line where the
1755 declaration appears, as described below.
1756
1757 * If ``E`` is declared as the result of a generic instantiation, then
1758 a ``Source_Location`` argument is needed, as described below
1759
1760 Pragma ``Eliminate`` allows a program to be compiled in a system-independent
1761 manner, so that unused entities are eliminated but without
1762 needing to modify the source text. Normally the required set of
1763 ``Eliminate`` pragmas is constructed automatically using the ``gnatelim`` tool.
1764
1765 Any source file change that removes, splits, or
1766 adds lines may make the set of ``Eliminate`` pragmas invalid because their
1767 ``Source_Location`` argument values may get out of date.
1768
1769 Pragma ``Eliminate`` may be used where the referenced entity is a dispatching
1770 operation. In this case all the subprograms to which the given operation can
1771 dispatch are considered to be unused (are never called as a result of a direct
1772 or a dispatching call).
1773
1774 The string literal given for the source location specifies the line number
1775 of the declaration of the entity, using the following syntax for ``SOURCE_TRACE``:
1776
1777 ::
1778
1779 SOURCE_TRACE ::= SOURCE_REFERENCE [ LBRACKET SOURCE_TRACE RBRACKET ]
1780
1781 LBRACKET ::= '['
1782 RBRACKET ::= ']'
1783
1784 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1785
1786 LINE_NUMBER ::= DIGIT {DIGIT}
1787
1788
1789 Spaces around the colon in a ``SOURCE_REFERENCE`` are optional.
1790
1791 The source trace that is given as the ``Source_Location`` must obey the
1792 following rules (or else the pragma is ignored), where ``U`` is
1793 the unit ``U`` specified by the ``Unit_Name`` argument and ``E`` is the
1794 subprogram specified by the ``Entity`` argument:
1795
1796 * ``FILE_NAME`` is the short name (with no directory
1797 information) of the Ada source file for ``U``, using the required syntax
1798 for the underlying file system (e.g. case is significant if the underlying
1799 operating system is case sensitive).
1800 If ``U`` is a package and ``E`` is a subprogram declared in the package
1801 specification and its full declaration appears in the package body,
1802 then the relevant source file is the one for the package specification;
1803 analogously if ``U`` is a generic package.
1804
1805 * If ``E`` is not declared in a generic instantiation (this includes
1806 generic subprogram instances), the source trace includes only one source
1807 line reference. ``LINE_NUMBER`` gives the line number of the occurrence
1808 of the declaration of ``E`` within the source file (as a decimal literal
1809 without an exponent or point).
1810
1811 * If ``E`` is declared by a generic instantiation, its source trace
1812 (from left to right) starts with the source location of the
1813 declaration of ``E`` in the generic unit and ends with the source
1814 location of the instantiation, given in square brackets. This approach is
1815 applied recursively with nested instantiations: the rightmost (nested
1816 most deeply in square brackets) element of the source trace is the location
1817 of the outermost instantiation, and the leftmost element (that is, outside
1818 of any square brackets) is the location of the declaration of ``E`` in
1819 the generic unit.
1820
1821 Examples:
1822
1823 .. code-block:: ada
1824
1825 pragma Eliminate (Pkg0, Proc);
1826 -- Eliminate (all overloadings of) Proc in Pkg0
1827
1828 pragma Eliminate (Pkg1, Proc,
1829 Source_Location => "pkg1.ads:8");
1830 -- Eliminate overloading of Proc at line 8 in pkg1.ads
1831
1832 -- Assume the following file contents:
1833 -- gen_pkg.ads
1834 -- 1: generic
1835 -- 2: type T is private;
1836 -- 3: package Gen_Pkg is
1837 -- 4: procedure Proc(N : T);
1838 -- ... ...
1839 -- ... end Gen_Pkg;
1840 --
1841 -- q.adb
1842 -- 1: with Gen_Pkg;
1843 -- 2: procedure Q is
1844 -- 3: package Inst_Pkg is new Gen_Pkg(Integer);
1845 -- ... -- No calls on Inst_Pkg.Proc
1846 -- ... end Q;
1847
1848 -- The following pragma eliminates Inst_Pkg.Proc from Q
1849 pragma Eliminate (Q, Proc,
1850 Source_Location => "gen_pkg.ads:4[q.adb:3]");
1851
1852
1853
1854 Pragma Enable_Atomic_Synchronization
1855 ====================================
1856 .. index:: Atomic Synchronization
1857
1858
1859 Syntax:
1860
1861
1862 ::
1863
1864 pragma Enable_Atomic_Synchronization [(Entity)];
1865
1866
1867 Ada requires that accesses (reads or writes) of an atomic variable be
1868 regarded as synchronization points in the case of multiple tasks.
1869 Particularly in the case of multi-processors this may require special
1870 handling, e.g. the generation of memory barriers. This synchronization
1871 is performed by default, but can be turned off using
1872 ``pragma Disable_Atomic_Synchronization``. The
1873 ``Enable_Atomic_Synchronization`` pragma can be used to turn
1874 it back on.
1875
1876 The placement and scope rules for this pragma are the same as those
1877 for ``pragma Unsuppress``. In particular it can be used as a
1878 configuration pragma, or in a declaration sequence where it applies
1879 till the end of the scope. If an ``Entity`` argument is present,
1880 the action applies only to that entity.
1881
1882 Pragma Export_Function
1883 ======================
1884 .. index:: Argument passing mechanisms
1885
1886
1887 Syntax:
1888
1889
1890 ::
1891
1892 pragma Export_Function (
1893 [Internal =>] LOCAL_NAME
1894 [, [External =>] EXTERNAL_SYMBOL]
1895 [, [Parameter_Types =>] PARAMETER_TYPES]
1896 [, [Result_Type =>] result_SUBTYPE_MARK]
1897 [, [Mechanism =>] MECHANISM]
1898 [, [Result_Mechanism =>] MECHANISM_NAME]);
1899
1900 EXTERNAL_SYMBOL ::=
1901 IDENTIFIER
1902 | static_string_EXPRESSION
1903 | ""
1904
1905 PARAMETER_TYPES ::=
1906 null
1907 | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
1908
1909 TYPE_DESIGNATOR ::=
1910 subtype_NAME
1911 | subtype_Name ' Access
1912
1913 MECHANISM ::=
1914 MECHANISM_NAME
1915 | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
1916
1917 MECHANISM_ASSOCIATION ::=
1918 [formal_parameter_NAME =>] MECHANISM_NAME
1919
1920 MECHANISM_NAME ::= Value | Reference
1921
1922
1923 Use this pragma to make a function externally callable and optionally
1924 provide information on mechanisms to be used for passing parameter and
1925 result values. We recommend, for the purposes of improving portability,
1926 this pragma always be used in conjunction with a separate pragma
1927 ``Export``, which must precede the pragma ``Export_Function``.
1928 GNAT does not require a separate pragma ``Export``, but if none is
1929 present, ``Convention Ada`` is assumed, which is usually
1930 not what is wanted, so it is usually appropriate to use this
1931 pragma in conjunction with a ``Export`` or ``Convention``
1932 pragma that specifies the desired foreign convention.
1933 Pragma ``Export_Function``
1934 (and ``Export``, if present) must appear in the same declarative
1935 region as the function to which they apply.
1936
1937 The ``internal_name`` must uniquely designate the function to which the
1938 pragma applies. If more than one function name exists of this name in
1939 the declarative part you must use the ``Parameter_Types`` and
1940 ``Result_Type`` parameters to achieve the required
1941 unique designation. The `subtype_mark`\ s in these parameters must
1942 exactly match the subtypes in the corresponding function specification,
1943 using positional notation to match parameters with subtype marks.
1944 The form with an ``'Access`` attribute can be used to match an
1945 anonymous access parameter.
1946
1947 .. index:: Suppressing external name
1948
1949 Special treatment is given if the EXTERNAL is an explicit null
1950 string or a static string expressions that evaluates to the null
1951 string. In this case, no external name is generated. This form
1952 still allows the specification of parameter mechanisms.
1953
1954 Pragma Export_Object
1955 ====================
1956
1957 Syntax:
1958
1959
1960 ::
1961
1962 pragma Export_Object
1963 [Internal =>] LOCAL_NAME
1964 [, [External =>] EXTERNAL_SYMBOL]
1965 [, [Size =>] EXTERNAL_SYMBOL]
1966
1967 EXTERNAL_SYMBOL ::=
1968 IDENTIFIER
1969 | static_string_EXPRESSION
1970
1971
1972 This pragma designates an object as exported, and apart from the
1973 extended rules for external symbols, is identical in effect to the use of
1974 the normal ``Export`` pragma applied to an object. You may use a
1975 separate Export pragma (and you probably should from the point of view
1976 of portability), but it is not required. ``Size`` is syntax checked,
1977 but otherwise ignored by GNAT.
1978
1979 Pragma Export_Procedure
1980 =======================
1981
1982 Syntax:
1983
1984
1985 ::
1986
1987 pragma Export_Procedure (
1988 [Internal =>] LOCAL_NAME
1989 [, [External =>] EXTERNAL_SYMBOL]
1990 [, [Parameter_Types =>] PARAMETER_TYPES]
1991 [, [Mechanism =>] MECHANISM]);
1992
1993 EXTERNAL_SYMBOL ::=
1994 IDENTIFIER
1995 | static_string_EXPRESSION
1996 | ""
1997
1998 PARAMETER_TYPES ::=
1999 null
2000 | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2001
2002 TYPE_DESIGNATOR ::=
2003 subtype_NAME
2004 | subtype_Name ' Access
2005
2006 MECHANISM ::=
2007 MECHANISM_NAME
2008 | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2009
2010 MECHANISM_ASSOCIATION ::=
2011 [formal_parameter_NAME =>] MECHANISM_NAME
2012
2013 MECHANISM_NAME ::= Value | Reference
2014
2015
2016 This pragma is identical to ``Export_Function`` except that it
2017 applies to a procedure rather than a function and the parameters
2018 ``Result_Type`` and ``Result_Mechanism`` are not permitted.
2019 GNAT does not require a separate pragma ``Export``, but if none is
2020 present, ``Convention Ada`` is assumed, which is usually
2021 not what is wanted, so it is usually appropriate to use this
2022 pragma in conjunction with a ``Export`` or ``Convention``
2023 pragma that specifies the desired foreign convention.
2024
2025 .. index:: Suppressing external name
2026
2027 Special treatment is given if the EXTERNAL is an explicit null
2028 string or a static string expressions that evaluates to the null
2029 string. In this case, no external name is generated. This form
2030 still allows the specification of parameter mechanisms.
2031
2032 Pragma Export_Valued_Procedure
2033 ==============================
2034
2035 Syntax:
2036
2037
2038 ::
2039
2040 pragma Export_Valued_Procedure (
2041 [Internal =>] LOCAL_NAME
2042 [, [External =>] EXTERNAL_SYMBOL]
2043 [, [Parameter_Types =>] PARAMETER_TYPES]
2044 [, [Mechanism =>] MECHANISM]);
2045
2046 EXTERNAL_SYMBOL ::=
2047 IDENTIFIER
2048 | static_string_EXPRESSION
2049 | ""
2050
2051 PARAMETER_TYPES ::=
2052 null
2053 | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2054
2055 TYPE_DESIGNATOR ::=
2056 subtype_NAME
2057 | subtype_Name ' Access
2058
2059 MECHANISM ::=
2060 MECHANISM_NAME
2061 | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2062
2063 MECHANISM_ASSOCIATION ::=
2064 [formal_parameter_NAME =>] MECHANISM_NAME
2065
2066 MECHANISM_NAME ::= Value | Reference
2067
2068
2069 This pragma is identical to ``Export_Procedure`` except that the
2070 first parameter of ``LOCAL_NAME``, which must be present, must be of
2071 mode ``out``, and externally the subprogram is treated as a function
2072 with this parameter as the result of the function. GNAT provides for
2073 this capability to allow the use of ``out`` and ``in out``
2074 parameters in interfacing to external functions (which are not permitted
2075 in Ada functions).
2076 GNAT does not require a separate pragma ``Export``, but if none is
2077 present, ``Convention Ada`` is assumed, which is almost certainly
2078 not what is wanted since the whole point of this pragma is to interface
2079 with foreign language functions, so it is usually appropriate to use this
2080 pragma in conjunction with a ``Export`` or ``Convention``
2081 pragma that specifies the desired foreign convention.
2082
2083 .. index:: Suppressing external name
2084
2085 Special treatment is given if the EXTERNAL is an explicit null
2086 string or a static string expressions that evaluates to the null
2087 string. In this case, no external name is generated. This form
2088 still allows the specification of parameter mechanisms.
2089
2090 Pragma Extend_System
2091 ====================
2092 .. index:: System, extending
2093
2094 .. index:: DEC Ada 83
2095
2096
2097 Syntax:
2098
2099
2100 ::
2101
2102 pragma Extend_System ([Name =>] IDENTIFIER);
2103
2104
2105 This pragma is used to provide backwards compatibility with other
2106 implementations that extend the facilities of package ``System``. In
2107 GNAT, ``System`` contains only the definitions that are present in
2108 the Ada RM. However, other implementations, notably the DEC Ada 83
2109 implementation, provide many extensions to package ``System``.
2110
2111 For each such implementation accommodated by this pragma, GNAT provides a
2112 package :samp:`Aux_{xxx}`, e.g., ``Aux_DEC`` for the DEC Ada 83
2113 implementation, which provides the required additional definitions. You
2114 can use this package in two ways. You can ``with`` it in the normal
2115 way and access entities either by selection or using a ``use``
2116 clause. In this case no special processing is required.
2117
2118 However, if existing code contains references such as
2119 :samp:`System.{xxx}` where *xxx* is an entity in the extended
2120 definitions provided in package ``System``, you may use this pragma
2121 to extend visibility in ``System`` in a non-standard way that
2122 provides greater compatibility with the existing code. Pragma
2123 ``Extend_System`` is a configuration pragma whose single argument is
2124 the name of the package containing the extended definition
2125 (e.g., ``Aux_DEC`` for the DEC Ada case). A unit compiled under
2126 control of this pragma will be processed using special visibility
2127 processing that looks in package :samp:`System.Aux_{xxx}` where
2128 :samp:`Aux_{xxx}` is the pragma argument for any entity referenced in
2129 package ``System``, but not found in package ``System``.
2130
2131 You can use this pragma either to access a predefined ``System``
2132 extension supplied with the compiler, for example ``Aux_DEC`` or
2133 you can construct your own extension unit following the above
2134 definition. Note that such a package is a child of ``System``
2135 and thus is considered part of the implementation.
2136 To compile it you will have to use the *-gnatg* switch
2137 for compiling System units, as explained in the
2138 GNAT User's Guide.
2139
2140 Pragma Extensions_Allowed
2141 =========================
2142 .. index:: Ada Extensions
2143
2144 .. index:: GNAT Extensions
2145
2146
2147 Syntax:
2148
2149 .. code-block:: ada
2150
2151 pragma Extensions_Allowed (On | Off);
2152
2153
2154 This configuration pragma enables or disables the implementation
2155 extension mode (the use of Off as a parameter cancels the effect
2156 of the *-gnatX* command switch).
2157
2158 In extension mode, the latest version of the Ada language is
2159 implemented (currently Ada 2022), and in addition a number
2160 of GNAT specific extensions are recognized as follows:
2161
2162 * Constrained attribute for generic objects
2163
2164 The ``Constrained`` attribute is permitted for objects of
2165 generic types. The result indicates if the corresponding actual
2166 is constrained.
2167
2168 * ``Static`` aspect on intrinsic functions
2169
2170 The Ada 202x ``Static`` aspect can be specified on Intrinsic imported
2171 functions and the compiler will evaluate some of these intrinsic statically,
2172 in particular the ``Shift_Left`` and ``Shift_Right`` intrinsics.
2173
2174 * ``'Reduce`` attribute
2175
2176 This attribute part of the Ada 202x language definition is provided for
2177 now under -gnatX to confirm and potentially refine its usage and syntax.
2178
2179 * ``[]`` aggregates
2180
2181 This new aggregate syntax for arrays and containers is provided under -gnatX
2182 to experiment and confirm this new language syntax.
2183
2184 * Additional ``when`` constructs
2185
2186 In addition to the ``exit when CONDITION`` control structure, several
2187 additional constructs are allowed following this format. Including
2188 ``return when CONDITION``, ``goto when CONDITION``, and
2189 ``raise [with EXCEPTION_MESSAGE] when CONDITION.``
2190
2191 Some examples:
2192
2193 .. code-block:: ada
2194
2195 return Result when Variable > 10;
2196
2197 raise Program_Error with "Element is null" when Element = null;
2198
2199 goto End_Of_Subprogram when Variable = -1;
2200
2201 * Casing on composite values (aka pattern matching)
2202
2203 The selector for a case statement may be of a composite type, subject to
2204 some restrictions (described below). Aggregate syntax is used for choices
2205 of such a case statement; however, in cases where a "normal" aggregate would
2206 require a discrete value, a discrete subtype may be used instead; box
2207 notation can also be used to match all values.
2208
2209 Consider this example:
2210
2211 .. code-block:: ada
2212
2213 type Rec is record
2214 F1, F2 : Integer;
2215 end record;
2216
2217 procedure Caser_1 (X : Rec) is
2218 begin
2219 case X is
2220 when (F1 => Positive, F2 => Positive) =>
2221 Do_This;
2222 when (F1 => Natural, F2 => <>) | (F1 => <>, F2 => Natural) =>
2223 Do_That;
2224 when others =>
2225 Do_The_Other_Thing;
2226 end case;
2227 end Caser_1;
2228
2229 If Caser_1 is called and both components of X are positive, then
2230 Do_This will be called; otherwise, if either component is nonnegative
2231 then Do_That will be called; otherwise, Do_The_Other_Thing will be called.
2232
2233 If the set of values that match the choice(s) of an earlier alternative
2234 overlaps the corresponding set of a later alternative, then the first
2235 set shall be a proper subset of the second (and the later alternative
2236 will not be executed if the earlier alternative "matches"). All possible
2237 values of the composite type shall be covered. The composite type of the
2238 selector shall be an array or record type that is neither limited
2239 class-wide.
2240
2241 If a subcomponent's subtype does not meet certain restrictions, then
2242 the only value that can be specified for that subcomponent in a case
2243 choice expression is a "box" component association (which matches all
2244 possible values for the subcomponent). This restriction applies if
2245
2246 - the component subtype is not a record, array, or discrete type; or
2247
2248 - the component subtype is subject to a non-static constraint or
2249 has a predicate; or
2250
2251 - the component type is an enumeration type that is subject to an
2252 enumeration representation clause; or
2253
2254 - the component type is a multidimensional array type or an
2255 array type with a nonstatic index subtype.
2256
2257 Support for casing on arrays (and on records that contain arrays) is
2258 currently subject to some restrictions. Non-positional
2259 array aggregates are not supported as (or within) case choices. Likewise
2260 for array type and subtype names. The current implementation exceeds
2261 compile-time capacity limits in some annoyingly common scenarios; the
2262 message generated in such cases is usually "Capacity exceeded in compiling
2263 case statement with composite selector type".
2264
2265 In addition, pattern bindings are supported. This is a mechanism
2266 for binding a name to a component of a matching value for use within
2267 an alternative of a case statement. For a component association
2268 that occurs within a case choice, the expression may be followed by
2269 "is <identifier>". In the special case of a "box" component association,
2270 the identifier may instead be provided within the box. Either of these
2271 indicates that the given identifer denotes (a constant view of) the matching
2272 subcomponent of the case selector. Binding is not yet supported for arrays
2273 or subcomponents thereof.
2274
2275 Consider this example (which uses type Rec from the previous example):
2276
2277 .. code-block:: ada
2278
2279 procedure Caser_2 (X : Rec) is
2280 begin
2281 case X is
2282 when (F1 => Positive is Abc, F2 => Positive) =>
2283 Do_This (Abc)
2284 when (F1 => Natural is N1, F2 => <N2>) |
2285 (F1 => <N2>, F2 => Natural is N1) =>
2286 Do_That (Param_1 => N1, Param_2 => N2);
2287 when others =>
2288 Do_The_Other_Thing;
2289 end case;
2290 end Caser_2;
2291
2292 This example is the same as the previous one with respect to
2293 determining whether Do_This, Do_That, or Do_The_Other_Thing will
2294 be called. But for this version, Do_This takes a parameter and Do_That
2295 takes two parameters. If Do_This is called, the actual parameter in the
2296 call will be X.F1.
2297
2298 If Do_That is called, the situation is more complex because there are two
2299 choices for that alternative. If Do_That is called because the first choice
2300 matched (i.e., because X.F1 is nonnegative and either X.F1 or X.F2 is zero
2301 or negative), then the actual parameters of the call will be (in order)
2302 X.F1 and X.F2. If Do_That is called because the second choice matched (and
2303 the first one did not), then the actual parameters will be reversed.
2304
2305 Within the choice list for single alternative, each choice must
2306 define the same set of bindings and the component subtypes for
2307 for a given identifer must all statically match. Currently, the case
2308 of a binding for a nondiscrete component is not implemented.
2309
2310 * Fixed lower bounds for array types and subtypes
2311
2312 Unconstrained array types and subtypes can be specified with a lower bound
2313 that is fixed to a certain value, by writing an index range that uses the
2314 syntax "<lower-bound-expression> .. <>". This guarantees that all objects
2315 of the type or subtype will have the specified lower bound.
2316
2317 For example, a matrix type with fixed lower bounds of zero for each
2318 dimension can be declared by the following:
2319
2320 .. code-block:: ada
2321
2322 type Matrix is
2323 array (Natural range 0 .. <>, Natural range 0 .. <>) of Integer;
2324
2325 Objects of type Matrix declared with an index constraint must have index
2326 ranges starting at zero:
2327
2328 .. code-block:: ada
2329
2330 M1 : Matrix (0 .. 9, 0 .. 19);
2331 M2 : Matrix (2 .. 11, 3 .. 22); -- Warning about bounds; will raise CE
2332
2333 Similarly, a subtype of String can be declared that specifies the lower
2334 bound of objects of that subtype to be 1:
2335
2336 .. code-block:: ada
2337
2338 subtype String_1 is String (1 .. <>);
2339
2340 If a string slice is passed to a formal of subtype String_1 in a call to
2341 a subprogram S, the slice's bounds will "slide" so that the lower bound
2342 is 1. Within S, the lower bound of the formal is known to be 1, so, unlike
2343 a normal unconstrained String formal, there is no need to worry about
2344 accounting for other possible lower-bound values. Sliding of bounds also
2345 occurs in other contexts, such as for object declarations with an
2346 unconstrained subtype with fixed lower bound, as well as in subtype
2347 conversions.
2348
2349 Use of this feature increases safety by simplifying code, and can also
2350 improve the efficiency of indexing operations, since the compiler statically
2351 knows the lower bound of unconstrained array formals when the formal's
2352 subtype has index ranges with static fixed lower bounds.
2353
2354 * Prefixed-view notation for calls to primitive subprograms of untagged types
2355
2356 Since Ada 2005, calls to primitive subprograms of a tagged type that
2357 have a "prefixed view" (see RM 4.1.3(9.2)) have been allowed to be
2358 written using the form of a selected_component, with the first actual
2359 parameter given as the prefix and the name of the subprogram as a
2360 selector. This prefixed-view notation for calls is extended so as to
2361 also allow such syntax for calls to primitive subprograms of untagged
2362 types. The primitives of an untagged type T that have a prefixed view
2363 are those where the first formal parameter of the subprogram either
2364 is of type T or is an anonymous access parameter whose designated type
2365 is T. For a type that has a component that happens to have the same
2366 simple name as one of the type's primitive subprograms, where the
2367 component is visible at the point of a selected_component using that
2368 name, preference is given to the component in a selected_component
2369 (as is currently the case for tagged types with such component names).
2370
2371 * Expression defaults for generic formal functions
2372
2373 The declaration of a generic formal function is allowed to specify
2374 an expression as a default, using the syntax of an expression function.
2375
2376 Here is an example of this feature:
2377
2378 .. code-block:: ada
2379
2380 generic
2381 type T is private;
2382 with function Copy (Item : T) return T is (Item); -- Defaults to Item
2383 package Stacks is
2384
2385 type Stack is limited private;
2386
2387 procedure Push (S : in out Stack; X : T); -- Calls Copy on X
2388
2389 function Pop (S : in out Stack) return T; -- Calls Copy to return item
2390
2391 private
2392 -- ...
2393 end Stacks;
2394
2395 .. _Pragma-Extensions_Visible:
2396
2397 Pragma Extensions_Visible
2398 =========================
2399
2400 Syntax:
2401
2402 .. code-block:: ada
2403
2404 pragma Extensions_Visible [ (boolean_EXPRESSION) ];
2405
2406 For the semantics of this pragma, see the entry for aspect ``Extensions_Visible``
2407 in the SPARK 2014 Reference Manual, section 6.1.7.
2408
2409 Pragma External
2410 ===============
2411
2412 Syntax:
2413
2414
2415 ::
2416
2417 pragma External (
2418 [ Convention =>] convention_IDENTIFIER,
2419 [ Entity =>] LOCAL_NAME
2420 [, [External_Name =>] static_string_EXPRESSION ]
2421 [, [Link_Name =>] static_string_EXPRESSION ]);
2422
2423
2424 This pragma is identical in syntax and semantics to pragma
2425 ``Export`` as defined in the Ada Reference Manual. It is
2426 provided for compatibility with some Ada 83 compilers that
2427 used this pragma for exactly the same purposes as pragma
2428 ``Export`` before the latter was standardized.
2429
2430 Pragma External_Name_Casing
2431 ===========================
2432 .. index:: Dec Ada 83 casing compatibility
2433
2434 .. index:: External Names, casing
2435
2436 .. index:: Casing of External names
2437
2438
2439 Syntax:
2440
2441
2442 ::
2443
2444 pragma External_Name_Casing (
2445 Uppercase | Lowercase
2446 [, Uppercase | Lowercase | As_Is]);
2447
2448
2449 This pragma provides control over the casing of external names associated
2450 with Import and Export pragmas. There are two cases to consider:
2451
2452
2453
2454 * Implicit external names
2455
2456 Implicit external names are derived from identifiers. The most common case
2457 arises when a standard Ada Import or Export pragma is used with only two
2458 arguments, as in:
2459
2460 .. code-block:: ada
2461
2462 pragma Import (C, C_Routine);
2463
2464 Since Ada is a case-insensitive language, the spelling of the identifier in
2465 the Ada source program does not provide any information on the desired
2466 casing of the external name, and so a convention is needed. In GNAT the
2467 default treatment is that such names are converted to all lower case
2468 letters. This corresponds to the normal C style in many environments.
2469 The first argument of pragma ``External_Name_Casing`` can be used to
2470 control this treatment. If ``Uppercase`` is specified, then the name
2471 will be forced to all uppercase letters. If ``Lowercase`` is specified,
2472 then the normal default of all lower case letters will be used.
2473
2474 This same implicit treatment is also used in the case of extended DEC Ada 83
2475 compatible Import and Export pragmas where an external name is explicitly
2476 specified using an identifier rather than a string.
2477
2478
2479 * Explicit external names
2480
2481 Explicit external names are given as string literals. The most common case
2482 arises when a standard Ada Import or Export pragma is used with three
2483 arguments, as in:
2484
2485 .. code-block:: ada
2486
2487 pragma Import (C, C_Routine, "C_routine");
2488
2489 In this case, the string literal normally provides the exact casing required
2490 for the external name. The second argument of pragma
2491 ``External_Name_Casing`` may be used to modify this behavior.
2492 If ``Uppercase`` is specified, then the name
2493 will be forced to all uppercase letters. If ``Lowercase`` is specified,
2494 then the name will be forced to all lowercase letters. A specification of
2495 ``As_Is`` provides the normal default behavior in which the casing is
2496 taken from the string provided.
2497
2498 This pragma may appear anywhere that a pragma is valid. In particular, it
2499 can be used as a configuration pragma in the :file:`gnat.adc` file, in which
2500 case it applies to all subsequent compilations, or it can be used as a program
2501 unit pragma, in which case it only applies to the current unit, or it can
2502 be used more locally to control individual Import/Export pragmas.
2503
2504 It was primarily intended for use with OpenVMS systems, where many
2505 compilers convert all symbols to upper case by default. For interfacing to
2506 such compilers (e.g., the DEC C compiler), it may be convenient to use
2507 the pragma:
2508
2509 .. code-block:: ada
2510
2511 pragma External_Name_Casing (Uppercase, Uppercase);
2512
2513
2514 to enforce the upper casing of all external symbols.
2515
2516 Pragma Fast_Math
2517 ================
2518
2519 Syntax:
2520
2521
2522 .. code-block:: ada
2523
2524 pragma Fast_Math;
2525
2526
2527 This is a configuration pragma which activates a mode in which speed is
2528 considered more important for floating-point operations than absolutely
2529 accurate adherence to the requirements of the standard. Currently the
2530 following operations are affected:
2531
2532
2533
2534 *Complex Multiplication*
2535 The normal simple formula for complex multiplication can result in intermediate
2536 overflows for numbers near the end of the range. The Ada standard requires that
2537 this situation be detected and corrected by scaling, but in Fast_Math mode such
2538 cases will simply result in overflow. Note that to take advantage of this you
2539 must instantiate your own version of ``Ada.Numerics.Generic_Complex_Types``
2540 under control of the pragma, rather than use the preinstantiated versions.
2541
2542 .. _Pragma-Favor_Top_Level:
2543
2544 Pragma Favor_Top_Level
2545 ======================
2546
2547 Syntax:
2548
2549
2550 .. code-block:: ada
2551
2552 pragma Favor_Top_Level (type_NAME);
2553
2554
2555 The argument of pragma ``Favor_Top_Level`` must be a named access-to-subprogram
2556 type. This pragma is an efficiency hint to the compiler, regarding the use of
2557 ``'Access`` or ``'Unrestricted_Access`` on nested (non-library-level) subprograms.
2558 The pragma means that nested subprograms are not used with this type, or are
2559 rare, so that the generated code should be efficient in the top-level case.
2560 When this pragma is used, dynamically generated trampolines may be used on some
2561 targets for nested subprograms. See restriction ``No_Implicit_Dynamic_Code``.
2562
2563 Pragma Finalize_Storage_Only
2564 ============================
2565
2566 Syntax:
2567
2568
2569 .. code-block:: ada
2570
2571 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2572
2573
2574 The argument of pragma ``Finalize_Storage_Only`` must denote a local type which
2575 is derived from ``Ada.Finalization.Controlled`` or ``Limited_Controlled``. The
2576 pragma suppresses the call to ``Finalize`` for declared library-level objects
2577 of the argument type. This is mostly useful for types where finalization is
2578 only used to deal with storage reclamation since in most environments it is
2579 not necessary to reclaim memory just before terminating execution, hence the
2580 name. Note that this pragma does not suppress Finalize calls for library-level
2581 heap-allocated objects (see pragma ``No_Heap_Finalization``).
2582
2583 Pragma Float_Representation
2584 ===========================
2585
2586 Syntax::
2587
2588 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2589
2590 FLOAT_REP ::= VAX_Float | IEEE_Float
2591
2592
2593 In the one argument form, this pragma is a configuration pragma which
2594 allows control over the internal representation chosen for the predefined
2595 floating point types declared in the packages ``Standard`` and
2596 ``System``. This pragma is only provided for compatibility and has no effect.
2597
2598 The two argument form specifies the representation to be used for
2599 the specified floating-point type. The argument must
2600 be ``IEEE_Float`` to specify the use of IEEE format, as follows:
2601
2602 *
2603 For a digits value of 6, 32-bit IEEE short format will be used.
2604 *
2605 For a digits value of 15, 64-bit IEEE long format will be used.
2606 *
2607 No other value of digits is permitted.
2608
2609 .. _Pragma-Ghost:
2610
2611 Pragma Ghost
2612 ============
2613
2614 Syntax:
2615
2616 .. code-block:: ada
2617
2618 pragma Ghost [ (boolean_EXPRESSION) ];
2619
2620 For the semantics of this pragma, see the entry for aspect ``Ghost`` in the SPARK
2621 2014 Reference Manual, section 6.9.
2622
2623 .. _Pragma-Global:
2624
2625 Pragma Global
2626 =============
2627
2628 Syntax:
2629
2630 .. code-block:: ada
2631
2632 pragma Global (GLOBAL_SPECIFICATION);
2633
2634 GLOBAL_SPECIFICATION ::=
2635 null
2636 | (GLOBAL_LIST)
2637 | (MODED_GLOBAL_LIST {, MODED_GLOBAL_LIST})
2638
2639 MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
2640
2641 MODE_SELECTOR ::= In_Out | Input | Output | Proof_In
2642 GLOBAL_LIST ::= GLOBAL_ITEM | (GLOBAL_ITEM {, GLOBAL_ITEM})
2643 GLOBAL_ITEM ::= NAME
2644
2645 For the semantics of this pragma, see the entry for aspect ``Global`` in the
2646 SPARK 2014 Reference Manual, section 6.1.4.
2647
2648 Pragma Ident
2649 ============
2650
2651 Syntax:
2652
2653
2654 .. code-block:: ada
2655
2656 pragma Ident (static_string_EXPRESSION);
2657
2658
2659 This pragma is identical in effect to pragma ``Comment``. It is provided
2660 for compatibility with other Ada compilers providing this pragma.
2661
2662 Pragma Ignore_Pragma
2663 ====================
2664
2665 Syntax:
2666
2667
2668 .. code-block:: ada
2669
2670 pragma Ignore_Pragma (pragma_IDENTIFIER);
2671
2672 This is a configuration pragma
2673 that takes a single argument that is a simple identifier. Any subsequent
2674 use of a pragma whose pragma identifier matches this argument will be
2675 silently ignored. This may be useful when legacy code or code intended
2676 for compilation with some other compiler contains pragmas that match the
2677 name, but not the exact implementation, of a GNAT pragma. The use of this
2678 pragma allows such pragmas to be ignored, which may be useful in CodePeer
2679 mode, or during porting of legacy code.
2680
2681 Pragma Implementation_Defined
2682 =============================
2683
2684 Syntax:
2685
2686
2687 .. code-block:: ada
2688
2689 pragma Implementation_Defined (local_NAME);
2690
2691
2692 This pragma marks a previously declared entity as implementation-defined.
2693 For an overloaded entity, applies to the most recent homonym.
2694
2695
2696 .. code-block:: ada
2697
2698 pragma Implementation_Defined;
2699
2700
2701 The form with no arguments appears anywhere within a scope, most
2702 typically a package spec, and indicates that all entities that are
2703 defined within the package spec are Implementation_Defined.
2704
2705 This pragma is used within the GNAT runtime library to identify
2706 implementation-defined entities introduced in language-defined units,
2707 for the purpose of implementing the No_Implementation_Identifiers
2708 restriction.
2709
2710 Pragma Implemented
2711 ==================
2712
2713 Syntax:
2714
2715
2716 ::
2717
2718 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2719
2720 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2721
2722
2723 This is an Ada 2012 representation pragma which applies to protected, task
2724 and synchronized interface primitives. The use of pragma Implemented provides
2725 a way to impose a static requirement on the overriding operation by adhering
2726 to one of the three implementation kinds: entry, protected procedure or any of
2727 the above. This pragma is available in all earlier versions of Ada as an
2728 implementation-defined pragma.
2729
2730
2731 .. code-block:: ada
2732
2733 type Synch_Iface is synchronized interface;
2734 procedure Prim_Op (Obj : in out Iface) is abstract;
2735 pragma Implemented (Prim_Op, By_Protected_Procedure);
2736
2737 protected type Prot_1 is new Synch_Iface with
2738 procedure Prim_Op; -- Legal
2739 end Prot_1;
2740
2741 protected type Prot_2 is new Synch_Iface with
2742 entry Prim_Op; -- Illegal
2743 end Prot_2;
2744
2745 task type Task_Typ is new Synch_Iface with
2746 entry Prim_Op; -- Illegal
2747 end Task_Typ;
2748
2749
2750 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2751 Implemented determines the runtime behavior of the requeue. Implementation kind
2752 By_Entry guarantees that the action of requeueing will proceed from an entry to
2753 another entry. Implementation kind By_Protected_Procedure transforms the
2754 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2755 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2756 the target's overriding subprogram kind.
2757
2758 Pragma Implicit_Packing
2759 =======================
2760 .. index:: Rational Profile
2761
2762 Syntax:
2763
2764
2765 .. code-block:: ada
2766
2767 pragma Implicit_Packing;
2768
2769
2770 This is a configuration pragma that requests implicit packing for packed
2771 arrays for which a size clause is given but no explicit pragma Pack or
2772 specification of Component_Size is present. It also applies to records
2773 where no record representation clause is present. Consider this example:
2774
2775
2776 .. code-block:: ada
2777
2778 type R is array (0 .. 7) of Boolean;
2779 for R'Size use 8;
2780
2781
2782 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2783 does not change the layout of a composite object. So the Size clause in the
2784 above example is normally rejected, since the default layout of the array uses
2785 8-bit components, and thus the array requires a minimum of 64 bits.
2786
2787 If this declaration is compiled in a region of code covered by an occurrence
2788 of the configuration pragma Implicit_Packing, then the Size clause in this
2789 and similar examples will cause implicit packing and thus be accepted. For
2790 this implicit packing to occur, the type in question must be an array of small
2791 components whose size is known at compile time, and the Size clause must
2792 specify the exact size that corresponds to the number of elements in the array
2793 multiplied by the size in bits of the component type (both single and
2794 multi-dimensioned arrays can be controlled with this pragma).
2795
2796 .. index:: Array packing
2797
2798 Similarly, the following example shows the use in the record case
2799
2800
2801 .. code-block:: ada
2802
2803 type r is record
2804 a, b, c, d, e, f, g, h : boolean;
2805 chr : character;
2806 end record;
2807 for r'size use 16;
2808
2809
2810 Without a pragma Pack, each Boolean field requires 8 bits, so the
2811 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2812 sufficient. The use of pragma Implicit_Packing allows this record
2813 declaration to compile without an explicit pragma Pack.
2814
2815 Pragma Import_Function
2816 ======================
2817
2818 Syntax:
2819
2820
2821 ::
2822
2823 pragma Import_Function (
2824 [Internal =>] LOCAL_NAME,
2825 [, [External =>] EXTERNAL_SYMBOL]
2826 [, [Parameter_Types =>] PARAMETER_TYPES]
2827 [, [Result_Type =>] SUBTYPE_MARK]
2828 [, [Mechanism =>] MECHANISM]
2829 [, [Result_Mechanism =>] MECHANISM_NAME]);
2830
2831 EXTERNAL_SYMBOL ::=
2832 IDENTIFIER
2833 | static_string_EXPRESSION
2834
2835 PARAMETER_TYPES ::=
2836 null
2837 | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2838
2839 TYPE_DESIGNATOR ::=
2840 subtype_NAME
2841 | subtype_Name ' Access
2842
2843 MECHANISM ::=
2844 MECHANISM_NAME
2845 | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2846
2847 MECHANISM_ASSOCIATION ::=
2848 [formal_parameter_NAME =>] MECHANISM_NAME
2849
2850 MECHANISM_NAME ::=
2851 Value
2852 | Reference
2853
2854
2855 This pragma is used in conjunction with a pragma ``Import`` to
2856 specify additional information for an imported function. The pragma
2857 ``Import`` (or equivalent pragma ``Interface``) must precede the
2858 ``Import_Function`` pragma and both must appear in the same
2859 declarative part as the function specification.
2860
2861 The ``Internal`` argument must uniquely designate
2862 the function to which the
2863 pragma applies. If more than one function name exists of this name in
2864 the declarative part you must use the ``Parameter_Types`` and
2865 ``Result_Type`` parameters to achieve the required unique
2866 designation. Subtype marks in these parameters must exactly match the
2867 subtypes in the corresponding function specification, using positional
2868 notation to match parameters with subtype marks.
2869 The form with an ``'Access`` attribute can be used to match an
2870 anonymous access parameter.
2871
2872 You may optionally use the ``Mechanism`` and ``Result_Mechanism``
2873 parameters to specify passing mechanisms for the
2874 parameters and result. If you specify a single mechanism name, it
2875 applies to all parameters. Otherwise you may specify a mechanism on a
2876 parameter by parameter basis using either positional or named
2877 notation. If the mechanism is not specified, the default mechanism
2878 is used.
2879
2880 Pragma Import_Object
2881 ====================
2882
2883 Syntax:
2884
2885
2886 ::
2887
2888 pragma Import_Object
2889 [Internal =>] LOCAL_NAME
2890 [, [External =>] EXTERNAL_SYMBOL]
2891 [, [Size =>] EXTERNAL_SYMBOL]);
2892
2893 EXTERNAL_SYMBOL ::=
2894 IDENTIFIER
2895 | static_string_EXPRESSION
2896
2897
2898 This pragma designates an object as imported, and apart from the
2899 extended rules for external symbols, is identical in effect to the use of
2900 the normal ``Import`` pragma applied to an object. Unlike the
2901 subprogram case, you need not use a separate ``Import`` pragma,
2902 although you may do so (and probably should do so from a portability
2903 point of view). ``size`` is syntax checked, but otherwise ignored by
2904 GNAT.
2905
2906 Pragma Import_Procedure
2907 =======================
2908
2909 Syntax:
2910
2911
2912 ::
2913
2914 pragma Import_Procedure (
2915 [Internal =>] LOCAL_NAME
2916 [, [External =>] EXTERNAL_SYMBOL]
2917 [, [Parameter_Types =>] PARAMETER_TYPES]
2918 [, [Mechanism =>] MECHANISM]);
2919
2920 EXTERNAL_SYMBOL ::=
2921 IDENTIFIER
2922 | static_string_EXPRESSION
2923
2924 PARAMETER_TYPES ::=
2925 null
2926 | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2927
2928 TYPE_DESIGNATOR ::=
2929 subtype_NAME
2930 | subtype_Name ' Access
2931
2932 MECHANISM ::=
2933 MECHANISM_NAME
2934 | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2935
2936 MECHANISM_ASSOCIATION ::=
2937 [formal_parameter_NAME =>] MECHANISM_NAME
2938
2939 MECHANISM_NAME ::= Value | Reference
2940
2941
2942 This pragma is identical to ``Import_Function`` except that it
2943 applies to a procedure rather than a function and the parameters
2944 ``Result_Type`` and ``Result_Mechanism`` are not permitted.
2945
2946 Pragma Import_Valued_Procedure
2947 ==============================
2948
2949 Syntax:
2950
2951
2952 ::
2953
2954 pragma Import_Valued_Procedure (
2955 [Internal =>] LOCAL_NAME
2956 [, [External =>] EXTERNAL_SYMBOL]
2957 [, [Parameter_Types =>] PARAMETER_TYPES]
2958 [, [Mechanism =>] MECHANISM]);
2959
2960 EXTERNAL_SYMBOL ::=
2961 IDENTIFIER
2962 | static_string_EXPRESSION
2963
2964 PARAMETER_TYPES ::=
2965 null
2966 | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2967
2968 TYPE_DESIGNATOR ::=
2969 subtype_NAME
2970 | subtype_Name ' Access
2971
2972 MECHANISM ::=
2973 MECHANISM_NAME
2974 | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2975
2976 MECHANISM_ASSOCIATION ::=
2977 [formal_parameter_NAME =>] MECHANISM_NAME
2978
2979 MECHANISM_NAME ::= Value | Reference
2980
2981
2982 This pragma is identical to ``Import_Procedure`` except that the
2983 first parameter of ``LOCAL_NAME``, which must be present, must be of
2984 mode ``out``, and externally the subprogram is treated as a function
2985 with this parameter as the result of the function. The purpose of this
2986 capability is to allow the use of ``out`` and ``in out``
2987 parameters in interfacing to external functions (which are not permitted
2988 in Ada functions). You may optionally use the ``Mechanism``
2989 parameters to specify passing mechanisms for the parameters.
2990 If you specify a single mechanism name, it applies to all parameters.
2991 Otherwise you may specify a mechanism on a parameter by parameter
2992 basis using either positional or named notation. If the mechanism is not
2993 specified, the default mechanism is used.
2994
2995 Note that it is important to use this pragma in conjunction with a separate
2996 pragma Import that specifies the desired convention, since otherwise the
2997 default convention is Ada, which is almost certainly not what is required.
2998
2999 Pragma Independent
3000 ==================
3001
3002 Syntax:
3003
3004
3005 .. code-block:: ada
3006
3007 pragma Independent (Local_NAME);
3008
3009
3010 This pragma is standard in Ada 2012 mode (which also provides an aspect
3011 of the same name). It is also available as an implementation-defined
3012 pragma in all earlier versions. It specifies that the
3013 designated object or all objects of the designated type must be
3014 independently addressable. This means that separate tasks can safely
3015 manipulate such objects. For example, if two components of a record are
3016 independent, then two separate tasks may access these two components.
3017 This may place
3018 constraints on the representation of the object (for instance prohibiting
3019 tight packing).
3020
3021 Pragma Independent_Components
3022 =============================
3023
3024 Syntax:
3025
3026
3027 .. code-block:: ada
3028
3029 pragma Independent_Components (Local_NAME);
3030
3031
3032 This pragma is standard in Ada 2012 mode (which also provides an aspect
3033 of the same name). It is also available as an implementation-defined
3034 pragma in all earlier versions. It specifies that the components of the
3035 designated object, or the components of each object of the designated
3036 type, must be
3037 independently addressable. This means that separate tasks can safely
3038 manipulate separate components in the composite object. This may place
3039 constraints on the representation of the object (for instance prohibiting
3040 tight packing).
3041
3042 .. _Pragma-Initial_Condition:
3043
3044 Pragma Initial_Condition
3045 ========================
3046
3047 Syntax:
3048
3049 .. code-block:: ada
3050
3051 pragma Initial_Condition (boolean_EXPRESSION);
3052
3053 For the semantics of this pragma, see the entry for aspect ``Initial_Condition``
3054 in the SPARK 2014 Reference Manual, section 7.1.6.
3055
3056 Pragma Initialize_Scalars
3057 =========================
3058 .. index:: debugging with Initialize_Scalars
3059
3060 Syntax:
3061
3062
3063 .. code-block:: ada
3064
3065 pragma Initialize_Scalars
3066 [ ( TYPE_VALUE_PAIR {, TYPE_VALUE_PAIR} ) ];
3067
3068 TYPE_VALUE_PAIR ::=
3069 SCALAR_TYPE => static_EXPRESSION
3070
3071 SCALAR_TYPE :=
3072 Short_Float
3073 | Float
3074 | Long_Float
3075 | Long_Long_Flat
3076 | Signed_8
3077 | Signed_16
3078 | Signed_32
3079 | Signed_64
3080 | Unsigned_8
3081 | Unsigned_16
3082 | Unsigned_32
3083 | Unsigned_64
3084
3085
3086 This pragma is similar to ``Normalize_Scalars`` conceptually but has two
3087 important differences.
3088
3089 First, there is no requirement for the pragma to be used uniformly in all units
3090 of a partition. In particular, it is fine to use this just for some or all of
3091 the application units of a partition, without needing to recompile the run-time
3092 library. In the case where some units are compiled with the pragma, and some
3093 without, then a declaration of a variable where the type is defined in package
3094 Standard or is locally declared will always be subject to initialization, as
3095 will any declaration of a scalar variable. For composite variables, whether the
3096 variable is initialized may also depend on whether the package in which the
3097 type of the variable is declared is compiled with the pragma.
3098
3099 The other important difference is that the programmer can control the value
3100 used for initializing scalar objects. This effect can be achieved in several
3101 different ways:
3102
3103 * At compile time, the programmer can specify the invalid value for a
3104 particular family of scalar types using the optional arguments of the pragma.
3105
3106 The compile-time approach is intended to optimize the generated code for the
3107 pragma, by possibly using fast operations such as ``memset``. Note that such
3108 optimizations require using values where the bytes all have the same binary
3109 representation.
3110
3111 * At bind time, the programmer has several options:
3112
3113 * Initialization with invalid values (similar to Normalize_Scalars, though
3114 for Initialize_Scalars it is not always possible to determine the invalid
3115 values in complex cases like signed component fields with nonstandard
3116 sizes).
3117
3118 * Initialization with high values.
3119
3120 * Initialization with low values.
3121
3122 * Initialization with a specific bit pattern.
3123
3124 See the GNAT User's Guide for binder options for specifying these cases.
3125
3126 The bind-time approach is intended to provide fast turnaround for testing
3127 with different values, without having to recompile the program.
3128
3129 * At execution time, the programmer can specify the invalid values using an
3130 environment variable. See the GNAT User's Guide for details.
3131
3132 The execution-time approach is intended to provide fast turnaround for
3133 testing with different values, without having to recompile and rebind the
3134 program.
3135
3136 Note that pragma ``Initialize_Scalars`` is particularly useful in conjunction
3137 with the enhanced validity checking that is now provided in GNAT, which checks
3138 for invalid values under more conditions. Using this feature (see description
3139 of the *-gnatV* flag in the GNAT User's Guide) in conjunction with pragma
3140 ``Initialize_Scalars`` provides a powerful new tool to assist in the detection
3141 of problems caused by uninitialized variables.
3142
3143 Note: the use of ``Initialize_Scalars`` has a fairly extensive effect on the
3144 generated code. This may cause your code to be substantially larger. It may
3145 also cause an increase in the amount of stack required, so it is probably a
3146 good idea to turn on stack checking (see description of stack checking in the
3147 GNAT User's Guide) when using this pragma.
3148
3149 .. _Pragma-Initializes:
3150
3151 Pragma Initializes
3152 ==================
3153
3154 Syntax:
3155
3156 .. code-block:: ada
3157
3158 pragma Initializes (INITIALIZATION_LIST);
3159
3160 INITIALIZATION_LIST ::=
3161 null
3162 | (INITIALIZATION_ITEM {, INITIALIZATION_ITEM})
3163
3164 INITIALIZATION_ITEM ::= name [=> INPUT_LIST]
3165
3166 INPUT_LIST ::=
3167 null
3168 | INPUT
3169 | (INPUT {, INPUT})
3170
3171 INPUT ::= name
3172
3173 For the semantics of this pragma, see the entry for aspect ``Initializes`` in the
3174 SPARK 2014 Reference Manual, section 7.1.5.
3175
3176 .. _Pragma-Inline_Always:
3177
3178 Pragma Inline_Always
3179 ====================
3180
3181 Syntax:
3182
3183
3184 ::
3185
3186 pragma Inline_Always (NAME [, NAME]);
3187
3188
3189 Similar to pragma ``Inline`` except that inlining is unconditional.
3190 Inline_Always instructs the compiler to inline every direct call to the
3191 subprogram or else to emit a compilation error, independently of any
3192 option, in particular *-gnatn* or *-gnatN* or the optimization level.
3193 It is an error to take the address or access of ``NAME``. It is also an error to
3194 apply this pragma to a primitive operation of a tagged type. Thanks to such
3195 restrictions, the compiler is allowed to remove the out-of-line body of ``NAME``.
3196
3197 Pragma Inline_Generic
3198 =====================
3199
3200 Syntax:
3201
3202
3203 ::
3204
3205 pragma Inline_Generic (GNAME {, GNAME});
3206
3207 GNAME ::= generic_unit_NAME | generic_instance_NAME
3208
3209
3210 This pragma is provided for compatibility with Dec Ada 83. It has
3211 no effect in GNAT (which always inlines generics), other
3212 than to check that the given names are all names of generic units or
3213 generic instances.
3214
3215 Pragma Interface
3216 ================
3217
3218 Syntax:
3219
3220
3221 ::
3222
3223 pragma Interface (
3224 [Convention =>] convention_identifier,
3225 [Entity =>] local_NAME
3226 [, [External_Name =>] static_string_expression]
3227 [, [Link_Name =>] static_string_expression]);
3228
3229
3230 This pragma is identical in syntax and semantics to
3231 the standard Ada pragma ``Import``. It is provided for compatibility
3232 with Ada 83. The definition is upwards compatible both with pragma
3233 ``Interface`` as defined in the Ada 83 Reference Manual, and also
3234 with some extended implementations of this pragma in certain Ada 83
3235 implementations. The only difference between pragma ``Interface``
3236 and pragma ``Import`` is that there is special circuitry to allow
3237 both pragmas to appear for the same subprogram entity (normally it
3238 is illegal to have multiple ``Import`` pragmas. This is useful in
3239 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3240 Ada 83 compilers.
3241
3242 Pragma Interface_Name
3243 =====================
3244
3245 Syntax:
3246
3247
3248 ::
3249
3250 pragma Interface_Name (
3251 [Entity =>] LOCAL_NAME
3252 [, [External_Name =>] static_string_EXPRESSION]
3253 [, [Link_Name =>] static_string_EXPRESSION]);
3254
3255
3256 This pragma provides an alternative way of specifying the interface name
3257 for an interfaced subprogram, and is provided for compatibility with Ada
3258 83 compilers that use the pragma for this purpose. You must provide at
3259 least one of ``External_Name`` or ``Link_Name``.
3260
3261 Pragma Interrupt_Handler
3262 ========================
3263
3264 Syntax:
3265
3266
3267 .. code-block:: ada
3268
3269 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3270
3271
3272 This program unit pragma is supported for parameterless protected procedures
3273 as described in Annex C of the Ada Reference Manual.
3274
3275 Pragma Interrupt_State
3276 ======================
3277
3278 Syntax:
3279
3280
3281 ::
3282
3283 pragma Interrupt_State
3284 ([Name =>] value,
3285 [State =>] SYSTEM | RUNTIME | USER);
3286
3287
3288 Normally certain interrupts are reserved to the implementation. Any attempt
3289 to attach an interrupt causes Program_Error to be raised, as described in
3290 RM C.3.2(22). A typical example is the ``SIGINT`` interrupt used in
3291 many systems for an :kbd:`Ctrl-C` interrupt. Normally this interrupt is
3292 reserved to the implementation, so that :kbd:`Ctrl-C` can be used to
3293 interrupt execution. Additionally, signals such as ``SIGSEGV``,
3294 ``SIGABRT``, ``SIGFPE`` and ``SIGILL`` are often mapped to specific
3295 Ada exceptions, or used to implement run-time functions such as the
3296 ``abort`` statement and stack overflow checking.
3297
3298 Pragma ``Interrupt_State`` provides a general mechanism for overriding
3299 such uses of interrupts. It subsumes the functionality of pragma
3300 ``Unreserve_All_Interrupts``. Pragma ``Interrupt_State`` is not
3301 available on Windows. On all other platforms than VxWorks,
3302 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3303 and may be used to mark interrupts required by the board support package
3304 as reserved.
3305
3306 Interrupts can be in one of three states:
3307
3308 * System
3309
3310 The interrupt is reserved (no Ada handler can be installed), and the
3311 Ada run-time may not install a handler. As a result you are guaranteed
3312 standard system default action if this interrupt is raised. This also allows
3313 installing a low level handler via C APIs such as sigaction(), outside
3314 of Ada control.
3315
3316 * Runtime
3317
3318 The interrupt is reserved (no Ada handler can be installed). The run time
3319 is allowed to install a handler for internal control purposes, but is
3320 not required to do so.
3321
3322 * User
3323
3324 The interrupt is unreserved. The user may install an Ada handler via
3325 Ada.Interrupts and pragma Interrupt_Handler or Attach_Handler to provide
3326 some other action.
3327
3328 These states are the allowed values of the ``State`` parameter of the
3329 pragma. The ``Name`` parameter is a value of the type
3330 ``Ada.Interrupts.Interrupt_ID``. Typically, it is a name declared in
3331 ``Ada.Interrupts.Names``.
3332
3333 This is a configuration pragma, and the binder will check that there
3334 are no inconsistencies between different units in a partition in how a
3335 given interrupt is specified. It may appear anywhere a pragma is legal.
3336
3337 The effect is to move the interrupt to the specified state.
3338
3339 By declaring interrupts to be SYSTEM, you guarantee the standard system
3340 action, such as a core dump.
3341
3342 By declaring interrupts to be USER, you guarantee that you can install
3343 a handler.
3344
3345 Note that certain signals on many operating systems cannot be caught and
3346 handled by applications. In such cases, the pragma is ignored. See the
3347 operating system documentation, or the value of the array ``Reserved``
3348 declared in the spec of package ``System.OS_Interface``.
3349
3350 Overriding the default state of signals used by the Ada runtime may interfere
3351 with an application's runtime behavior in the cases of the synchronous signals,
3352 and in the case of the signal used to implement the ``abort`` statement.
3353
3354 .. _Pragma-Invariant:
3355
3356 Pragma Invariant
3357 ================
3358
3359 Syntax:
3360
3361
3362 ::
3363
3364 pragma Invariant
3365 ([Entity =>] private_type_LOCAL_NAME,
3366 [Check =>] EXPRESSION
3367 [,[Message =>] String_Expression]);
3368
3369
3370 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3371 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3372 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3373 requires the use of the aspect syntax, which is not available except in 2012
3374 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3375 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3376 note that the aspect Invariant is a synonym in GNAT for the aspect
3377 Type_Invariant, but there is no pragma Type_Invariant.
3378
3379 The pragma must appear within the visible part of the package specification,
3380 after the type to which its Entity argument appears. As with the Invariant
3381 aspect, the Check expression is not analyzed until the end of the visible
3382 part of the package, so it may contain forward references. The Message
3383 argument, if present, provides the exception message used if the invariant
3384 is violated. If no Message parameter is provided, a default message that
3385 identifies the line on which the pragma appears is used.
3386
3387 It is permissible to have multiple Invariants for the same type entity, in
3388 which case they are and'ed together. It is permissible to use this pragma
3389 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3390 invariant pragma for the same entity.
3391
3392 For further details on the use of this pragma, see the Ada 2012 documentation
3393 of the Type_Invariant aspect.
3394
3395 Pragma Keep_Names
3396 =================
3397
3398 Syntax:
3399
3400
3401 ::
3402
3403 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3404
3405
3406 The ``LOCAL_NAME`` argument
3407 must refer to an enumeration first subtype
3408 in the current declarative part. The effect is to retain the enumeration
3409 literal names for use by ``Image`` and ``Value`` even if a global
3410 ``Discard_Names`` pragma applies. This is useful when you want to
3411 generally suppress enumeration literal names and for example you therefore
3412 use a ``Discard_Names`` pragma in the :file:`gnat.adc` file, but you
3413 want to retain the names for specific enumeration types.
3414
3415 Pragma License
3416 ==============
3417 .. index:: License checking
3418
3419 Syntax:
3420
3421
3422 .. code-block:: ada
3423
3424 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3425
3426
3427 This pragma is provided to allow automated checking for appropriate license
3428 conditions with respect to the standard and modified GPL. A pragma
3429 ``License``, which is a configuration pragma that typically appears at
3430 the start of a source file or in a separate :file:`gnat.adc` file, specifies
3431 the licensing conditions of a unit as follows:
3432
3433 * Unrestricted
3434 This is used for a unit that can be freely used with no license restrictions.
3435 Examples of such units are public domain units, and units from the Ada
3436 Reference Manual.
3437
3438 * GPL
3439 This is used for a unit that is licensed under the unmodified GPL, and which
3440 therefore cannot be ``with``\ ed by a restricted unit.
3441
3442 * Modified_GPL
3443 This is used for a unit licensed under the GNAT modified GPL that includes
3444 a special exception paragraph that specifically permits the inclusion of
3445 the unit in programs without requiring the entire program to be released
3446 under the GPL.
3447
3448 * Restricted
3449 This is used for a unit that is restricted in that it is not permitted to
3450 depend on units that are licensed under the GPL. Typical examples are
3451 proprietary code that is to be released under more restrictive license
3452 conditions. Note that restricted units are permitted to ``with`` units
3453 which are licensed under the modified GPL (this is the whole point of the
3454 modified GPL).
3455
3456
3457 Normally a unit with no ``License`` pragma is considered to have an
3458 unknown license, and no checking is done. However, standard GNAT headers
3459 are recognized, and license information is derived from them as follows.
3460
3461 A GNAT license header starts with a line containing 78 hyphens. The following
3462 comment text is searched for the appearance of any of the following strings.
3463
3464 If the string 'GNU General Public License' is found, then the unit is assumed
3465 to have GPL license, unless the string 'As a special exception' follows, in
3466 which case the license is assumed to be modified GPL.
3467
3468 If one of the strings
3469 'This specification is adapted from the Ada Semantic Interface' or
3470 'This specification is derived from the Ada Reference Manual' is found
3471 then the unit is assumed to be unrestricted.
3472
3473 These default actions means that a program with a restricted license pragma
3474 will automatically get warnings if a GPL unit is inappropriately
3475 ``with``\ ed. For example, the program:
3476
3477 .. code-block:: ada
3478
3479 with Sem_Ch3;
3480 with GNAT.Sockets;
3481 procedure Secret_Stuff is
3482 ...
3483 end Secret_Stuff
3484
3485
3486 if compiled with pragma ``License`` (``Restricted``) in a
3487 :file:`gnat.adc` file will generate the warning::
3488
3489 1. with Sem_Ch3;
3490 |
3491 >>> license of withed unit "Sem_Ch3" is incompatible
3492
3493 2. with GNAT.Sockets;
3494 3. procedure Secret_Stuff is
3495
3496
3497 Here we get a warning on ``Sem_Ch3`` since it is part of the GNAT
3498 compiler and is licensed under the
3499 GPL, but no warning for ``GNAT.Sockets`` which is part of the GNAT
3500 run time, and is therefore licensed under the modified GPL.
3501
3502 Pragma Link_With
3503 ================
3504
3505 Syntax:
3506
3507
3508 ::
3509
3510 pragma Link_With (static_string_EXPRESSION {,static_string_EXPRESSION});
3511
3512
3513 This pragma is provided for compatibility with certain Ada 83 compilers.
3514 It has exactly the same effect as pragma ``Linker_Options`` except
3515 that spaces occurring within one of the string expressions are treated
3516 as separators. For example, in the following case:
3517
3518 .. code-block:: ada
3519
3520 pragma Link_With ("-labc -ldef");
3521
3522
3523 results in passing the strings ``-labc`` and ``-ldef`` as two
3524 separate arguments to the linker. In addition pragma Link_With allows
3525 multiple arguments, with the same effect as successive pragmas.
3526
3527 Pragma Linker_Alias
3528 ===================
3529
3530 Syntax:
3531
3532
3533 ::
3534
3535 pragma Linker_Alias (
3536 [Entity =>] LOCAL_NAME,
3537 [Target =>] static_string_EXPRESSION);
3538
3539
3540 ``LOCAL_NAME`` must refer to an object that is declared at the library
3541 level. This pragma establishes the given entity as a linker alias for the
3542 given target. It is equivalent to ``__attribute__((alias))`` in GNU C
3543 and causes ``LOCAL_NAME`` to be emitted as an alias for the symbol
3544 ``static_string_EXPRESSION`` in the object file, that is to say no space
3545 is reserved for ``LOCAL_NAME`` by the assembler and it will be resolved
3546 to the same address as ``static_string_EXPRESSION`` by the linker.
3547
3548 The actual linker name for the target must be used (e.g., the fully
3549 encoded name with qualification in Ada, or the mangled name in C++),
3550 or it must be declared using the C convention with ``pragma Import``
3551 or ``pragma Export``.
3552
3553 Not all target machines support this pragma. On some of them it is accepted
3554 only if ``pragma Weak_External`` has been applied to ``LOCAL_NAME``.
3555
3556
3557 .. code-block:: ada
3558
3559 -- Example of the use of pragma Linker_Alias
3560
3561 package p is
3562 i : Integer := 1;
3563 pragma Export (C, i);
3564
3565 new_name_for_i : Integer;
3566 pragma Linker_Alias (new_name_for_i, "i");
3567 end p;
3568
3569
3570 Pragma Linker_Constructor
3571 =========================
3572
3573 Syntax:
3574
3575
3576 .. code-block:: ada
3577
3578 pragma Linker_Constructor (procedure_LOCAL_NAME);
3579
3580
3581 ``procedure_LOCAL_NAME`` must refer to a parameterless procedure that
3582 is declared at the library level. A procedure to which this pragma is
3583 applied will be treated as an initialization routine by the linker.
3584 It is equivalent to ``__attribute__((constructor))`` in GNU C and
3585 causes ``procedure_LOCAL_NAME`` to be invoked before the entry point
3586 of the executable is called (or immediately after the shared library is
3587 loaded if the procedure is linked in a shared library), in particular
3588 before the Ada run-time environment is set up.
3589
3590 Because of these specific contexts, the set of operations such a procedure
3591 can perform is very limited and the type of objects it can manipulate is
3592 essentially restricted to the elementary types. In particular, it must only
3593 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3594
3595 This pragma is used by GNAT to implement auto-initialization of shared Stand
3596 Alone Libraries, which provides a related capability without the restrictions
3597 listed above. Where possible, the use of Stand Alone Libraries is preferable
3598 to the use of this pragma.
3599
3600 Pragma Linker_Destructor
3601 ========================
3602
3603 Syntax:
3604
3605
3606 .. code-block:: ada
3607
3608 pragma Linker_Destructor (procedure_LOCAL_NAME);
3609
3610
3611 ``procedure_LOCAL_NAME`` must refer to a parameterless procedure that
3612 is declared at the library level. A procedure to which this pragma is
3613 applied will be treated as a finalization routine by the linker.
3614 It is equivalent to ``__attribute__((destructor))`` in GNU C and
3615 causes ``procedure_LOCAL_NAME`` to be invoked after the entry point
3616 of the executable has exited (or immediately before the shared library
3617 is unloaded if the procedure is linked in a shared library), in particular
3618 after the Ada run-time environment is shut down.
3619
3620 See ``pragma Linker_Constructor`` for the set of restrictions that apply
3621 because of these specific contexts.
3622
3623 .. _Pragma-Linker_Section:
3624
3625 Pragma Linker_Section
3626 =====================
3627
3628 Syntax:
3629
3630
3631 ::
3632
3633 pragma Linker_Section (
3634 [Entity =>] LOCAL_NAME,
3635 [Section =>] static_string_EXPRESSION);
3636
3637
3638 ``LOCAL_NAME`` must refer to an object, type, or subprogram that is
3639 declared at the library level. This pragma specifies the name of the
3640 linker section for the given entity. It is equivalent to
3641 ``__attribute__((section))`` in GNU C and causes ``LOCAL_NAME`` to
3642 be placed in the ``static_string_EXPRESSION`` section of the
3643 executable (assuming the linker doesn't rename the section).
3644 GNAT also provides an implementation defined aspect of the same name.
3645
3646 In the case of specifying this aspect for a type, the effect is to
3647 specify the corresponding section for all library-level objects of
3648 the type that do not have an explicit linker section set. Note that
3649 this only applies to whole objects, not to components of composite objects.
3650
3651 In the case of a subprogram, the linker section applies to all previously
3652 declared matching overloaded subprograms in the current declarative part
3653 which do not already have a linker section assigned. The linker section
3654 aspect is useful in this case for specifying different linker sections
3655 for different elements of such an overloaded set.
3656
3657 Note that an empty string specifies that no linker section is specified.
3658 This is not quite the same as omitting the pragma or aspect, since it
3659 can be used to specify that one element of an overloaded set of subprograms
3660 has the default linker section, or that one object of a type for which a
3661 linker section is specified should has the default linker section.
3662
3663 The compiler normally places library-level entities in standard sections
3664 depending on the class: procedures and functions generally go in the
3665 ``.text`` section, initialized variables in the ``.data`` section
3666 and uninitialized variables in the ``.bss`` section.
3667
3668 Other, special sections may exist on given target machines to map special
3669 hardware, for example I/O ports or flash memory. This pragma is a means to
3670 defer the final layout of the executable to the linker, thus fully working
3671 at the symbolic level with the compiler.
3672
3673 Some file formats do not support arbitrary sections so not all target
3674 machines support this pragma. The use of this pragma may cause a program
3675 execution to be erroneous if it is used to place an entity into an
3676 inappropriate section (e.g., a modified variable into the ``.text``
3677 section). See also ``pragma Persistent_BSS``.
3678
3679
3680 .. code-block:: ada
3681
3682 -- Example of the use of pragma Linker_Section
3683
3684 package IO_Card is
3685 Port_A : Integer;
3686 pragma Volatile (Port_A);
3687 pragma Linker_Section (Port_A, ".bss.port_a");
3688
3689 Port_B : Integer;
3690 pragma Volatile (Port_B);
3691 pragma Linker_Section (Port_B, ".bss.port_b");
3692
3693 type Port_Type is new Integer with Linker_Section => ".bss";
3694 PA : Port_Type with Linker_Section => ".bss.PA";
3695 PB : Port_Type; -- ends up in linker section ".bss"
3696
3697 procedure Q with Linker_Section => "Qsection";
3698 end IO_Card;
3699
3700 .. _Pragma-Lock_Free:
3701
3702 Pragma Lock_Free
3703 ================
3704
3705 Syntax:
3706 This pragma may be specified for protected types or objects. It specifies that
3707 the implementation of protected operations must be implemented without locks.
3708 Compilation fails if the compiler cannot generate lock-free code for the
3709 operations.
3710
3711 The current conditions required to support this pragma are:
3712
3713 * Protected type declarations may not contain entries
3714 * Protected subprogram declarations may not have nonelementary parameters
3715
3716 In addition, each protected subprogram body must satisfy:
3717
3718 * May reference only one protected component
3719 * May not reference nonconstant entities outside the protected subprogram
3720 scope.
3721 * May not contain address representation items, allocators, or quantified
3722 expressions.
3723 * May not contain delay, goto, loop, or procedure-call statements.
3724 * May not contain exported and imported entities
3725 * May not dereferenced access values
3726 * Function calls and attribute references must be static
3727
3728
3729 Pragma Loop_Invariant
3730 =====================
3731
3732 Syntax:
3733
3734
3735 .. code-block:: ada
3736
3737 pragma Loop_Invariant ( boolean_EXPRESSION );
3738
3739
3740 The effect of this pragma is similar to that of pragma ``Assert``,
3741 except that in an ``Assertion_Policy`` pragma, the identifier
3742 ``Loop_Invariant`` is used to control whether it is ignored or checked
3743 (or disabled).
3744
3745 ``Loop_Invariant`` can only appear as one of the items in the sequence
3746 of statements of a loop body, or nested inside block statements that
3747 appear in the sequence of statements of a loop body.
3748 The intention is that it be used to
3749 represent a "loop invariant" assertion, i.e. something that is true each
3750 time through the loop, and which can be used to show that the loop is
3751 achieving its purpose.
3752
3753 Multiple ``Loop_Invariant`` and ``Loop_Variant`` pragmas that
3754 apply to the same loop should be grouped in the same sequence of
3755 statements.
3756
3757 To aid in writing such invariants, the special attribute ``Loop_Entry``
3758 may be used to refer to the value of an expression on entry to the loop. This
3759 attribute can only be used within the expression of a ``Loop_Invariant``
3760 pragma. For full details, see documentation of attribute ``Loop_Entry``.
3761
3762 Pragma Loop_Optimize
3763 ====================
3764
3765 Syntax:
3766
3767
3768 ::
3769
3770 pragma Loop_Optimize (OPTIMIZATION_HINT {, OPTIMIZATION_HINT});
3771
3772 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
3773
3774
3775 This pragma must appear immediately within a loop statement. It allows the
3776 programmer to specify optimization hints for the enclosing loop. The hints
3777 are not mutually exclusive and can be freely mixed, but not all combinations
3778 will yield a sensible outcome.
3779
3780 There are five supported optimization hints for a loop:
3781
3782 * Ivdep
3783
3784 The programmer asserts that there are no loop-carried dependencies
3785 which would prevent consecutive iterations of the loop from being
3786 executed simultaneously.
3787
3788 * No_Unroll
3789
3790 The loop must not be unrolled. This is a strong hint: the compiler will not
3791 unroll a loop marked with this hint.
3792
3793 * Unroll
3794
3795 The loop should be unrolled. This is a weak hint: the compiler will try to
3796 apply unrolling to this loop preferably to other optimizations, notably
3797 vectorization, but there is no guarantee that the loop will be unrolled.
3798
3799 * No_Vector
3800
3801 The loop must not be vectorized. This is a strong hint: the compiler will not
3802 vectorize a loop marked with this hint.
3803
3804 * Vector
3805
3806 The loop should be vectorized. This is a weak hint: the compiler will try to
3807 apply vectorization to this loop preferably to other optimizations, notably
3808 unrolling, but there is no guarantee that the loop will be vectorized.
3809
3810
3811 These hints do not remove the need to pass the appropriate switches to the
3812 compiler in order to enable the relevant optimizations, that is to say
3813 *-funroll-loops* for unrolling and *-ftree-vectorize* for
3814 vectorization.
3815
3816 Pragma Loop_Variant
3817 ===================
3818
3819 Syntax:
3820
3821
3822 ::
3823
3824 pragma Loop_Variant ( LOOP_VARIANT_ITEM {, LOOP_VARIANT_ITEM } );
3825 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
3826 CHANGE_DIRECTION ::= Increases | Decreases
3827
3828
3829 ``Loop_Variant`` can only appear as one of the items in the sequence
3830 of statements of a loop body, or nested inside block statements that
3831 appear in the sequence of statements of a loop body.
3832 It allows the specification of quantities which must always
3833 decrease or increase in successive iterations of the loop. In its simplest
3834 form, just one expression is specified, whose value must increase or decrease
3835 on each iteration of the loop.
3836
3837 In a more complex form, multiple arguments can be given which are intepreted
3838 in a nesting lexicographic manner. For example:
3839
3840 .. code-block:: ada
3841
3842 pragma Loop_Variant (Increases => X, Decreases => Y);
3843
3844
3845 specifies that each time through the loop either X increases, or X stays
3846 the same and Y decreases. A ``Loop_Variant`` pragma ensures that the
3847 loop is making progress. It can be useful in helping to show informally
3848 or prove formally that the loop always terminates.
3849
3850 ``Loop_Variant`` is an assertion whose effect can be controlled using
3851 an ``Assertion_Policy`` with a check name of ``Loop_Variant``. The
3852 policy can be ``Check`` to enable the loop variant check, ``Ignore``
3853 to ignore the check (in which case the pragma has no effect on the program),
3854 or ``Disable`` in which case the pragma is not even checked for correct
3855 syntax.
3856
3857 Multiple ``Loop_Invariant`` and ``Loop_Variant`` pragmas that
3858 apply to the same loop should be grouped in the same sequence of
3859 statements.
3860
3861 The ``Loop_Entry`` attribute may be used within the expressions of the
3862 ``Loop_Variant`` pragma to refer to values on entry to the loop.
3863
3864 Pragma Machine_Attribute
3865 ========================
3866
3867 Syntax:
3868
3869
3870 ::
3871
3872 pragma Machine_Attribute (
3873 [Entity =>] LOCAL_NAME,
3874 [Attribute_Name =>] static_string_EXPRESSION
3875 [, [Info =>] static_EXPRESSION {, static_EXPRESSION}] );
3876
3877
3878 Machine-dependent attributes can be specified for types and/or
3879 declarations. This pragma is semantically equivalent to
3880 :samp:`__attribute__(({attribute_name}))` (if ``info`` is not
3881 specified) or :samp:`__attribute__(({attribute_name(info})))`
3882 or :samp:`__attribute__(({attribute_name(info,...})))` in GNU C,
3883 where *attribute_name* is recognized by the compiler middle-end
3884 or the ``TARGET_ATTRIBUTE_TABLE`` machine specific macro. Note
3885 that a string literal for the optional parameter ``info`` or the
3886 following ones is transformed by default into an identifier,
3887 which may make this pragma unusable for some attributes.
3888 For further information see :title:`GNU Compiler Collection (GCC) Internals`.
3889
3890 Pragma Main
3891 ===========
3892
3893 Syntax::
3894
3895 pragma Main
3896 (MAIN_OPTION [, MAIN_OPTION]);
3897
3898 MAIN_OPTION ::=
3899 [Stack_Size =>] static_integer_EXPRESSION
3900 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3901 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3902
3903
3904 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3905 no effect in GNAT, other than being syntax checked.
3906
3907 Pragma Main_Storage
3908 ===================
3909
3910 Syntax::
3911
3912 pragma Main_Storage
3913 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3914
3915 MAIN_STORAGE_OPTION ::=
3916 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3917 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3918
3919
3920 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3921 no effect in GNAT, other than being syntax checked.
3922
3923 .. _Pragma-Max_Queue_Length:
3924
3925 Pragma Max_Queue_Length
3926 =======================
3927
3928 Syntax::
3929
3930 pragma Max_Entry_Queue (static_integer_EXPRESSION);
3931
3932
3933 This pragma is used to specify the maximum callers per entry queue for
3934 individual protected entries and entry families. It accepts a single
3935 integer (-1 or more) as a parameter and must appear after the declaration of an
3936 entry.
3937
3938 A value of -1 represents no additional restriction on queue length.
3939
3940 Pragma No_Body
3941 ==============
3942
3943 Syntax:
3944
3945
3946 .. code-block:: ada
3947
3948 pragma No_Body;
3949
3950
3951 There are a number of cases in which a package spec does not require a body,
3952 and in fact a body is not permitted. GNAT will not permit the spec to be
3953 compiled if there is a body around. The pragma No_Body allows you to provide
3954 a body file, even in a case where no body is allowed. The body file must
3955 contain only comments and a single No_Body pragma. This is recognized by
3956 the compiler as indicating that no body is logically present.
3957
3958 This is particularly useful during maintenance when a package is modified in
3959 such a way that a body needed before is no longer needed. The provision of a
3960 dummy body with a No_Body pragma ensures that there is no interference from
3961 earlier versions of the package body.
3962
3963 .. _Pragma-No_Caching:
3964
3965 Pragma No_Caching
3966 =================
3967
3968 Syntax:
3969
3970 .. code-block:: ada
3971
3972 pragma No_Caching [ (boolean_EXPRESSION) ];
3973
3974 For the semantics of this pragma, see the entry for aspect ``No_Caching`` in
3975 the SPARK 2014 Reference Manual, section 7.1.2.
3976
3977 Pragma No_Component_Reordering
3978 ==============================
3979
3980 Syntax:
3981
3982
3983 ::
3984
3985 pragma No_Component_Reordering [([Entity =>] type_LOCAL_NAME)];
3986
3987
3988 ``type_LOCAL_NAME`` must refer to a record type declaration in the current
3989 declarative part. The effect is to preclude any reordering of components
3990 for the layout of the record, i.e. the record is laid out by the compiler
3991 in the order in which the components are declared textually. The form with
3992 no argument is a configuration pragma which applies to all record types
3993 declared in units to which the pragma applies and there is a requirement
3994 that this pragma be used consistently within a partition.
3995
3996 .. _Pragma-No_Elaboration_Code_All:
3997
3998 Pragma No_Elaboration_Code_All
3999 ==============================
4000
4001 Syntax:
4002
4003
4004 ::
4005
4006 pragma No_Elaboration_Code_All [(program_unit_NAME)];
4007
4008
4009 This is a program unit pragma (there is also an equivalent aspect of the
4010 same name) that establishes the restriction ``No_Elaboration_Code`` for
4011 the current unit and any extended main source units (body and subunits).
4012 It also has the effect of enforcing a transitive application of this
4013 aspect, so that if any unit is implicitly or explicitly with'ed by the
4014 current unit, it must also have the No_Elaboration_Code_All aspect set.
4015 It may be applied to package or subprogram specs or their generic versions.
4016
4017 Pragma No_Heap_Finalization
4018 ===========================
4019
4020 Syntax:
4021
4022
4023 ::
4024
4025 pragma No_Heap_Finalization [ (first_subtype_LOCAL_NAME) ];
4026
4027
4028 Pragma ``No_Heap_Finalization`` may be used as a configuration pragma or as a
4029 type-specific pragma.
4030
4031 In its configuration form, the pragma must appear within a configuration file
4032 such as gnat.adc, without an argument. The pragma suppresses the call to
4033 ``Finalize`` for heap-allocated objects created through library-level named
4034 access-to-object types in cases where the designated type requires finalization
4035 actions.
4036
4037 In its type-specific form, the argument of the pragma must denote a
4038 library-level named access-to-object type. The pragma suppresses the call to
4039 ``Finalize`` for heap-allocated objects created through the specific access type
4040 in cases where the designated type requires finalization actions.
4041
4042 It is still possible to finalize such heap-allocated objects by explicitly
4043 deallocating them.
4044
4045 A library-level named access-to-object type declared within a generic unit will
4046 lose its ``No_Heap_Finalization`` pragma when the corresponding instance does not
4047 appear at the library level.
4048
4049 .. _Pragma-No_Inline:
4050
4051 Pragma No_Inline
4052 ================
4053
4054 Syntax:
4055
4056
4057 ::
4058
4059 pragma No_Inline (NAME {, NAME});
4060
4061
4062 This pragma suppresses inlining for the callable entity or the instances of
4063 the generic subprogram designated by ``NAME``, including inlining that
4064 results from the use of pragma ``Inline``. This pragma is always active,
4065 in particular it is not subject to the use of option *-gnatn* or
4066 *-gnatN*. It is illegal to specify both pragma ``No_Inline`` and
4067 pragma ``Inline_Always`` for the same ``NAME``.
4068
4069 Pragma No_Return
4070 ================
4071
4072 Syntax:
4073
4074
4075 ::
4076
4077 pragma No_Return (procedure_LOCAL_NAME {, procedure_LOCAL_NAME});
4078
4079
4080 Each ``procedure_LOCAL_NAME`` argument must refer to one or more procedure
4081 declarations in the current declarative part. A procedure to which this
4082 pragma is applied may not contain any explicit ``return`` statements.
4083 In addition, if the procedure contains any implicit returns from falling
4084 off the end of a statement sequence, then execution of that implicit
4085 return will cause Program_Error to be raised.
4086
4087 One use of this pragma is to identify procedures whose only purpose is to raise
4088 an exception. Another use of this pragma is to suppress incorrect warnings
4089 about missing returns in functions, where the last statement of a function
4090 statement sequence is a call to such a procedure.
4091
4092 Note that in Ada 2005 mode, this pragma is part of the language. It is
4093 available in all earlier versions of Ada as an implementation-defined
4094 pragma.
4095
4096 Pragma No_Strict_Aliasing
4097 =========================
4098
4099 Syntax:
4100
4101
4102 ::
4103
4104 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4105
4106
4107 ``type_LOCAL_NAME`` must refer to an access type
4108 declaration in the current declarative part. The effect is to inhibit
4109 strict aliasing optimization for the given type. The form with no
4110 arguments is a configuration pragma which applies to all access types
4111 declared in units to which the pragma applies. For a detailed
4112 description of the strict aliasing optimization, and the situations
4113 in which it must be suppressed, see the section on Optimization and Strict Aliasing
4114 in the :title:`GNAT User's Guide`.
4115
4116 This pragma currently has no effects on access to unconstrained array types.
4117
4118 .. _Pragma-No_Tagged_Streams:
4119
4120 Pragma No_Tagged_Streams
4121 ========================
4122
4123 Syntax:
4124
4125
4126 ::
4127
4128 pragma No_Tagged_Streams [([Entity =>] tagged_type_LOCAL_NAME)];
4129
4130
4131 Normally when a tagged type is introduced using a full type declaration,
4132 part of the processing includes generating stream access routines to be
4133 used by stream attributes referencing the type (or one of its subtypes
4134 or derived types). This can involve the generation of significant amounts
4135 of code which is wasted space if stream routines are not needed for the
4136 type in question.
4137
4138 The ``No_Tagged_Streams`` pragma causes the generation of these stream
4139 routines to be skipped, and any attempt to use stream operations on
4140 types subject to this pragma will be statically rejected as illegal.
4141
4142 There are two forms of the pragma. The form with no arguments must appear
4143 in a declarative sequence or in the declarations of a package spec. This
4144 pragma affects all subsequent root tagged types declared in the declaration
4145 sequence, and specifies that no stream routines be generated. The form with
4146 an argument (for which there is also a corresponding aspect) specifies a
4147 single root tagged type for which stream routines are not to be generated.
4148
4149 Once the pragma has been given for a particular root tagged type, all subtypes
4150 and derived types of this type inherit the pragma automatically, so the effect
4151 applies to a complete hierarchy (this is necessary to deal with the class-wide
4152 dispatching versions of the stream routines).
4153
4154 When pragmas ``Discard_Names`` and ``No_Tagged_Streams`` are simultaneously
4155 applied to a tagged type its Expanded_Name and External_Tag are initialized
4156 with empty strings. This is useful to avoid exposing entity names at binary
4157 level but has a negative impact on the debuggability of tagged types.
4158
4159 Pragma Normalize_Scalars
4160 ========================
4161
4162 Syntax:
4163
4164
4165 .. code-block:: ada
4166
4167 pragma Normalize_Scalars;
4168
4169
4170 This is a language defined pragma which is fully implemented in GNAT. The
4171 effect is to cause all scalar objects that are not otherwise initialized
4172 to be initialized. The initial values are implementation dependent and
4173 are as follows:
4174
4175
4176
4177 *Standard.Character*
4178 Objects whose root type is Standard.Character are initialized to
4179 Character'Last unless the subtype range excludes NUL (in which case
4180 NUL is used). This choice will always generate an invalid value if
4181 one exists.
4182
4183
4184 *Standard.Wide_Character*
4185 Objects whose root type is Standard.Wide_Character are initialized to
4186 Wide_Character'Last unless the subtype range excludes NUL (in which case
4187 NUL is used). This choice will always generate an invalid value if
4188 one exists.
4189
4190
4191 *Standard.Wide_Wide_Character*
4192 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4193 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4194 which case NUL is used). This choice will always generate an invalid value if
4195 one exists.
4196
4197
4198 *Integer types*
4199 Objects of an integer type are treated differently depending on whether
4200 negative values are present in the subtype. If no negative values are
4201 present, then all one bits is used as the initial value except in the
4202 special case where zero is excluded from the subtype, in which case
4203 all zero bits are used. This choice will always generate an invalid
4204 value if one exists.
4205
4206 For subtypes with negative values present, the largest negative number
4207 is used, except in the unusual case where this largest negative number
4208 is in the subtype, and the largest positive number is not, in which case
4209 the largest positive value is used. This choice will always generate
4210 an invalid value if one exists.
4211
4212
4213 *Floating-Point Types*
4214 Objects of all floating-point types are initialized to all 1-bits. For
4215 standard IEEE format, this corresponds to a NaN (not a number) which is
4216 indeed an invalid value.
4217
4218
4219 *Fixed-Point Types*
4220 Objects of all fixed-point types are treated as described above for integers,
4221 with the rules applying to the underlying integer value used to represent
4222 the fixed-point value.
4223
4224
4225 *Modular types*
4226 Objects of a modular type are initialized to all one bits, except in
4227 the special case where zero is excluded from the subtype, in which
4228 case all zero bits are used. This choice will always generate an
4229 invalid value if one exists.
4230
4231
4232 *Enumeration types*
4233 Objects of an enumeration type are initialized to all one-bits, i.e., to
4234 the value ``2 ** typ'Size - 1`` unless the subtype excludes the literal
4235 whose Pos value is zero, in which case a code of zero is used. This choice
4236 will always generate an invalid value if one exists.
4237
4238 .. _Pragma_Obsolescent:
4239
4240 Pragma Obsolescent
4241 ==================
4242
4243 Syntax:
4244
4245
4246 ::
4247
4248 pragma Obsolescent;
4249
4250 pragma Obsolescent (
4251 [Message =>] static_string_EXPRESSION
4252 [,[Version =>] Ada_05]]);
4253
4254 pragma Obsolescent (
4255 [Entity =>] NAME
4256 [,[Message =>] static_string_EXPRESSION
4257 [,[Version =>] Ada_05]] );
4258
4259
4260 This pragma can occur immediately following a declaration of an entity,
4261 including the case of a record component. If no Entity argument is present,
4262 then this declaration is the one to which the pragma applies. If an Entity
4263 parameter is present, it must either match the name of the entity in this
4264 declaration, or alternatively, the pragma can immediately follow an enumeration
4265 type declaration, where the Entity argument names one of the enumeration
4266 literals.
4267
4268 This pragma is used to indicate that the named entity
4269 is considered obsolescent and should not be used. Typically this is
4270 used when an API must be modified by eventually removing or modifying
4271 existing subprograms or other entities. The pragma can be used at an
4272 intermediate stage when the entity is still present, but will be
4273 removed later.
4274
4275 The effect of this pragma is to output a warning message on a reference to
4276 an entity thus marked that the subprogram is obsolescent if the appropriate
4277 warning option in the compiler is activated. If the ``Message`` parameter is
4278 present, then a second warning message is given containing this text. In
4279 addition, a reference to the entity is considered to be a violation of pragma
4280 ``Restrictions (No_Obsolescent_Features)``.
4281
4282 This pragma can also be used as a program unit pragma for a package,
4283 in which case the entity name is the name of the package, and the
4284 pragma indicates that the entire package is considered
4285 obsolescent. In this case a client ``with``\ ing such a package
4286 violates the restriction, and the ``with`` clause is
4287 flagged with warnings if the warning option is set.
4288
4289 If the ``Version`` parameter is present (which must be exactly
4290 the identifier ``Ada_05``, no other argument is allowed), then the
4291 indication of obsolescence applies only when compiling in Ada 2005
4292 mode. This is primarily intended for dealing with the situations
4293 in the predefined library where subprograms or packages
4294 have become defined as obsolescent in Ada 2005
4295 (e.g., in ``Ada.Characters.Handling``), but may be used anywhere.
4296
4297 The following examples show typical uses of this pragma:
4298
4299
4300 .. code-block:: ada
4301
4302 package p is
4303 pragma Obsolescent (p, Message => "use pp instead of p");
4304 end p;
4305
4306 package q is
4307 procedure q2;
4308 pragma Obsolescent ("use q2new instead");
4309
4310 type R is new integer;
4311 pragma Obsolescent
4312 (Entity => R,
4313 Message => "use RR in Ada 2005",
4314 Version => Ada_05);
4315
4316 type M is record
4317 F1 : Integer;
4318 F2 : Integer;
4319 pragma Obsolescent;
4320 F3 : Integer;
4321 end record;
4322
4323 type E is (a, bc, 'd', quack);
4324 pragma Obsolescent (Entity => bc)
4325 pragma Obsolescent (Entity => 'd')
4326
4327 function "+"
4328 (a, b : character) return character;
4329 pragma Obsolescent (Entity => "+");
4330 end;
4331
4332
4333 Note that, as for all pragmas, if you use a pragma argument identifier,
4334 then all subsequent parameters must also use a pragma argument identifier.
4335 So if you specify ``Entity =>`` for the ``Entity`` argument, and a ``Message``
4336 argument is present, it must be preceded by ``Message =>``.
4337
4338 Pragma Optimize_Alignment
4339 =========================
4340 .. index:: Alignment, default settings
4341
4342 Syntax:
4343
4344
4345 .. code-block:: ada
4346
4347 pragma Optimize_Alignment (TIME | SPACE | OFF);
4348
4349
4350 This is a configuration pragma which affects the choice of default alignments
4351 for types and objects where no alignment is explicitly specified. There is a
4352 time/space trade-off in the selection of these values. Large alignments result
4353 in more efficient code, at the expense of larger data space, since sizes have
4354 to be increased to match these alignments. Smaller alignments save space, but
4355 the access code is slower. The normal choice of default alignments for types
4356 and individual alignment promotions for objects (which is what you get if you
4357 do not use this pragma, or if you use an argument of OFF), tries to balance
4358 these two requirements.
4359
4360 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4361 First any packed record is given an alignment of 1. Second, if a size is given
4362 for the type, then the alignment is chosen to avoid increasing this size. For
4363 example, consider:
4364
4365
4366 .. code-block:: ada
4367
4368 type R is record
4369 X : Integer;
4370 Y : Character;
4371 end record;
4372
4373 for R'Size use 5*8;
4374
4375
4376 In the default mode, this type gets an alignment of 4, so that access to the
4377 Integer field X are efficient. But this means that objects of the type end up
4378 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4379 allowed to be bigger than the size of the type, but it can waste space if for
4380 example fields of type R appear in an enclosing record. If the above type is
4381 compiled in ``Optimize_Alignment (Space)`` mode, the alignment is set to 1.
4382
4383 However, there is one case in which SPACE is ignored. If a variable length
4384 record (that is a discriminated record with a component which is an array
4385 whose length depends on a discriminant), has a pragma Pack, then it is not
4386 in general possible to set the alignment of such a record to one, so the
4387 pragma is ignored in this case (with a warning).
4388
4389 Specifying SPACE also disables alignment promotions for standalone objects,
4390 which occur when the compiler increases the alignment of a specific object
4391 without changing the alignment of its type.
4392
4393 Specifying SPACE also disables component reordering in unpacked record types,
4394 which can result in larger sizes in order to meet alignment requirements.
4395
4396 Specifying TIME causes larger default alignments to be chosen in the case of
4397 small types with sizes that are not a power of 2. For example, consider:
4398
4399
4400 .. code-block:: ada
4401
4402 type R is record
4403 A : Character;
4404 B : Character;
4405 C : Boolean;
4406 end record;
4407
4408 pragma Pack (R);
4409 for R'Size use 17;
4410
4411
4412 The default alignment for this record is normally 1, but if this type is
4413 compiled in ``Optimize_Alignment (Time)`` mode, then the alignment is set
4414 to 4, which wastes space for objects of the type, since they are now 4 bytes
4415 long, but results in more efficient access when the whole record is referenced.
4416
4417 As noted above, this is a configuration pragma, and there is a requirement
4418 that all units in a partition be compiled with a consistent setting of the
4419 optimization setting. This would normally be achieved by use of a configuration
4420 pragma file containing the appropriate setting. The exception to this rule is
4421 that units with an explicit configuration pragma in the same file as the source
4422 unit are excluded from the consistency check, as are all predefined units. The
4423 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4424 pragma appears at the start of the file.
4425
4426 Pragma Ordered
4427 ==============
4428
4429 Syntax:
4430
4431
4432 .. code-block:: ada
4433
4434 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4435
4436
4437 Most enumeration types are from a conceptual point of view unordered.
4438 For example, consider:
4439
4440
4441 .. code-block:: ada
4442
4443 type Color is (Red, Blue, Green, Yellow);
4444
4445
4446 By Ada semantics ``Blue > Red`` and ``Green > Blue``,
4447 but really these relations make no sense; the enumeration type merely
4448 specifies a set of possible colors, and the order is unimportant.
4449
4450 For unordered enumeration types, it is generally a good idea if
4451 clients avoid comparisons (other than equality or inequality) and
4452 explicit ranges. (A *client* is a unit where the type is referenced,
4453 other than the unit where the type is declared, its body, and its subunits.)
4454 For example, if code buried in some client says:
4455
4456
4457 .. code-block:: ada
4458
4459 if Current_Color < Yellow then ...
4460 if Current_Color in Blue .. Green then ...
4461
4462
4463 then the client code is relying on the order, which is undesirable.
4464 It makes the code hard to read and creates maintenance difficulties if
4465 entries have to be added to the enumeration type. Instead,
4466 the code in the client should list the possibilities, or an
4467 appropriate subtype should be declared in the unit that declares
4468 the original enumeration type. E.g., the following subtype could
4469 be declared along with the type ``Color``:
4470
4471
4472 .. code-block:: ada
4473
4474 subtype RBG is Color range Red .. Green;
4475
4476
4477 and then the client could write:
4478
4479
4480 .. code-block:: ada
4481
4482 if Current_Color in RBG then ...
4483 if Current_Color = Blue or Current_Color = Green then ...
4484
4485
4486 However, some enumeration types are legitimately ordered from a conceptual
4487 point of view. For example, if you declare:
4488
4489
4490 .. code-block:: ada
4491
4492 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4493
4494
4495 then the ordering imposed by the language is reasonable, and
4496 clients can depend on it, writing for example:
4497
4498
4499 .. code-block:: ada
4500
4501 if D in Mon .. Fri then ...
4502 if D < Wed then ...
4503
4504
4505 The pragma *Ordered* is provided to mark enumeration types that
4506 are conceptually ordered, alerting the reader that clients may depend
4507 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4508 rather than one to mark them as unordered, since in our experience,
4509 the great majority of enumeration types are conceptually unordered.
4510
4511 The types ``Boolean``, ``Character``, ``Wide_Character``,
4512 and ``Wide_Wide_Character``
4513 are considered to be ordered types, so each is declared with a
4514 pragma ``Ordered`` in package ``Standard``.
4515
4516 Normally pragma ``Ordered`` serves only as documentation and a guide for
4517 coding standards, but GNAT provides a warning switch *-gnatw.u* that
4518 requests warnings for inappropriate uses (comparisons and explicit
4519 subranges) for unordered types. If this switch is used, then any
4520 enumeration type not marked with pragma ``Ordered`` will be considered
4521 as unordered, and will generate warnings for inappropriate uses.
4522
4523 Note that generic types are not considered ordered or unordered (since the
4524 template can be instantiated for both cases), so we never generate warnings
4525 for the case of generic enumerated types.
4526
4527 For additional information please refer to the description of the
4528 *-gnatw.u* switch in the GNAT User's Guide.
4529
4530 Pragma Overflow_Mode
4531 ====================
4532
4533 Syntax:
4534
4535
4536 ::
4537
4538 pragma Overflow_Mode
4539 ( [General =>] MODE
4540 [,[Assertions =>] MODE]);
4541
4542 MODE ::= STRICT | MINIMIZED | ELIMINATED
4543
4544
4545 This pragma sets the current overflow mode to the given setting. For details
4546 of the meaning of these modes, please refer to the
4547 'Overflow Check Handling in GNAT' appendix in the
4548 GNAT User's Guide. If only the ``General`` parameter is present,
4549 the given mode applies to all expressions. If both parameters are present,
4550 the ``General`` mode applies to expressions outside assertions, and
4551 the ``Eliminated`` mode applies to expressions within assertions.
4552
4553 The case of the ``MODE`` parameter is ignored,
4554 so ``MINIMIZED``, ``Minimized`` and
4555 ``minimized`` all have the same effect.
4556
4557 The ``Overflow_Mode`` pragma has the same scoping and placement
4558 rules as pragma ``Suppress``, so it can occur either as a
4559 configuration pragma, specifying a default for the whole
4560 program, or in a declarative scope, where it applies to the
4561 remaining declarations and statements in that scope.
4562
4563 The pragma ``Suppress (Overflow_Check)`` suppresses
4564 overflow checking, but does not affect the overflow mode.
4565
4566 The pragma ``Unsuppress (Overflow_Check)`` unsuppresses (enables)
4567 overflow checking, but does not affect the overflow mode.
4568
4569 Pragma Overriding_Renamings
4570 ===========================
4571 .. index:: Rational profile
4572
4573 .. index:: Rational compatibility
4574
4575 Syntax:
4576
4577
4578 .. code-block:: ada
4579
4580 pragma Overriding_Renamings;
4581
4582
4583 This is a GNAT configuration pragma to simplify porting
4584 legacy code accepted by the Rational
4585 Ada compiler. In the presence of this pragma, a renaming declaration that
4586 renames an inherited operation declared in the same scope is legal if selected
4587 notation is used as in:
4588
4589
4590 .. code-block:: ada
4591
4592 pragma Overriding_Renamings;
4593 ...
4594 package R is
4595 function F (..);
4596 ...
4597 function F (..) renames R.F;
4598 end R;
4599
4600
4601 even though
4602 RM 8.3 (15) stipulates that an overridden operation is not visible within the
4603 declaration of the overriding operation.
4604
4605 Pragma Partition_Elaboration_Policy
4606 ===================================
4607
4608 Syntax:
4609
4610
4611 ::
4612
4613 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4614
4615 POLICY_IDENTIFIER ::= Concurrent | Sequential
4616
4617
4618 This pragma is standard in Ada 2005, but is available in all earlier
4619 versions of Ada as an implementation-defined pragma.
4620 See Ada 2012 Reference Manual for details.
4621
4622 .. _Pragma-Part_Of:
4623
4624 Pragma Part_Of
4625 ==============
4626
4627 Syntax:
4628
4629 .. code-block:: ada
4630
4631 pragma Part_Of (ABSTRACT_STATE);
4632
4633 ABSTRACT_STATE ::= NAME
4634
4635 For the semantics of this pragma, see the entry for aspect ``Part_Of`` in the
4636 SPARK 2014 Reference Manual, section 7.2.6.
4637
4638 Pragma Passive
4639 ==============
4640
4641 Syntax:
4642
4643
4644 ::
4645
4646 pragma Passive [(Semaphore | No)];
4647
4648
4649 Syntax checked, but otherwise ignored by GNAT. This is recognized for
4650 compatibility with DEC Ada 83 implementations, where it is used within a
4651 task definition to request that a task be made passive. If the argument
4652 ``Semaphore`` is present, or the argument is omitted, then DEC Ada 83
4653 treats the pragma as an assertion that the containing task is passive
4654 and that optimization of context switch with this task is permitted and
4655 desired. If the argument ``No`` is present, the task must not be
4656 optimized. GNAT does not attempt to optimize any tasks in this manner
4657 (since protected objects are available in place of passive tasks).
4658
4659 For more information on the subject of passive tasks, see the section
4660 'Passive Task Optimization' in the GNAT Users Guide.
4661
4662 .. _Pragma-Persistent_BSS:
4663
4664 Pragma Persistent_BSS
4665 =====================
4666
4667 Syntax:
4668
4669
4670 ::
4671
4672 pragma Persistent_BSS [(LOCAL_NAME)]
4673
4674
4675 This pragma allows selected objects to be placed in the ``.persistent_bss``
4676 section. On some targets the linker and loader provide for special
4677 treatment of this section, allowing a program to be reloaded without
4678 affecting the contents of this data (hence the name persistent).
4679
4680 There are two forms of usage. If an argument is given, it must be the
4681 local name of a library-level object, with no explicit initialization
4682 and whose type is potentially persistent. If no argument is given, then
4683 the pragma is a configuration pragma, and applies to all library-level
4684 objects with no explicit initialization of potentially persistent types.
4685
4686 A potentially persistent type is a scalar type, or an untagged,
4687 non-discriminated record, all of whose components have no explicit
4688 initialization and are themselves of a potentially persistent type,
4689 or an array, all of whose constraints are static, and whose component
4690 type is potentially persistent.
4691
4692 If this pragma is used on a target where this feature is not supported,
4693 then the pragma will be ignored. See also ``pragma Linker_Section``.
4694
4695 Pragma Post
4696 ===========
4697 .. index:: Post
4698
4699 .. index:: Checks, postconditions
4700
4701
4702 Syntax:
4703
4704
4705 .. code-block:: ada
4706
4707 pragma Post (Boolean_Expression);
4708
4709
4710 The ``Post`` pragma is intended to be an exact replacement for
4711 the language-defined
4712 ``Post`` aspect, and shares its restrictions and semantics.
4713 It must appear either immediately following the corresponding
4714 subprogram declaration (only other pragmas may intervene), or
4715 if there is no separate subprogram declaration, then it can
4716 appear at the start of the declarations in a subprogram body
4717 (preceded only by other pragmas).
4718
4719 Pragma Postcondition
4720 ====================
4721 .. index:: Postcondition
4722
4723 .. index:: Checks, postconditions
4724
4725
4726 Syntax:
4727
4728
4729 ::
4730
4731 pragma Postcondition (
4732 [Check =>] Boolean_Expression
4733 [,[Message =>] String_Expression]);
4734
4735
4736 The ``Postcondition`` pragma allows specification of automatic
4737 postcondition checks for subprograms. These checks are similar to
4738 assertions, but are automatically inserted just prior to the return
4739 statements of the subprogram with which they are associated (including
4740 implicit returns at the end of procedure bodies and associated
4741 exception handlers).
4742
4743 In addition, the boolean expression which is the condition which
4744 must be true may contain references to function'Result in the case
4745 of a function to refer to the returned value.
4746
4747 ``Postcondition`` pragmas may appear either immediately following the
4748 (separate) declaration of a subprogram, or at the start of the
4749 declarations of a subprogram body. Only other pragmas may intervene
4750 (that is appear between the subprogram declaration and its
4751 postconditions, or appear before the postcondition in the
4752 declaration sequence in a subprogram body). In the case of a
4753 postcondition appearing after a subprogram declaration, the
4754 formal arguments of the subprogram are visible, and can be
4755 referenced in the postcondition expressions.
4756
4757 The postconditions are collected and automatically tested just
4758 before any return (implicit or explicit) in the subprogram body.
4759 A postcondition is only recognized if postconditions are active
4760 at the time the pragma is encountered. The compiler switch *gnata*
4761 turns on all postconditions by default, and pragma ``Check_Policy``
4762 with an identifier of ``Postcondition`` can also be used to
4763 control whether postconditions are active.
4764
4765 The general approach is that postconditions are placed in the spec
4766 if they represent functional aspects which make sense to the client.
4767 For example we might have:
4768
4769
4770 .. code-block:: ada
4771
4772 function Direction return Integer;
4773 pragma Postcondition
4774 (Direction'Result = +1
4775 or else
4776 Direction'Result = -1);
4777
4778
4779 which serves to document that the result must be +1 or -1, and
4780 will test that this is the case at run time if postcondition
4781 checking is active.
4782
4783 Postconditions within the subprogram body can be used to
4784 check that some internal aspect of the implementation,
4785 not visible to the client, is operating as expected.
4786 For instance if a square root routine keeps an internal
4787 counter of the number of times it is called, then we
4788 might have the following postcondition:
4789
4790
4791 .. code-block:: ada
4792
4793 Sqrt_Calls : Natural := 0;
4794
4795 function Sqrt (Arg : Float) return Float is
4796 pragma Postcondition
4797 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4798 ...
4799 end Sqrt
4800
4801
4802 As this example, shows, the use of the ``Old`` attribute
4803 is often useful in postconditions to refer to the state on
4804 entry to the subprogram.
4805
4806 Note that postconditions are only checked on normal returns
4807 from the subprogram. If an abnormal return results from
4808 raising an exception, then the postconditions are not checked.
4809
4810 If a postcondition fails, then the exception
4811 ``System.Assertions.Assert_Failure`` is raised. If
4812 a message argument was supplied, then the given string
4813 will be used as the exception message. If no message
4814 argument was supplied, then the default message has
4815 the form "Postcondition failed at file_name:line". The
4816 exception is raised in the context of the subprogram
4817 body, so it is possible to catch postcondition failures
4818 within the subprogram body itself.
4819
4820 Within a package spec, normal visibility rules
4821 in Ada would prevent forward references within a
4822 postcondition pragma to functions defined later in
4823 the same package. This would introduce undesirable
4824 ordering constraints. To avoid this problem, all
4825 postcondition pragmas are analyzed at the end of
4826 the package spec, allowing forward references.
4827
4828 The following example shows that this even allows
4829 mutually recursive postconditions as in:
4830
4831
4832 .. code-block:: ada
4833
4834 package Parity_Functions is
4835 function Odd (X : Natural) return Boolean;
4836 pragma Postcondition
4837 (Odd'Result =
4838 (x = 1
4839 or else
4840 (x /= 0 and then Even (X - 1))));
4841
4842 function Even (X : Natural) return Boolean;
4843 pragma Postcondition
4844 (Even'Result =
4845 (x = 0
4846 or else
4847 (x /= 1 and then Odd (X - 1))));
4848
4849 end Parity_Functions;
4850
4851
4852 There are no restrictions on the complexity or form of
4853 conditions used within ``Postcondition`` pragmas.
4854 The following example shows that it is even possible
4855 to verify performance behavior.
4856
4857
4858 .. code-block:: ada
4859
4860 package Sort is
4861
4862 Performance : constant Float;
4863 -- Performance constant set by implementation
4864 -- to match target architecture behavior.
4865
4866 procedure Treesort (Arg : String);
4867 -- Sorts characters of argument using N*logN sort
4868 pragma Postcondition
4869 (Float (Clock - Clock'Old) <=
4870 Float (Arg'Length) *
4871 log (Float (Arg'Length)) *
4872 Performance);
4873 end Sort;
4874
4875
4876 Note: postcondition pragmas associated with subprograms that are
4877 marked as Inline_Always, or those marked as Inline with front-end
4878 inlining (-gnatN option set) are accepted and legality-checked
4879 by the compiler, but are ignored at run-time even if postcondition
4880 checking is enabled.
4881
4882 Note that pragma ``Postcondition`` differs from the language-defined
4883 ``Post`` aspect (and corresponding ``Post`` pragma) in allowing
4884 multiple occurrences, allowing occurences in the body even if there
4885 is a separate spec, and allowing a second string parameter, and the
4886 use of the pragma identifier ``Check``. Historically, pragma
4887 ``Postcondition`` was implemented prior to the development of
4888 Ada 2012, and has been retained in its original form for
4889 compatibility purposes.
4890
4891 Pragma Post_Class
4892 =================
4893 .. index:: Post
4894
4895 .. index:: Checks, postconditions
4896
4897
4898 Syntax:
4899
4900
4901 .. code-block:: ada
4902
4903 pragma Post_Class (Boolean_Expression);
4904
4905
4906 The ``Post_Class`` pragma is intended to be an exact replacement for
4907 the language-defined
4908 ``Post'Class`` aspect, and shares its restrictions and semantics.
4909 It must appear either immediately following the corresponding
4910 subprogram declaration (only other pragmas may intervene), or
4911 if there is no separate subprogram declaration, then it can
4912 appear at the start of the declarations in a subprogram body
4913 (preceded only by other pragmas).
4914
4915 Note: This pragma is called ``Post_Class`` rather than
4916 ``Post'Class`` because the latter would not be strictly
4917 conforming to the allowed syntax for pragmas. The motivation
4918 for provinding pragmas equivalent to the aspects is to allow a program
4919 to be written using the pragmas, and then compiled if necessary
4920 using an Ada compiler that does not recognize the pragmas or
4921 aspects, but is prepared to ignore the pragmas. The assertion
4922 policy that controls this pragma is ``Post'Class``, not
4923 ``Post_Class``.
4924
4925 Pragma Pre
4926 ==========
4927 .. index:: Pre
4928
4929 .. index:: Checks, preconditions
4930
4931
4932 Syntax:
4933
4934
4935 .. code-block:: ada
4936
4937 pragma Pre (Boolean_Expression);
4938
4939
4940 The ``Pre`` pragma is intended to be an exact replacement for
4941 the language-defined
4942 ``Pre`` aspect, and shares its restrictions and semantics.
4943 It must appear either immediately following the corresponding
4944 subprogram declaration (only other pragmas may intervene), or
4945 if there is no separate subprogram declaration, then it can
4946 appear at the start of the declarations in a subprogram body
4947 (preceded only by other pragmas).
4948
4949 Pragma Precondition
4950 ===================
4951 .. index:: Preconditions
4952
4953 .. index:: Checks, preconditions
4954
4955
4956 Syntax:
4957
4958
4959 ::
4960
4961 pragma Precondition (
4962 [Check =>] Boolean_Expression
4963 [,[Message =>] String_Expression]);
4964
4965
4966 The ``Precondition`` pragma is similar to ``Postcondition``
4967 except that the corresponding checks take place immediately upon
4968 entry to the subprogram, and if a precondition fails, the exception
4969 is raised in the context of the caller, and the attribute 'Result
4970 cannot be used within the precondition expression.
4971
4972 Otherwise, the placement and visibility rules are identical to those
4973 described for postconditions. The following is an example of use
4974 within a package spec:
4975
4976
4977 .. code-block:: ada
4978
4979 package Math_Functions is
4980 ...
4981 function Sqrt (Arg : Float) return Float;
4982 pragma Precondition (Arg >= 0.0)
4983 ...
4984 end Math_Functions;
4985
4986
4987 ``Precondition`` pragmas may appear either immediately following the
4988 (separate) declaration of a subprogram, or at the start of the
4989 declarations of a subprogram body. Only other pragmas may intervene
4990 (that is appear between the subprogram declaration and its
4991 postconditions, or appear before the postcondition in the
4992 declaration sequence in a subprogram body).
4993
4994 Note: precondition pragmas associated with subprograms that are
4995 marked as Inline_Always, or those marked as Inline with front-end
4996 inlining (-gnatN option set) are accepted and legality-checked
4997 by the compiler, but are ignored at run-time even if precondition
4998 checking is enabled.
4999
5000 Note that pragma ``Precondition`` differs from the language-defined
5001 ``Pre`` aspect (and corresponding ``Pre`` pragma) in allowing
5002 multiple occurrences, allowing occurences in the body even if there
5003 is a separate spec, and allowing a second string parameter, and the
5004 use of the pragma identifier ``Check``. Historically, pragma
5005 ``Precondition`` was implemented prior to the development of
5006 Ada 2012, and has been retained in its original form for
5007 compatibility purposes.
5008
5009 .. _Pragma-Predicate:
5010
5011 Pragma Predicate
5012 ================
5013
5014 Syntax:
5015
5016
5017 ::
5018
5019 pragma Predicate
5020 ([Entity =>] type_LOCAL_NAME,
5021 [Check =>] EXPRESSION);
5022
5023
5024 This pragma (available in all versions of Ada in GNAT) encompasses both
5025 the ``Static_Predicate`` and ``Dynamic_Predicate`` aspects in
5026 Ada 2012. A predicate is regarded as static if it has an allowed form
5027 for ``Static_Predicate`` and is otherwise treated as a
5028 ``Dynamic_Predicate``. Otherwise, predicates specified by this
5029 pragma behave exactly as described in the Ada 2012 reference manual.
5030 For example, if we have
5031
5032
5033 .. code-block:: ada
5034
5035 type R is range 1 .. 10;
5036 subtype S is R;
5037 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5038 subtype Q is R
5039 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5040
5041
5042 the effect is identical to the following Ada 2012 code:
5043
5044
5045 .. code-block:: ada
5046
5047 type R is range 1 .. 10;
5048 subtype S is R with
5049 Static_Predicate => S not in 4 .. 6;
5050 subtype Q is R with
5051 Dynamic_Predicate => F(Q) or G(Q);
5052
5053
5054 Note that there are no pragmas ``Dynamic_Predicate``
5055 or ``Static_Predicate``. That is
5056 because these pragmas would affect legality and semantics of
5057 the program and thus do not have a neutral effect if ignored.
5058 The motivation behind providing pragmas equivalent to
5059 corresponding aspects is to allow a program to be written
5060 using the pragmas, and then compiled with a compiler that
5061 will ignore the pragmas. That doesn't work in the case of
5062 static and dynamic predicates, since if the corresponding
5063 pragmas are ignored, then the behavior of the program is
5064 fundamentally changed (for example a membership test
5065 ``A in B`` would not take into account a predicate
5066 defined for subtype B). When following this approach, the
5067 use of predicates should be avoided.
5068
5069 Pragma Predicate_Failure
5070 ========================
5071
5072 Syntax:
5073
5074
5075 ::
5076
5077 pragma Predicate_Failure
5078 ([Entity =>] type_LOCAL_NAME,
5079 [Message =>] String_Expression);
5080
5081
5082 The ``Predicate_Failure`` pragma is intended to be an exact replacement for
5083 the language-defined
5084 ``Predicate_Failure`` aspect, and shares its restrictions and semantics.
5085
5086 Pragma Preelaborable_Initialization
5087 ===================================
5088
5089 Syntax:
5090
5091
5092 .. code-block:: ada
5093
5094 pragma Preelaborable_Initialization (DIRECT_NAME);
5095
5096
5097 This pragma is standard in Ada 2005, but is available in all earlier
5098 versions of Ada as an implementation-defined pragma.
5099 See Ada 2012 Reference Manual for details.
5100
5101 Pragma Prefix_Exception_Messages
5102 ================================
5103 .. index:: Prefix_Exception_Messages
5104
5105 .. index:: exception
5106
5107 .. index:: Exception_Message
5108
5109
5110 Syntax:
5111
5112
5113 .. code-block:: ada
5114
5115 pragma Prefix_Exception_Messages;
5116
5117
5118 This is an implementation-defined configuration pragma that affects the
5119 behavior of raise statements with a message given as a static string
5120 constant (typically a string literal). In such cases, the string will
5121 be automatically prefixed by the name of the enclosing entity (giving
5122 the package and subprogram containing the raise statement). This helps
5123 to identify where messages are coming from, and this mode is automatic
5124 for the run-time library.
5125
5126 The pragma has no effect if the message is computed with an expression other
5127 than a static string constant, since the assumption in this case is that
5128 the program computes exactly the string it wants. If you still want the
5129 prefixing in this case, you can always call
5130 ``GNAT.Source_Info.Enclosing_Entity`` and prepend the string manually.
5131
5132 Pragma Pre_Class
5133 ================
5134 .. index:: Pre_Class
5135
5136 .. index:: Checks, preconditions
5137
5138
5139 Syntax:
5140
5141
5142 .. code-block:: ada
5143
5144 pragma Pre_Class (Boolean_Expression);
5145
5146
5147 The ``Pre_Class`` pragma is intended to be an exact replacement for
5148 the language-defined
5149 ``Pre'Class`` aspect, and shares its restrictions and semantics.
5150 It must appear either immediately following the corresponding
5151 subprogram declaration (only other pragmas may intervene), or
5152 if there is no separate subprogram declaration, then it can
5153 appear at the start of the declarations in a subprogram body
5154 (preceded only by other pragmas).
5155
5156 Note: This pragma is called ``Pre_Class`` rather than
5157 ``Pre'Class`` because the latter would not be strictly
5158 conforming to the allowed syntax for pragmas. The motivation
5159 for providing pragmas equivalent to the aspects is to allow a program
5160 to be written using the pragmas, and then compiled if necessary
5161 using an Ada compiler that does not recognize the pragmas or
5162 aspects, but is prepared to ignore the pragmas. The assertion
5163 policy that controls this pragma is ``Pre'Class``, not
5164 ``Pre_Class``.
5165
5166 Pragma Priority_Specific_Dispatching
5167 ====================================
5168
5169 Syntax:
5170
5171
5172 ::
5173
5174 pragma Priority_Specific_Dispatching (
5175 POLICY_IDENTIFIER,
5176 first_priority_EXPRESSION,
5177 last_priority_EXPRESSION)
5178
5179 POLICY_IDENTIFIER ::=
5180 EDF_Across_Priorities |
5181 FIFO_Within_Priorities |
5182 Non_Preemptive_Within_Priorities |
5183 Round_Robin_Within_Priorities
5184
5185
5186 This pragma is standard in Ada 2005, but is available in all earlier
5187 versions of Ada as an implementation-defined pragma.
5188 See Ada 2012 Reference Manual for details.
5189
5190 Pragma Profile
5191 ==============
5192
5193 Syntax:
5194
5195
5196 .. code-block:: ada
5197
5198 pragma Profile (Ravenscar | Restricted | Rational | Jorvik |
5199 GNAT_Extended_Ravenscar | GNAT_Ravenscar_EDF );
5200
5201
5202 This pragma is standard in Ada 2005, but is available in all earlier
5203 versions of Ada as an implementation-defined pragma. This is a
5204 configuration pragma that establishes a set of configuration pragmas
5205 that depend on the argument. ``Ravenscar`` is standard in Ada 2005.
5206 ``Jorvik`` is standard in Ada 202x.
5207 The other possibilities (``Restricted``, ``Rational``,
5208 ``GNAT_Extended_Ravenscar``, ``GNAT_Ravenscar_EDF``)
5209 are implementation-defined. ``GNAT_Extended_Ravenscar`` is an alias for ``Jorvik``.
5210
5211 The set of configuration pragmas is defined in the following sections.
5212
5213
5214 * Pragma Profile (Ravenscar)
5215
5216 The ``Ravenscar`` profile is standard in Ada 2005,
5217 but is available in all earlier
5218 versions of Ada as an implementation-defined pragma. This profile
5219 establishes the following set of configuration pragmas:
5220
5221 * ``Task_Dispatching_Policy (FIFO_Within_Priorities)``
5222
5223 [RM D.2.2] Tasks are dispatched following a preemptive
5224 priority-ordered scheduling policy.
5225
5226
5227 * ``Locking_Policy (Ceiling_Locking)``
5228
5229 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5230 the ceiling priority of the corresponding protected object.
5231
5232
5233 * ``Detect_Blocking``
5234
5235 This pragma forces the detection of potentially blocking operations within a
5236 protected operation, and to raise Program_Error if that happens.
5237
5238 plus the following set of restrictions:
5239
5240 * ``Max_Entry_Queue_Length => 1``
5241
5242 No task can be queued on a protected entry.
5243
5244 * ``Max_Protected_Entries => 1``
5245
5246 * ``Max_Task_Entries => 0``
5247
5248 No rendezvous statements are allowed.
5249
5250 * ``No_Abort_Statements``
5251
5252 * ``No_Dynamic_Attachment``
5253
5254 * ``No_Dynamic_Priorities``
5255
5256 * ``No_Implicit_Heap_Allocations``
5257
5258 * ``No_Local_Protected_Objects``
5259
5260 * ``No_Local_Timing_Events``
5261
5262 * ``No_Protected_Type_Allocators``
5263
5264 * ``No_Relative_Delay``
5265
5266 * ``No_Requeue_Statements``
5267
5268 * ``No_Select_Statements``
5269
5270 * ``No_Specific_Termination_Handlers``
5271
5272 * ``No_Task_Allocators``
5273
5274 * ``No_Task_Hierarchy``
5275
5276 * ``No_Task_Termination``
5277
5278 * ``Simple_Barriers``
5279
5280 The Ravenscar profile also includes the following restrictions that specify
5281 that there are no semantic dependencies on the corresponding predefined
5282 packages:
5283
5284 * ``No_Dependence => Ada.Asynchronous_Task_Control``
5285
5286 * ``No_Dependence => Ada.Calendar``
5287
5288 * ``No_Dependence => Ada.Execution_Time.Group_Budget``
5289
5290 * ``No_Dependence => Ada.Execution_Time.Timers``
5291
5292 * ``No_Dependence => Ada.Task_Attributes``
5293
5294 * ``No_Dependence => System.Multiprocessors.Dispatching_Domains``
5295
5296 This set of configuration pragmas and restrictions correspond to the
5297 definition of the 'Ravenscar Profile' for limited tasking, devised and
5298 published by the :title:`International Real-Time Ada Workshop, 1997`.
5299 A description is also available at
5300 `http://www-users.cs.york.ac.uk/~burns/ravenscar.ps <http://www-users.cs.york.ac.uk/~burns/ravenscar.ps>`_.
5301
5302 The original definition of the profile was revised at subsequent IRTAW
5303 meetings. It has been included in the ISO
5304 :title:`Guide for the Use of the Ada Programming Language in High Integrity Systems`,
5305 and was made part of the Ada 2005 standard.
5306 The formal definition given by
5307 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5308 AI-305) available at
5309 `http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt <http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt>`_ and
5310 `http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt <http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt>`_.
5311
5312 The above set is a superset of the restrictions provided by pragma
5313 ``Profile (Restricted)``, it includes six additional restrictions
5314 (``Simple_Barriers``, ``No_Select_Statements``,
5315 ``No_Calendar``, ``No_Implicit_Heap_Allocations``,
5316 ``No_Relative_Delay`` and ``No_Task_Termination``). This means
5317 that pragma ``Profile (Ravenscar)``, like the pragma
5318 ``Profile (Restricted)``,
5319 automatically causes the use of a simplified,
5320 more efficient version of the tasking run-time library.
5321
5322 * Pragma Profile (Jorvik)
5323
5324 ``Jorvik`` is the new profile added to the Ada 202x draft standard,
5325 previously implemented under the name ``GNAT_Extended_Ravenscar``.
5326
5327 The ``No_Implicit_Heap_Allocations`` restriction has been replaced
5328 by ``No_Implicit_Task_Allocations`` and
5329 ``No_Implicit_Protected_Object_Allocations``.
5330
5331 The ``Simple_Barriers`` restriction has been replaced by
5332 ``Pure_Barriers``.
5333
5334 The ``Max_Protected_Entries``, ``Max_Entry_Queue_Length``, and
5335 ``No_Relative_Delay`` restrictions have been removed.
5336
5337 Details on the rationale for ``Jorvik`` and implications for use may be
5338 found in :title:`A New Ravenscar-Based Profile` by P. Rogers, J. Ruiz,
5339 T. Gingold and P. Bernardi, in :title:`Reliable Software Technologies --
5340 Ada Europe 2017`, Springer-Verlag Lecture Notes in Computer Science,
5341 Number 10300.
5342
5343
5344 * Pragma Profile (GNAT_Ravenscar_EDF)
5345
5346 This profile corresponds to the Ravenscar profile but using
5347 EDF_Across_Priority as the Task_Scheduling_Policy.
5348
5349 * Pragma Profile (Restricted)
5350
5351 This profile corresponds to the GNAT restricted run time. It
5352 establishes the following set of restrictions:
5353
5354 * ``No_Abort_Statements``
5355 * ``No_Entry_Queue``
5356 * ``No_Task_Hierarchy``
5357 * ``No_Task_Allocators``
5358 * ``No_Dynamic_Priorities``
5359 * ``No_Terminate_Alternatives``
5360 * ``No_Dynamic_Attachment``
5361 * ``No_Protected_Type_Allocators``
5362 * ``No_Local_Protected_Objects``
5363 * ``No_Requeue_Statements``
5364 * ``No_Task_Attributes_Package``
5365 * ``Max_Asynchronous_Select_Nesting = 0``
5366 * ``Max_Task_Entries = 0``
5367 * ``Max_Protected_Entries = 1``
5368 * ``Max_Select_Alternatives = 0``
5369
5370 This set of restrictions causes the automatic selection of a simplified
5371 version of the run time that provides improved performance for the
5372 limited set of tasking functionality permitted by this set of restrictions.
5373
5374 * Pragma Profile (Rational)
5375
5376 The Rational profile is intended to facilitate porting legacy code that
5377 compiles with the Rational APEX compiler, even when the code includes non-
5378 conforming Ada constructs. The profile enables the following three pragmas:
5379
5380 * ``pragma Implicit_Packing``
5381 * ``pragma Overriding_Renamings``
5382 * ``pragma Use_VADS_Size``
5383
5384
5385 Pragma Profile_Warnings
5386 =======================
5387
5388 Syntax:
5389
5390
5391 .. code-block:: ada
5392
5393 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5394
5395
5396 This is an implementation-defined pragma that is similar in
5397 effect to ``pragma Profile`` except that instead of
5398 generating ``Restrictions`` pragmas, it generates
5399 ``Restriction_Warnings`` pragmas. The result is that
5400 violations of the profile generate warning messages instead
5401 of error messages.
5402
5403 Pragma Propagate_Exceptions
5404 ===========================
5405 .. index:: Interfacing to C++
5406
5407
5408 Syntax:
5409
5410
5411 .. code-block:: ada
5412
5413 pragma Propagate_Exceptions;
5414
5415
5416 This pragma is now obsolete and, other than generating a warning if warnings
5417 on obsolescent features are enabled, is ignored.
5418 It is retained for compatibility
5419 purposes. It used to be used in connection with optimization of
5420 a now-obsolete mechanism for implementation of exceptions.
5421
5422 Pragma Provide_Shift_Operators
5423 ==============================
5424 .. index:: Shift operators
5425
5426
5427 Syntax:
5428
5429
5430 .. code-block:: ada
5431
5432 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
5433
5434
5435 This pragma can be applied to a first subtype local name that specifies
5436 either an unsigned or signed type. It has the effect of providing the
5437 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
5438 Rotate_Left and Rotate_Right) for the given type. It is similar to
5439 including the function declarations for these five operators, together
5440 with the pragma Import (Intrinsic, ...) statements.
5441
5442 Pragma Psect_Object
5443 ===================
5444
5445 Syntax:
5446
5447
5448 ::
5449
5450 pragma Psect_Object (
5451 [Internal =>] LOCAL_NAME,
5452 [, [External =>] EXTERNAL_SYMBOL]
5453 [, [Size =>] EXTERNAL_SYMBOL]);
5454
5455 EXTERNAL_SYMBOL ::=
5456 IDENTIFIER
5457 | static_string_EXPRESSION
5458
5459
5460 This pragma is identical in effect to pragma ``Common_Object``.
5461
5462 .. _Pragma-Pure_Function:
5463
5464 Pragma Pure_Function
5465 ====================
5466
5467 Syntax:
5468
5469
5470 ::
5471
5472 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5473
5474
5475 This pragma appears in the same declarative part as a function
5476 declaration (or a set of function declarations if more than one
5477 overloaded declaration exists, in which case the pragma applies
5478 to all entities). It specifies that the function ``Entity`` is
5479 to be considered pure for the purposes of code generation. This means
5480 that the compiler can assume that there are no side effects, and
5481 in particular that two calls with identical arguments produce the
5482 same result. It also means that the function can be used in an
5483 address clause.
5484
5485 Note that, quite deliberately, there are no static checks to try
5486 to ensure that this promise is met, so ``Pure_Function`` can be used
5487 with functions that are conceptually pure, even if they do modify
5488 global variables. For example, a square root function that is
5489 instrumented to count the number of times it is called is still
5490 conceptually pure, and can still be optimized, even though it
5491 modifies a global variable (the count). Memo functions are another
5492 example (where a table of previous calls is kept and consulted to
5493 avoid re-computation).
5494
5495 Note also that the normal rules excluding optimization of subprograms
5496 in pure units (when parameter types are descended from System.Address,
5497 or when the full view of a parameter type is limited), do not apply
5498 for the Pure_Function case. If you explicitly specify Pure_Function,
5499 the compiler may optimize away calls with identical arguments, and
5500 if that results in unexpected behavior, the proper action is not to
5501 use the pragma for subprograms that are not (conceptually) pure.
5502
5503 Note: Most functions in a ``Pure`` package are automatically pure, and
5504 there is no need to use pragma ``Pure_Function`` for such functions. One
5505 exception is any function that has at least one formal of type
5506 ``System.Address`` or a type derived from it. Such functions are not
5507 considered pure by default, since the compiler assumes that the
5508 ``Address`` parameter may be functioning as a pointer and that the
5509 referenced data may change even if the address value does not.
5510 Similarly, imported functions are not considered to be pure by default,
5511 since there is no way of checking that they are in fact pure. The use
5512 of pragma ``Pure_Function`` for such a function will override these default
5513 assumption, and cause the compiler to treat a designated subprogram as pure
5514 in these cases.
5515
5516 Note: If pragma ``Pure_Function`` is applied to a renamed function, it
5517 applies to the underlying renamed function. This can be used to
5518 disambiguate cases of overloading where some but not all functions
5519 in a set of overloaded functions are to be designated as pure.
5520
5521 If pragma ``Pure_Function`` is applied to a library-level function, the
5522 function is also considered pure from an optimization point of view, but the
5523 unit is not a Pure unit in the categorization sense. So for example, a function
5524 thus marked is free to ``with`` non-pure units.
5525
5526 Pragma Rational
5527 ===============
5528
5529 Syntax:
5530
5531
5532 .. code-block:: ada
5533
5534 pragma Rational;
5535
5536
5537 This pragma is considered obsolescent, but is retained for
5538 compatibility purposes. It is equivalent to:
5539
5540
5541 .. code-block:: ada
5542
5543 pragma Profile (Rational);
5544
5545
5546 Pragma Ravenscar
5547 ================
5548
5549 Syntax:
5550
5551
5552 .. code-block:: ada
5553
5554 pragma Ravenscar;
5555
5556
5557 This pragma is considered obsolescent, but is retained for
5558 compatibility purposes. It is equivalent to:
5559
5560
5561 .. code-block:: ada
5562
5563 pragma Profile (Ravenscar);
5564
5565
5566 which is the preferred method of setting the ``Ravenscar`` profile.
5567
5568 .. _Pragma-Refined_Depends:
5569
5570 Pragma Refined_Depends
5571 ======================
5572
5573 Syntax:
5574
5575 .. code-block:: ada
5576
5577 pragma Refined_Depends (DEPENDENCY_RELATION);
5578
5579 DEPENDENCY_RELATION ::=
5580 null
5581 | (DEPENDENCY_CLAUSE {, DEPENDENCY_CLAUSE})
5582
5583 DEPENDENCY_CLAUSE ::=
5584 OUTPUT_LIST =>[+] INPUT_LIST
5585 | NULL_DEPENDENCY_CLAUSE
5586
5587 NULL_DEPENDENCY_CLAUSE ::= null => INPUT_LIST
5588
5589 OUTPUT_LIST ::= OUTPUT | (OUTPUT {, OUTPUT})
5590
5591 INPUT_LIST ::= null | INPUT | (INPUT {, INPUT})
5592
5593 OUTPUT ::= NAME | FUNCTION_RESULT
5594 INPUT ::= NAME
5595
5596 where FUNCTION_RESULT is a function Result attribute_reference
5597
5598 For the semantics of this pragma, see the entry for aspect ``Refined_Depends`` in
5599 the SPARK 2014 Reference Manual, section 6.1.5.
5600
5601 .. _Pragma-Refined_Global:
5602
5603 Pragma Refined_Global
5604 =====================
5605
5606 Syntax:
5607
5608 .. code-block:: ada
5609
5610 pragma Refined_Global (GLOBAL_SPECIFICATION);
5611
5612 GLOBAL_SPECIFICATION ::=
5613 null
5614 | (GLOBAL_LIST)
5615 | (MODED_GLOBAL_LIST {, MODED_GLOBAL_LIST})
5616
5617 MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
5618
5619 MODE_SELECTOR ::= In_Out | Input | Output | Proof_In
5620 GLOBAL_LIST ::= GLOBAL_ITEM | (GLOBAL_ITEM {, GLOBAL_ITEM})
5621 GLOBAL_ITEM ::= NAME
5622
5623 For the semantics of this pragma, see the entry for aspect ``Refined_Global`` in
5624 the SPARK 2014 Reference Manual, section 6.1.4.
5625
5626 .. _Pragma-Refined_Post:
5627
5628 Pragma Refined_Post
5629 ===================
5630
5631 Syntax:
5632
5633 .. code-block:: ada
5634
5635 pragma Refined_Post (boolean_EXPRESSION);
5636
5637 For the semantics of this pragma, see the entry for aspect ``Refined_Post`` in
5638 the SPARK 2014 Reference Manual, section 7.2.7.
5639
5640 .. _Pragma-Refined_State:
5641
5642 Pragma Refined_State
5643 ====================
5644
5645 Syntax:
5646
5647 .. code-block:: ada
5648
5649 pragma Refined_State (REFINEMENT_LIST);
5650
5651 REFINEMENT_LIST ::=
5652 (REFINEMENT_CLAUSE {, REFINEMENT_CLAUSE})
5653
5654 REFINEMENT_CLAUSE ::= state_NAME => CONSTITUENT_LIST
5655
5656 CONSTITUENT_LIST ::=
5657 null
5658 | CONSTITUENT
5659 | (CONSTITUENT {, CONSTITUENT})
5660
5661 CONSTITUENT ::= object_NAME | state_NAME
5662
5663 For the semantics of this pragma, see the entry for aspect ``Refined_State`` in
5664 the SPARK 2014 Reference Manual, section 7.2.2.
5665
5666 Pragma Relative_Deadline
5667 ========================
5668
5669 Syntax:
5670
5671
5672 .. code-block:: ada
5673
5674 pragma Relative_Deadline (time_span_EXPRESSION);
5675
5676
5677 This pragma is standard in Ada 2005, but is available in all earlier
5678 versions of Ada as an implementation-defined pragma.
5679 See Ada 2012 Reference Manual for details.
5680
5681 .. _Pragma-Remote_Access_Type:
5682
5683 Pragma Remote_Access_Type
5684 =========================
5685
5686 Syntax:
5687
5688
5689 ::
5690
5691 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5692
5693
5694 This pragma appears in the formal part of a generic declaration.
5695 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5696 the use of a remote access to class-wide type as actual for a formal
5697 access type.
5698
5699 When this pragma applies to a formal access type ``Entity``, that
5700 type is treated as a remote access to class-wide type in the generic.
5701 It must be a formal general access type, and its designated type must
5702 be the class-wide type of a formal tagged limited private type from the
5703 same generic declaration.
5704
5705 In the generic unit, the formal type is subject to all restrictions
5706 pertaining to remote access to class-wide types. At instantiation, the
5707 actual type must be a remote access to class-wide type.
5708
5709 Pragma Rename_Pragma
5710 ============================
5711 .. index:: Pragmas, synonyms
5712
5713 Syntax:
5714
5715
5716 ::
5717
5718 pragma Rename_Pragma (
5719 [New_Name =>] IDENTIFIER,
5720 [Renamed =>] pragma_IDENTIFIER);
5721
5722 This pragma provides a mechanism for supplying new names for existing
5723 pragmas. The ``New_Name`` identifier can subsequently be used as a synonym for
5724 the Renamed pragma. For example, suppose you have code that was originally
5725 developed on a compiler that supports Inline_Only as an implementation defined
5726 pragma. And suppose the semantics of pragma Inline_Only are identical to (or at
5727 least very similar to) the GNAT implementation defined pragma
5728 Inline_Always. You could globally replace Inline_Only with Inline_Always.
5729
5730 However, to avoid that source modification, you could instead add a
5731 configuration pragma:
5732
5733 .. code-block:: ada
5734
5735 pragma Rename_Pragma (
5736 New_Name => Inline_Only,
5737 Renamed => Inline_Always);
5738
5739
5740 Then GNAT will treat "pragma Inline_Only ..." as if you had written
5741 "pragma Inline_Always ...".
5742
5743 Pragma Inline_Only will not necessarily mean the same thing as the other Ada
5744 compiler; it's up to you to make sure the semantics are close enough.
5745
5746 Pragma Restricted_Run_Time
5747 ==========================
5748
5749 Syntax:
5750
5751
5752 .. code-block:: ada
5753
5754 pragma Restricted_Run_Time;
5755
5756
5757 This pragma is considered obsolescent, but is retained for
5758 compatibility purposes. It is equivalent to:
5759
5760
5761 .. code-block:: ada
5762
5763 pragma Profile (Restricted);
5764
5765
5766 which is the preferred method of setting the restricted run time
5767 profile.
5768
5769 Pragma Restriction_Warnings
5770 ===========================
5771
5772 Syntax:
5773
5774
5775 ::
5776
5777 pragma Restriction_Warnings
5778 (restriction_IDENTIFIER {, restriction_IDENTIFIER});
5779
5780
5781 This pragma allows a series of restriction identifiers to be
5782 specified (the list of allowed identifiers is the same as for
5783 pragma ``Restrictions``). For each of these identifiers
5784 the compiler checks for violations of the restriction, but
5785 generates a warning message rather than an error message
5786 if the restriction is violated.
5787
5788 One use of this is in situations where you want to know
5789 about violations of a restriction, but you want to ignore some of
5790 these violations. Consider this example, where you want to set
5791 Ada_95 mode and enable style checks, but you want to know about
5792 any other use of implementation pragmas:
5793
5794
5795 .. code-block:: ada
5796
5797 pragma Restriction_Warnings (No_Implementation_Pragmas);
5798 pragma Warnings (Off, "violation of No_Implementation_Pragmas");
5799 pragma Ada_95;
5800 pragma Style_Checks ("2bfhkM160");
5801 pragma Warnings (On, "violation of No_Implementation_Pragmas");
5802
5803
5804 By including the above lines in a configuration pragmas file,
5805 the Ada_95 and Style_Checks pragmas are accepted without
5806 generating a warning, but any other use of implementation
5807 defined pragmas will cause a warning to be generated.
5808
5809 Pragma Reviewable
5810 =================
5811
5812 Syntax:
5813
5814
5815 .. code-block:: ada
5816
5817 pragma Reviewable;
5818
5819
5820 This pragma is an RM-defined standard pragma, but has no effect on the
5821 program being compiled, or on the code generated for the program.
5822
5823 To obtain the required output specified in RM H.3.1, the compiler must be
5824 run with various special switches as follows:
5825
5826 * *Where compiler-generated run-time checks remain*
5827
5828 The switch *-gnatGL*
5829 may be used to list the expanded code in pseudo-Ada form.
5830 Runtime checks show up in the listing either as explicit
5831 checks or operators marked with {} to indicate a check is present.
5832
5833
5834 * *An identification of known exceptions at compile time*
5835
5836 If the program is compiled with *-gnatwa*,
5837 the compiler warning messages will indicate all cases where the compiler
5838 detects that an exception is certain to occur at run time.
5839
5840
5841 * *Possible reads of uninitialized variables*
5842
5843 The compiler warns of many such cases, but its output is incomplete.
5844
5845 .. only:: PRO or GPL
5846
5847 The CodePeer analysis tool
5848 may be used to obtain a comprehensive list of all
5849 possible points at which uninitialized data may be read.
5850
5851 .. only:: FSF
5852
5853 A supplemental static analysis tool
5854 may be used to obtain a comprehensive list of all
5855 possible points at which uninitialized data may be read.
5856
5857
5858 * *Where run-time support routines are implicitly invoked*
5859
5860 In the output from *-gnatGL*,
5861 run-time calls are explicitly listed as calls to the relevant
5862 run-time routine.
5863
5864
5865 * *Object code listing*
5866
5867 This may be obtained either by using the *-S* switch,
5868 or the objdump utility.
5869
5870
5871 * *Constructs known to be erroneous at compile time*
5872
5873 These are identified by warnings issued by the compiler (use *-gnatwa*).
5874
5875
5876 * *Stack usage information*
5877
5878 Static stack usage data (maximum per-subprogram) can be obtained via the
5879 *-fstack-usage* switch to the compiler.
5880 Dynamic stack usage data (per task) can be obtained via the *-u* switch
5881 to gnatbind
5882
5883 .. only:: PRO or GPL
5884
5885 The gnatstack utility
5886 can be used to provide additional information on stack usage.
5887
5888
5889 * *Object code listing of entire partition*
5890
5891 This can be obtained by compiling the partition with *-S*,
5892 or by applying objdump
5893 to all the object files that are part of the partition.
5894
5895
5896 * *A description of the run-time model*
5897
5898 The full sources of the run-time are available, and the documentation of
5899 these routines describes how these run-time routines interface to the
5900 underlying operating system facilities.
5901
5902
5903 * *Control and data-flow information*
5904
5905 .. only:: PRO or GPL
5906
5907 The CodePeer tool
5908 may be used to obtain complete control and data-flow information, as well as
5909 comprehensive messages identifying possible problems based on this
5910 information.
5911
5912 .. only:: FSF
5913
5914 A supplemental static analysis tool
5915 may be used to obtain complete control and data-flow information, as well as
5916 comprehensive messages identifying possible problems based on this
5917 information.
5918
5919 .. _Pragma-Secondary_Stack_Size:
5920
5921 Pragma Secondary_Stack_Size
5922 ===========================
5923
5924 Syntax:
5925
5926 .. code-block:: ada
5927
5928 pragma Secondary_Stack_Size (integer_EXPRESSION);
5929
5930 This pragma appears within the task definition of a single task declaration
5931 or a task type declaration (like pragma ``Storage_Size``) and applies to all
5932 task objects of that type. The argument specifies the size of the secondary
5933 stack to be used by these task objects, and must be of an integer type. The
5934 secondary stack is used to handle functions that return a variable-sized
5935 result, for example a function returning an unconstrained String.
5936
5937 Note this pragma only applies to targets using fixed secondary stacks, like
5938 VxWorks 653 and bare board targets, where a fixed block for the
5939 secondary stack is allocated from the primary stack of the task. By default,
5940 these targets assign a percentage of the primary stack for the secondary stack,
5941 as defined by ``System.Parameter.Sec_Stack_Percentage``. With this pragma,
5942 an ``integer_EXPRESSION`` of bytes is assigned from the primary stack instead.
5943
5944 For most targets, the pragma does not apply as the secondary stack grows on
5945 demand: allocated as a chain of blocks in the heap. The default size of these
5946 blocks can be modified via the :switch:`-D` binder option as described in
5947 :title:`GNAT User's Guide`.
5948
5949 Note that no check is made to see if the secondary stack can fit inside the
5950 primary stack.
5951
5952 Note the pragma cannot appear when the restriction ``No_Secondary_Stack``
5953 is in effect.
5954
5955 Pragma Share_Generic
5956 ====================
5957
5958 Syntax:
5959
5960
5961 ::
5962
5963 pragma Share_Generic (GNAME {, GNAME});
5964
5965 GNAME ::= generic_unit_NAME | generic_instance_NAME
5966
5967
5968 This pragma is provided for compatibility with Dec Ada 83. It has
5969 no effect in GNAT (which does not implement shared generics), other
5970 than to check that the given names are all names of generic units or
5971 generic instances.
5972
5973 .. _Pragma-Shared:
5974
5975 Pragma Shared
5976 =============
5977
5978 This pragma is provided for compatibility with Ada 83. The syntax and
5979 semantics are identical to pragma Atomic.
5980
5981 Pragma Short_Circuit_And_Or
5982 ===========================
5983
5984 Syntax:
5985
5986
5987 .. code-block:: ada
5988
5989 pragma Short_Circuit_And_Or;
5990
5991
5992 This configuration pragma causes any occurrence of the AND operator applied to
5993 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5994 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5995 may be useful in the context of certification protocols requiring the use of
5996 short-circuited logical operators. If this configuration pragma occurs locally
5997 within the file being compiled, it applies only to the file being compiled.
5998 There is no requirement that all units in a partition use this option.
5999
6000 Pragma Short_Descriptors
6001 ========================
6002
6003 Syntax:
6004
6005
6006 .. code-block:: ada
6007
6008 pragma Short_Descriptors
6009
6010
6011 This pragma is provided for compatibility with other Ada implementations. It
6012 is recognized but ignored by all current versions of GNAT.
6013
6014 .. _Pragma-Simple_Storage_Pool_Type:
6015
6016 Pragma Simple_Storage_Pool_Type
6017 ===============================
6018 .. index:: Storage pool, simple
6019
6020 .. index:: Simple storage pool
6021
6022 Syntax:
6023
6024
6025 .. code-block:: ada
6026
6027 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6028
6029
6030 A type can be established as a 'simple storage pool type' by applying
6031 the representation pragma ``Simple_Storage_Pool_Type`` to the type.
6032 A type named in the pragma must be a library-level immutably limited record
6033 type or limited tagged type declared immediately within a package declaration.
6034 The type can also be a limited private type whose full type is allowed as
6035 a simple storage pool type.
6036
6037 For a simple storage pool type ``SSP``, nonabstract primitive subprograms
6038 ``Allocate``, ``Deallocate``, and ``Storage_Size`` can be declared that
6039 are subtype conformant with the following subprogram declarations:
6040
6041
6042 .. code-block:: ada
6043
6044 procedure Allocate
6045 (Pool : in out SSP;
6046 Storage_Address : out System.Address;
6047 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6048 Alignment : System.Storage_Elements.Storage_Count);
6049
6050 procedure Deallocate
6051 (Pool : in out SSP;
6052 Storage_Address : System.Address;
6053 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6054 Alignment : System.Storage_Elements.Storage_Count);
6055
6056 function Storage_Size (Pool : SSP)
6057 return System.Storage_Elements.Storage_Count;
6058
6059
6060 Procedure ``Allocate`` must be declared, whereas ``Deallocate`` and
6061 ``Storage_Size`` are optional. If ``Deallocate`` is not declared, then
6062 applying an unchecked deallocation has no effect other than to set its actual
6063 parameter to null. If ``Storage_Size`` is not declared, then the
6064 ``Storage_Size`` attribute applied to an access type associated with
6065 a pool object of type SSP returns zero. Additional operations can be declared
6066 for a simple storage pool type (such as for supporting a mark/release
6067 storage-management discipline).
6068
6069 An object of a simple storage pool type can be associated with an access
6070 type by specifying the attribute
6071 :ref:`Simple_Storage_Pool <Attribute_Simple_Storage_Pool>`. For example:
6072
6073
6074 .. code-block:: ada
6075
6076 My_Pool : My_Simple_Storage_Pool_Type;
6077
6078 type Acc is access My_Data_Type;
6079
6080 for Acc'Simple_Storage_Pool use My_Pool;
6081
6082
6083
6084 See attribute :ref:`Simple_Storage_Pool <Attribute_Simple_Storage_Pool>`
6085 for further details.
6086
6087 .. _Pragma_Source_File_Name:
6088
6089 Pragma Source_File_Name
6090 =======================
6091
6092 Syntax:
6093
6094
6095 ::
6096
6097 pragma Source_File_Name (
6098 [Unit_Name =>] unit_NAME,
6099 Spec_File_Name => STRING_LITERAL,
6100 [Index => INTEGER_LITERAL]);
6101
6102 pragma Source_File_Name (
6103 [Unit_Name =>] unit_NAME,
6104 Body_File_Name => STRING_LITERAL,
6105 [Index => INTEGER_LITERAL]);
6106
6107
6108 Use this to override the normal naming convention. It is a configuration
6109 pragma, and so has the usual applicability of configuration pragmas
6110 (i.e., it applies to either an entire partition, or to all units in a
6111 compilation, or to a single unit, depending on how it is used.
6112 ``unit_name`` is mapped to ``file_name_literal``. The identifier for
6113 the second argument is required, and indicates whether this is the file
6114 name for the spec or for the body.
6115
6116 The optional Index argument should be used when a file contains multiple
6117 units, and when you do not want to use ``gnatchop`` to separate then
6118 into multiple files (which is the recommended procedure to limit the
6119 number of recompilations that are needed when some sources change).
6120 For instance, if the source file :file:`source.ada` contains
6121
6122
6123 .. code-block:: ada
6124
6125 package B is
6126 ...
6127 end B;
6128
6129 with B;
6130 procedure A is
6131 begin
6132 ..
6133 end A;
6134
6135
6136 you could use the following configuration pragmas:
6137
6138
6139 .. code-block:: ada
6140
6141 pragma Source_File_Name
6142 (B, Spec_File_Name => "source.ada", Index => 1);
6143 pragma Source_File_Name
6144 (A, Body_File_Name => "source.ada", Index => 2);
6145
6146
6147 Note that the ``gnatname`` utility can also be used to generate those
6148 configuration pragmas.
6149
6150 Another form of the ``Source_File_Name`` pragma allows
6151 the specification of patterns defining alternative file naming schemes
6152 to apply to all files.
6153
6154
6155 ::
6156
6157 pragma Source_File_Name
6158 ( [Spec_File_Name =>] STRING_LITERAL
6159 [,[Casing =>] CASING_SPEC]
6160 [,[Dot_Replacement =>] STRING_LITERAL]);
6161
6162 pragma Source_File_Name
6163 ( [Body_File_Name =>] STRING_LITERAL
6164 [,[Casing =>] CASING_SPEC]
6165 [,[Dot_Replacement =>] STRING_LITERAL]);
6166
6167 pragma Source_File_Name
6168 ( [Subunit_File_Name =>] STRING_LITERAL
6169 [,[Casing =>] CASING_SPEC]
6170 [,[Dot_Replacement =>] STRING_LITERAL]);
6171
6172 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6173
6174
6175 The first argument is a pattern that contains a single asterisk indicating
6176 the point at which the unit name is to be inserted in the pattern string
6177 to form the file name. The second argument is optional. If present it
6178 specifies the casing of the unit name in the resulting file name string.
6179 The default is lower case. Finally the third argument allows for systematic
6180 replacement of any dots in the unit name by the specified string literal.
6181
6182 Note that Source_File_Name pragmas should not be used if you are using
6183 project files. The reason for this rule is that the project manager is not
6184 aware of these pragmas, and so other tools that use the projet file would not
6185 be aware of the intended naming conventions. If you are using project files,
6186 file naming is controlled by Source_File_Name_Project pragmas, which are
6187 usually supplied automatically by the project manager. A pragma
6188 Source_File_Name cannot appear after a :ref:`Pragma_Source_File_Name_Project`.
6189
6190 For more details on the use of the ``Source_File_Name`` pragma, see the
6191 sections on `Using Other File Names` and `Alternative File Naming Schemes`
6192 in the :title:`GNAT User's Guide`.
6193
6194 .. _Pragma_Source_File_Name_Project:
6195
6196 Pragma Source_File_Name_Project
6197 ===============================
6198
6199 This pragma has the same syntax and semantics as pragma Source_File_Name.
6200 It is only allowed as a stand-alone configuration pragma.
6201 It cannot appear after a :ref:`Pragma_Source_File_Name`, and
6202 most importantly, once pragma Source_File_Name_Project appears,
6203 no further Source_File_Name pragmas are allowed.
6204
6205 The intention is that Source_File_Name_Project pragmas are always
6206 generated by the Project Manager in a manner consistent with the naming
6207 specified in a project file, and when naming is controlled in this manner,
6208 it is not permissible to attempt to modify this naming scheme using
6209 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6210 known to the project manager).
6211
6212 Pragma Source_Reference
6213 =======================
6214
6215 Syntax:
6216
6217
6218 .. code-block:: ada
6219
6220 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6221
6222
6223 This pragma must appear as the first line of a source file.
6224 ``integer_literal`` is the logical line number of the line following
6225 the pragma line (for use in error messages and debugging
6226 information). ``string_literal`` is a static string constant that
6227 specifies the file name to be used in error messages and debugging
6228 information. This is most notably used for the output of ``gnatchop``
6229 with the *-r* switch, to make sure that the original unchopped
6230 source file is the one referred to.
6231
6232 The second argument must be a string literal, it cannot be a static
6233 string expression other than a string literal. This is because its value
6234 is needed for error messages issued by all phases of the compiler.
6235
6236 .. _Pragma-SPARK_Mode:
6237
6238 Pragma SPARK_Mode
6239 =================
6240
6241 Syntax:
6242
6243
6244 ::
6245
6246 pragma SPARK_Mode [(On | Off)] ;
6247
6248
6249 In general a program can have some parts that are in SPARK 2014 (and
6250 follow all the rules in the SPARK Reference Manual), and some parts
6251 that are full Ada 2012.
6252
6253 The SPARK_Mode pragma is used to identify which parts are in SPARK
6254 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
6255 be used in the following places:
6256
6257
6258 *
6259 As a configuration pragma, in which case it sets the default mode for
6260 all units compiled with this pragma.
6261
6262 *
6263 Immediately following a library-level subprogram spec
6264
6265 *
6266 Immediately within a library-level package body
6267
6268 *
6269 Immediately following the ``private`` keyword of a library-level
6270 package spec
6271
6272 *
6273 Immediately following the ``begin`` keyword of a library-level
6274 package body
6275
6276 *
6277 Immediately within a library-level subprogram body
6278
6279
6280 Normally a subprogram or package spec/body inherits the current mode
6281 that is active at the point it is declared. But this can be overridden
6282 by pragma within the spec or body as above.
6283
6284 The basic consistency rule is that you can't turn SPARK_Mode back
6285 ``On``, once you have explicitly (with a pragma) turned if
6286 ``Off``. So the following rules apply:
6287
6288 If a subprogram spec has SPARK_Mode ``Off``, then the body must
6289 also have SPARK_Mode ``Off``.
6290
6291 For a package, we have four parts:
6292
6293 *
6294 the package public declarations
6295 *
6296 the package private part
6297 *
6298 the body of the package
6299 *
6300 the elaboration code after ``begin``
6301
6302 For a package, the rule is that if you explicitly turn SPARK_Mode
6303 ``Off`` for any part, then all the following parts must have
6304 SPARK_Mode ``Off``. Note that this may require repeating a pragma
6305 SPARK_Mode (``Off``) in the body. For example, if we have a
6306 configuration pragma SPARK_Mode (``On``) that turns the mode on by
6307 default everywhere, and one particular package spec has pragma
6308 SPARK_Mode (``Off``), then that pragma will need to be repeated in
6309 the package body.
6310
6311 Pragma Static_Elaboration_Desired
6312 =================================
6313
6314 Syntax:
6315
6316
6317 .. code-block:: ada
6318
6319 pragma Static_Elaboration_Desired;
6320
6321
6322 This pragma is used to indicate that the compiler should attempt to initialize
6323 statically the objects declared in the library unit to which the pragma applies,
6324 when these objects are initialized (explicitly or implicitly) by an aggregate.
6325 In the absence of this pragma, aggregates in object declarations are expanded
6326 into assignments and loops, even when the aggregate components are static
6327 constants. When the aggregate is present the compiler builds a static expression
6328 that requires no run-time code, so that the initialized object can be placed in
6329 read-only data space. If the components are not static, or the aggregate has
6330 more that 100 components, the compiler emits a warning that the pragma cannot
6331 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6332 construction of larger aggregates with static components that include an others
6333 choice.)
6334
6335 Pragma Stream_Convert
6336 =====================
6337
6338 Syntax:
6339
6340
6341 ::
6342
6343 pragma Stream_Convert (
6344 [Entity =>] type_LOCAL_NAME,
6345 [Read =>] function_NAME,
6346 [Write =>] function_NAME);
6347
6348
6349 This pragma provides an efficient way of providing user-defined stream
6350 attributes. Not only is it simpler to use than specifying the attributes
6351 directly, but more importantly, it allows the specification to be made in such
6352 a way that the predefined unit Ada.Streams is not loaded unless it is actually
6353 needed (i.e. unless the stream attributes are actually used); the use of
6354 the Stream_Convert pragma adds no overhead at all, unless the stream
6355 attributes are actually used on the designated type.
6356
6357 The first argument specifies the type for which stream functions are
6358 provided. The second parameter provides a function used to read values
6359 of this type. It must name a function whose argument type may be any
6360 subtype, and whose returned type must be the type given as the first
6361 argument to the pragma.
6362
6363 The meaning of the ``Read`` parameter is that if a stream attribute directly
6364 or indirectly specifies reading of the type given as the first parameter,
6365 then a value of the type given as the argument to the Read function is
6366 read from the stream, and then the Read function is used to convert this
6367 to the required target type.
6368
6369 Similarly the ``Write`` parameter specifies how to treat write attributes
6370 that directly or indirectly apply to the type given as the first parameter.
6371 It must have an input parameter of the type specified by the first parameter,
6372 and the return type must be the same as the input type of the Read function.
6373 The effect is to first call the Write function to convert to the given stream
6374 type, and then write the result type to the stream.
6375
6376 The Read and Write functions must not be overloaded subprograms. If necessary
6377 renamings can be supplied to meet this requirement.
6378 The usage of this attribute is best illustrated by a simple example, taken
6379 from the GNAT implementation of package Ada.Strings.Unbounded:
6380
6381
6382 .. code-block:: ada
6383
6384 function To_Unbounded (S : String) return Unbounded_String
6385 renames To_Unbounded_String;
6386
6387 pragma Stream_Convert
6388 (Unbounded_String, To_Unbounded, To_String);
6389
6390
6391 The specifications of the referenced functions, as given in the Ada
6392 Reference Manual are:
6393
6394
6395 .. code-block:: ada
6396
6397 function To_Unbounded_String (Source : String)
6398 return Unbounded_String;
6399
6400 function To_String (Source : Unbounded_String)
6401 return String;
6402
6403
6404 The effect is that if the value of an unbounded string is written to a stream,
6405 then the representation of the item in the stream is in the same format that
6406 would be used for ``Standard.String'Output``, and this same representation
6407 is expected when a value of this type is read from the stream. Note that the
6408 value written always includes the bounds, even for Unbounded_String'Write,
6409 since Unbounded_String is not an array type.
6410
6411 Note that the ``Stream_Convert`` pragma is not effective in the case of
6412 a derived type of a non-limited tagged type. If such a type is specified then
6413 the pragma is silently ignored, and the default implementation of the stream
6414 attributes is used instead.
6415
6416 Pragma Style_Checks
6417 ===================
6418
6419 Syntax:
6420
6421
6422 ::
6423
6424 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6425 On | Off [, LOCAL_NAME]);
6426
6427
6428 This pragma is used in conjunction with compiler switches to control the
6429 built in style checking provided by GNAT. The compiler switches, if set,
6430 provide an initial setting for the switches, and this pragma may be used
6431 to modify these settings, or the settings may be provided entirely by
6432 the use of the pragma. This pragma can be used anywhere that a pragma
6433 is legal, including use as a configuration pragma (including use in
6434 the :file:`gnat.adc` file).
6435
6436 The form with a string literal specifies which style options are to be
6437 activated. These are additive, so they apply in addition to any previously
6438 set style check options. The codes for the options are the same as those
6439 used in the *-gnaty* switch to *gcc* or *gnatmake*.
6440 For example the following two methods can be used to enable
6441 layout checking:
6442
6443 *
6444
6445 ::
6446
6447 pragma Style_Checks ("l");
6448
6449
6450 *
6451
6452 ::
6453
6454 gcc -c -gnatyl ...
6455
6456
6457 The form ``ALL_CHECKS`` activates all standard checks (its use is equivalent
6458 to the use of the :switch:`gnaty` switch with no options.
6459 See the :title:`GNAT User's Guide` for details.)
6460
6461 Note: the behavior is slightly different in GNAT mode (:switch:`-gnatg` used).
6462 In this case, ``ALL_CHECKS`` implies the standard set of GNAT mode style check
6463 options (i.e. equivalent to :switch:`-gnatyg`).
6464
6465 The forms with ``Off`` and ``On``
6466 can be used to temporarily disable style checks
6467 as shown in the following example:
6468
6469
6470 .. code-block:: ada
6471
6472 pragma Style_Checks ("k"); -- requires keywords in lower case
6473 pragma Style_Checks (Off); -- turn off style checks
6474 NULL; -- this will not generate an error message
6475 pragma Style_Checks (On); -- turn style checks back on
6476 NULL; -- this will generate an error message
6477
6478
6479 Finally the two argument form is allowed only if the first argument is
6480 ``On`` or ``Off``. The effect is to turn of semantic style checks
6481 for the specified entity, as shown in the following example:
6482
6483
6484 .. code-block:: ada
6485
6486 pragma Style_Checks ("r"); -- require consistency of identifier casing
6487 Arg : Integer;
6488 Rf1 : Integer := ARG; -- incorrect, wrong case
6489 pragma Style_Checks (Off, Arg);
6490 Rf2 : Integer := ARG; -- OK, no error
6491
6492
6493 Pragma Subtitle
6494 ===============
6495
6496 Syntax:
6497
6498
6499 ::
6500
6501 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6502
6503
6504 This pragma is recognized for compatibility with other Ada compilers
6505 but is ignored by GNAT.
6506
6507 Pragma Suppress
6508 ===============
6509
6510 Syntax:
6511
6512
6513 ::
6514
6515 pragma Suppress (Identifier [, [On =>] Name]);
6516
6517
6518 This is a standard pragma, and supports all the check names required in
6519 the RM. It is included here because GNAT recognizes some additional check
6520 names that are implementation defined (as permitted by the RM):
6521
6522
6523 *
6524 ``Alignment_Check`` can be used to suppress alignment checks
6525 on addresses used in address clauses. Such checks can also be suppressed
6526 by suppressing range checks, but the specific use of ``Alignment_Check``
6527 allows suppression of alignment checks without suppressing other range checks.
6528 Note that ``Alignment_Check`` is suppressed by default on machines (such as
6529 the x86) with non-strict alignment.
6530
6531 *
6532 ``Atomic_Synchronization`` can be used to suppress the special memory
6533 synchronization instructions that are normally generated for access to
6534 ``Atomic`` variables to ensure correct synchronization between tasks
6535 that use such variables for synchronization purposes.
6536
6537 *
6538 ``Duplicated_Tag_Check`` Can be used to suppress the check that is generated
6539 for a duplicated tag value when a tagged type is declared.
6540
6541 *
6542 ``Container_Checks`` Can be used to suppress all checks within Ada.Containers
6543 and instances of its children, including Tampering_Check.
6544
6545 *
6546 ``Tampering_Check`` Can be used to suppress tampering check in the containers.
6547
6548 *
6549 ``Predicate_Check`` can be used to control whether predicate checks are
6550 active. It is applicable only to predicates for which the policy is
6551 ``Check``. Unlike ``Assertion_Policy``, which determines if a given
6552 predicate is ignored or checked for the whole program, the use of
6553 ``Suppress`` and ``Unsuppress`` with this check name allows a given
6554 predicate to be turned on and off at specific points in the program.
6555
6556 *
6557 ``Validity_Check`` can be used specifically to control validity checks.
6558 If ``Suppress`` is used to suppress validity checks, then no validity
6559 checks are performed, including those specified by the appropriate compiler
6560 switch or the ``Validity_Checks`` pragma.
6561
6562 *
6563 Additional check names previously introduced by use of the ``Check_Name``
6564 pragma are also allowed.
6565
6566
6567 Note that pragma Suppress gives the compiler permission to omit
6568 checks, but does not require the compiler to omit checks. The compiler
6569 will generate checks if they are essentially free, even when they are
6570 suppressed. In particular, if the compiler can prove that a certain
6571 check will necessarily fail, it will generate code to do an
6572 unconditional 'raise', even if checks are suppressed. The compiler
6573 warns in this case.
6574
6575 Of course, run-time checks are omitted whenever the compiler can prove
6576 that they will not fail, whether or not checks are suppressed.
6577
6578 Pragma Suppress_All
6579 ===================
6580
6581 Syntax:
6582
6583
6584 .. code-block:: ada
6585
6586 pragma Suppress_All;
6587
6588
6589 This pragma can appear anywhere within a unit.
6590 The effect is to apply ``Suppress (All_Checks)`` to the unit
6591 in which it appears. This pragma is implemented for compatibility with DEC
6592 Ada 83 usage where it appears at the end of a unit, and for compatibility
6593 with Rational Ada, where it appears as a program unit pragma.
6594 The use of the standard Ada pragma ``Suppress (All_Checks)``
6595 as a normal configuration pragma is the preferred usage in GNAT.
6596
6597 .. _Pragma-Suppress_Debug_Info:
6598
6599 Pragma Suppress_Debug_Info
6600 ==========================
6601
6602 Syntax:
6603
6604
6605 ::
6606
6607 pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6608
6609
6610 This pragma can be used to suppress generation of debug information
6611 for the specified entity. It is intended primarily for use in debugging
6612 the debugger, and navigating around debugger problems.
6613
6614 Pragma Suppress_Exception_Locations
6615 ===================================
6616
6617 Syntax:
6618
6619
6620 .. code-block:: ada
6621
6622 pragma Suppress_Exception_Locations;
6623
6624
6625 In normal mode, a raise statement for an exception by default generates
6626 an exception message giving the file name and line number for the location
6627 of the raise. This is useful for debugging and logging purposes, but this
6628 entails extra space for the strings for the messages. The configuration
6629 pragma ``Suppress_Exception_Locations`` can be used to suppress the
6630 generation of these strings, with the result that space is saved, but the
6631 exception message for such raises is null. This configuration pragma may
6632 appear in a global configuration pragma file, or in a specific unit as
6633 usual. It is not required that this pragma be used consistently within
6634 a partition, so it is fine to have some units within a partition compiled
6635 with this pragma and others compiled in normal mode without it.
6636
6637 .. _Pragma-Suppress_Initialization:
6638
6639 Pragma Suppress_Initialization
6640 ==============================
6641 .. index:: Suppressing initialization
6642
6643 .. index:: Initialization, suppression of
6644
6645 Syntax:
6646
6647
6648 ::
6649
6650 pragma Suppress_Initialization ([Entity =>] variable_or_subtype_Name);
6651
6652
6653 Here variable_or_subtype_Name is the name introduced by a type declaration
6654 or subtype declaration or the name of a variable introduced by an
6655 object declaration.
6656
6657 In the case of a type or subtype
6658 this pragma suppresses any implicit or explicit initialization
6659 for all variables of the given type or subtype,
6660 including initialization resulting from the use of pragmas
6661 Normalize_Scalars or Initialize_Scalars.
6662
6663 This is considered a representation item, so it cannot be given after
6664 the type is frozen. It applies to all subsequent object declarations,
6665 and also any allocator that creates objects of the type.
6666
6667 If the pragma is given for the first subtype, then it is considered
6668 to apply to the base type and all its subtypes. If the pragma is given
6669 for other than a first subtype, then it applies only to the given subtype.
6670 The pragma may not be given after the type is frozen.
6671
6672 Note that this includes eliminating initialization of discriminants
6673 for discriminated types, and tags for tagged types. In these cases,
6674 you will have to use some non-portable mechanism (e.g. address
6675 overlays or unchecked conversion) to achieve required initialization
6676 of these fields before accessing any object of the corresponding type.
6677
6678 For the variable case, implicit initialization for the named variable
6679 is suppressed, just as though its subtype had been given in a pragma
6680 Suppress_Initialization, as described above.
6681
6682 Pragma Task_Name
6683 ================
6684
6685 Syntax
6686
6687
6688 .. code-block:: ada
6689
6690 pragma Task_Name (string_EXPRESSION);
6691
6692
6693 This pragma appears within a task definition (like pragma
6694 ``Priority``) and applies to the task in which it appears. The
6695 argument must be of type String, and provides a name to be used for
6696 the task instance when the task is created. Note that this expression
6697 is not required to be static, and in particular, it can contain
6698 references to task discriminants. This facility can be used to
6699 provide different names for different tasks as they are created,
6700 as illustrated in the example below.
6701
6702 The task name is recorded internally in the run-time structures
6703 and is accessible to tools like the debugger. In addition the
6704 routine ``Ada.Task_Identification.Image`` will return this
6705 string, with a unique task address appended.
6706
6707
6708 .. code-block:: ada
6709
6710 -- Example of the use of pragma Task_Name
6711
6712 with Ada.Task_Identification;
6713 use Ada.Task_Identification;
6714 with Text_IO; use Text_IO;
6715 procedure t3 is
6716
6717 type Astring is access String;
6718
6719 task type Task_Typ (Name : access String) is
6720 pragma Task_Name (Name.all);
6721 end Task_Typ;
6722
6723 task body Task_Typ is
6724 Nam : constant String := Image (Current_Task);
6725 begin
6726 Put_Line ("-->" & Nam (1 .. 14) & "<--");
6727 end Task_Typ;
6728
6729 type Ptr_Task is access Task_Typ;
6730 Task_Var : Ptr_Task;
6731
6732 begin
6733 Task_Var :=
6734 new Task_Typ (new String'("This is task 1"));
6735 Task_Var :=
6736 new Task_Typ (new String'("This is task 2"));
6737 end;
6738
6739
6740 Pragma Task_Storage
6741 ===================
6742 Syntax:
6743
6744
6745 ::
6746
6747 pragma Task_Storage (
6748 [Task_Type =>] LOCAL_NAME,
6749 [Top_Guard =>] static_integer_EXPRESSION);
6750
6751
6752 This pragma specifies the length of the guard area for tasks. The guard
6753 area is an additional storage area allocated to a task. A value of zero
6754 means that either no guard area is created or a minimal guard area is
6755 created, depending on the target. This pragma can appear anywhere a
6756 ``Storage_Size`` attribute definition clause is allowed for a task
6757 type.
6758
6759 .. _Pragma-Test_Case:
6760
6761 Pragma Test_Case
6762 ================
6763 .. index:: Test cases
6764
6765
6766 Syntax:
6767
6768
6769 ::
6770
6771 pragma Test_Case (
6772 [Name =>] static_string_Expression
6773 ,[Mode =>] (Nominal | Robustness)
6774 [, Requires => Boolean_Expression]
6775 [, Ensures => Boolean_Expression]);
6776
6777
6778 The ``Test_Case`` pragma allows defining fine-grain specifications
6779 for use by testing tools.
6780 The compiler checks the validity of the ``Test_Case`` pragma, but its
6781 presence does not lead to any modification of the code generated by the
6782 compiler.
6783
6784 ``Test_Case`` pragmas may only appear immediately following the
6785 (separate) declaration of a subprogram in a package declaration, inside
6786 a package spec unit. Only other pragmas may intervene (that is appear
6787 between the subprogram declaration and a test case).
6788
6789 The compiler checks that boolean expressions given in ``Requires`` and
6790 ``Ensures`` are valid, where the rules for ``Requires`` are the
6791 same as the rule for an expression in ``Precondition`` and the rules
6792 for ``Ensures`` are the same as the rule for an expression in
6793 ``Postcondition``. In particular, attributes ``'Old`` and
6794 ``'Result`` can only be used within the ``Ensures``
6795 expression. The following is an example of use within a package spec:
6796
6797
6798 .. code-block:: ada
6799
6800 package Math_Functions is
6801 ...
6802 function Sqrt (Arg : Float) return Float;
6803 pragma Test_Case (Name => "Test 1",
6804 Mode => Nominal,
6805 Requires => Arg < 10000.0,
6806 Ensures => Sqrt'Result < 10.0);
6807 ...
6808 end Math_Functions;
6809
6810
6811 The meaning of a test case is that there is at least one context where
6812 ``Requires`` holds such that, if the associated subprogram is executed in
6813 that context, then ``Ensures`` holds when the subprogram returns.
6814 Mode ``Nominal`` indicates that the input context should also satisfy the
6815 precondition of the subprogram, and the output context should also satisfy its
6816 postcondition. Mode ``Robustness`` indicates that the precondition and
6817 postcondition of the subprogram should be ignored for this test case.
6818
6819 .. _Pragma-Thread_Local_Storage:
6820
6821 Pragma Thread_Local_Storage
6822 ===========================
6823 .. index:: Task specific storage
6824
6825 .. index:: TLS (Thread Local Storage)
6826
6827 .. index:: Task_Attributes
6828
6829 Syntax:
6830
6831
6832 ::
6833
6834 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
6835
6836
6837 This pragma specifies that the specified entity, which must be
6838 a variable declared in a library-level package, is to be marked as
6839 "Thread Local Storage" (``TLS``). On systems supporting this (which
6840 include Windows, Solaris, GNU/Linux, and VxWorks 6), this causes each
6841 thread (and hence each Ada task) to see a distinct copy of the variable.
6842
6843 The variable must not have default initialization, and if there is
6844 an explicit initialization, it must be either ``null`` for an
6845 access variable, a static expression for a scalar variable, or a fully
6846 static aggregate for a composite type, that is to say, an aggregate all
6847 of whose components are static, and which does not include packed or
6848 discriminated components.
6849
6850 This provides a low-level mechanism similar to that provided by
6851 the ``Ada.Task_Attributes`` package, but much more efficient
6852 and is also useful in writing interface code that will interact
6853 with foreign threads.
6854
6855 If this pragma is used on a system where ``TLS`` is not supported,
6856 then an error message will be generated and the program will be rejected.
6857
6858 Pragma Time_Slice
6859 =================
6860
6861 Syntax:
6862
6863
6864 .. code-block:: ada
6865
6866 pragma Time_Slice (static_duration_EXPRESSION);
6867
6868
6869 For implementations of GNAT on operating systems where it is possible
6870 to supply a time slice value, this pragma may be used for this purpose.
6871 It is ignored if it is used in a system that does not allow this control,
6872 or if it appears in other than the main program unit.
6873
6874 Pragma Title
6875 ============
6876
6877 Syntax:
6878
6879
6880 ::
6881
6882 pragma Title (TITLING_OPTION [, TITLING OPTION]);
6883
6884 TITLING_OPTION ::=
6885 [Title =>] STRING_LITERAL,
6886 | [Subtitle =>] STRING_LITERAL
6887
6888
6889 Syntax checked but otherwise ignored by GNAT. This is a listing control
6890 pragma used in DEC Ada 83 implementations to provide a title and/or
6891 subtitle for the program listing. The program listing generated by GNAT
6892 does not have titles or subtitles.
6893
6894 Unlike other pragmas, the full flexibility of named notation is allowed
6895 for this pragma, i.e., the parameters may be given in any order if named
6896 notation is used, and named and positional notation can be mixed
6897 following the normal rules for procedure calls in Ada.
6898
6899 Pragma Type_Invariant
6900 =====================
6901
6902 Syntax:
6903
6904
6905 ::
6906
6907 pragma Type_Invariant
6908 ([Entity =>] type_LOCAL_NAME,
6909 [Check =>] EXPRESSION);
6910
6911
6912 The ``Type_Invariant`` pragma is intended to be an exact
6913 replacement for the language-defined ``Type_Invariant``
6914 aspect, and shares its restrictions and semantics. It differs
6915 from the language defined ``Invariant`` pragma in that it
6916 does not permit a string parameter, and it is
6917 controlled by the assertion identifier ``Type_Invariant``
6918 rather than ``Invariant``.
6919
6920 .. _Pragma-Type_Invariant_Class:
6921
6922 Pragma Type_Invariant_Class
6923 ===========================
6924
6925 Syntax:
6926
6927
6928 ::
6929
6930 pragma Type_Invariant_Class
6931 ([Entity =>] type_LOCAL_NAME,
6932 [Check =>] EXPRESSION);
6933
6934
6935 The ``Type_Invariant_Class`` pragma is intended to be an exact
6936 replacement for the language-defined ``Type_Invariant'Class``
6937 aspect, and shares its restrictions and semantics.
6938
6939 Note: This pragma is called ``Type_Invariant_Class`` rather than
6940 ``Type_Invariant'Class`` because the latter would not be strictly
6941 conforming to the allowed syntax for pragmas. The motivation
6942 for providing pragmas equivalent to the aspects is to allow a program
6943 to be written using the pragmas, and then compiled if necessary
6944 using an Ada compiler that does not recognize the pragmas or
6945 aspects, but is prepared to ignore the pragmas. The assertion
6946 policy that controls this pragma is ``Type_Invariant'Class``,
6947 not ``Type_Invariant_Class``.
6948
6949 Pragma Unchecked_Union
6950 ======================
6951 .. index:: Unions in C
6952
6953
6954 Syntax:
6955
6956
6957 .. code-block:: ada
6958
6959 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
6960
6961
6962 This pragma is used to specify a representation of a record type that is
6963 equivalent to a C union. It was introduced as a GNAT implementation defined
6964 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
6965 pragma, making it language defined, and GNAT fully implements this extended
6966 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
6967 details, consult the Ada 2012 Reference Manual, section B.3.3.
6968
6969 Pragma Unevaluated_Use_Of_Old
6970 =============================
6971 .. index:: Attribute Old
6972
6973 .. index:: Attribute Loop_Entry
6974
6975 .. index:: Unevaluated_Use_Of_Old
6976
6977
6978 Syntax:
6979
6980
6981 .. code-block:: ada
6982
6983 pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
6984
6985
6986 This pragma controls the processing of attributes Old and Loop_Entry.
6987 If either of these attributes is used in a potentially unevaluated
6988 expression (e.g. the then or else parts of an if expression), then
6989 normally this usage is considered illegal if the prefix of the attribute
6990 is other than an entity name. The language requires this
6991 behavior for Old, and GNAT copies the same rule for Loop_Entry.
6992
6993 The reason for this rule is that otherwise, we can have a situation
6994 where we save the Old value, and this results in an exception, even
6995 though we might not evaluate the attribute. Consider this example:
6996
6997
6998 .. code-block:: ada
6999
7000 package UnevalOld is
7001 K : Character;
7002 procedure U (A : String; C : Boolean) -- ERROR
7003 with Post => (if C then A(1)'Old = K else True);
7004 end;
7005
7006
7007 If procedure U is called with a string with a lower bound of 2, and
7008 C false, then an exception would be raised trying to evaluate A(1)
7009 on entry even though the value would not be actually used.
7010
7011 Although the rule guarantees against this possibility, it is sometimes
7012 too restrictive. For example if we know that the string has a lower
7013 bound of 1, then we will never raise an exception.
7014 The pragma ``Unevaluated_Use_Of_Old`` can be
7015 used to modify this behavior. If the argument is ``Error`` then an
7016 error is given (this is the default RM behavior). If the argument is
7017 ``Warn`` then the usage is allowed as legal but with a warning
7018 that an exception might be raised. If the argument is ``Allow``
7019 then the usage is allowed as legal without generating a warning.
7020
7021 This pragma may appear as a configuration pragma, or in a declarative
7022 part or package specification. In the latter case it applies to
7023 uses up to the end of the corresponding statement sequence or
7024 sequence of package declarations.
7025
7026 Pragma Unimplemented_Unit
7027 =========================
7028
7029 Syntax:
7030
7031
7032 .. code-block:: ada
7033
7034 pragma Unimplemented_Unit;
7035
7036
7037 If this pragma occurs in a unit that is processed by the compiler, GNAT
7038 aborts with the message :samp:`xxx not implemented`, where
7039 ``xxx`` is the name of the current compilation unit. This pragma is
7040 intended to allow the compiler to handle unimplemented library units in
7041 a clean manner.
7042
7043 The abort only happens if code is being generated. Thus you can use
7044 specs of unimplemented packages in syntax or semantic checking mode.
7045
7046 .. _Pragma-Universal_Aliasing:
7047
7048 Pragma Universal_Aliasing
7049 =========================
7050
7051 Syntax:
7052
7053
7054 ::
7055
7056 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7057
7058
7059 ``type_LOCAL_NAME`` must refer to a type declaration in the current
7060 declarative part. The effect is to inhibit strict type-based aliasing
7061 optimization for the given type. In other words, the effect is as though
7062 access types designating this type were subject to pragma No_Strict_Aliasing.
7063 For a detailed description of the strict aliasing optimization, and the
7064 situations in which it must be suppressed, see the section on
7065 ``Optimization and Strict Aliasing`` in the :title:`GNAT User's Guide`.
7066
7067 .. _Pragma-Unmodified:
7068
7069 Pragma Unmodified
7070 =================
7071 .. index:: Warnings, unmodified
7072
7073 Syntax:
7074
7075
7076 ::
7077
7078 pragma Unmodified (LOCAL_NAME {, LOCAL_NAME});
7079
7080
7081 This pragma signals that the assignable entities (variables,
7082 ``out`` parameters, ``in out`` parameters) whose names are listed are
7083 deliberately not assigned in the current source unit. This
7084 suppresses warnings about the
7085 entities being referenced but not assigned, and in addition a warning will be
7086 generated if one of these entities is in fact assigned in the
7087 same unit as the pragma (or in the corresponding body, or one
7088 of its subunits).
7089
7090 This is particularly useful for clearly signaling that a particular
7091 parameter is not modified, even though the spec suggests that it might
7092 be.
7093
7094 For the variable case, warnings are never given for unreferenced variables
7095 whose name contains one of the substrings
7096 ``DISCARD, DUMMY, IGNORE, JUNK, UNUSED`` in any casing. Such names
7097 are typically to be used in cases where such warnings are expected.
7098 Thus it is never necessary to use ``pragma Unmodified`` for such
7099 variables, though it is harmless to do so.
7100
7101 .. _Pragma-Unreferenced:
7102
7103 Pragma Unreferenced
7104 ===================
7105 .. index:: Warnings, unreferenced
7106
7107 Syntax:
7108
7109
7110 ::
7111
7112 pragma Unreferenced (LOCAL_NAME {, LOCAL_NAME});
7113 pragma Unreferenced (library_unit_NAME {, library_unit_NAME});
7114
7115
7116 This pragma signals that the entities whose names are listed are
7117 deliberately not referenced in the current source unit after the
7118 occurrence of the pragma. This
7119 suppresses warnings about the
7120 entities being unreferenced, and in addition a warning will be
7121 generated if one of these entities is in fact subsequently referenced in the
7122 same unit as the pragma (or in the corresponding body, or one
7123 of its subunits).
7124
7125 This is particularly useful for clearly signaling that a particular
7126 parameter is not referenced in some particular subprogram implementation
7127 and that this is deliberate. It can also be useful in the case of
7128 objects declared only for their initialization or finalization side
7129 effects.
7130
7131 If ``LOCAL_NAME`` identifies more than one matching homonym in the
7132 current scope, then the entity most recently declared is the one to which
7133 the pragma applies. Note that in the case of accept formals, the pragma
7134 Unreferenced may appear immediately after the keyword ``do`` which
7135 allows the indication of whether or not accept formals are referenced
7136 or not to be given individually for each accept statement.
7137
7138 The left hand side of an assignment does not count as a reference for the
7139 purpose of this pragma. Thus it is fine to assign to an entity for which
7140 pragma Unreferenced is given. However, use of an entity as an actual for
7141 an out parameter does count as a reference unless warnings for unread output
7142 parameters are enabled via :switch:`-gnatw.o`.
7143
7144 Note that if a warning is desired for all calls to a given subprogram,
7145 regardless of whether they occur in the same unit as the subprogram
7146 declaration, then this pragma should not be used (calls from another
7147 unit would not be flagged); pragma Obsolescent can be used instead
7148 for this purpose, see :ref:`Pragma_Obsolescent`.
7149
7150 The second form of pragma ``Unreferenced`` is used within a context
7151 clause. In this case the arguments must be unit names of units previously
7152 mentioned in ``with`` clauses (similar to the usage of pragma
7153 ``Elaborate_All``. The effect is to suppress warnings about unreferenced
7154 units and unreferenced entities within these units.
7155
7156 For the variable case, warnings are never given for unreferenced variables
7157 whose name contains one of the substrings
7158 ``DISCARD, DUMMY, IGNORE, JUNK, UNUSED`` in any casing. Such names
7159 are typically to be used in cases where such warnings are expected.
7160 Thus it is never necessary to use ``pragma Unreferenced`` for such
7161 variables, though it is harmless to do so.
7162
7163 .. _Pragma-Unreferenced_Objects:
7164
7165 Pragma Unreferenced_Objects
7166 ===========================
7167 .. index:: Warnings, unreferenced
7168
7169 Syntax:
7170
7171
7172 ::
7173
7174 pragma Unreferenced_Objects (local_subtype_NAME {, local_subtype_NAME});
7175
7176
7177 This pragma signals that for the types or subtypes whose names are
7178 listed, objects which are declared with one of these types or subtypes may
7179 not be referenced, and if no references appear, no warnings are given.
7180
7181 This is particularly useful for objects which are declared solely for their
7182 initialization and finalization effect. Such variables are sometimes referred
7183 to as RAII variables (Resource Acquisition Is Initialization). Using this
7184 pragma on the relevant type (most typically a limited controlled type), the
7185 compiler will automatically suppress unwanted warnings about these variables
7186 not being referenced.
7187
7188 Pragma Unreserve_All_Interrupts
7189 ===============================
7190
7191 Syntax:
7192
7193
7194 .. code-block:: ada
7195
7196 pragma Unreserve_All_Interrupts;
7197
7198
7199 Normally certain interrupts are reserved to the implementation. Any attempt
7200 to attach an interrupt causes Program_Error to be raised, as described in
7201 RM C.3.2(22). A typical example is the ``SIGINT`` interrupt used in
7202 many systems for a :kbd:`Ctrl-C` interrupt. Normally this interrupt is
7203 reserved to the implementation, so that :kbd:`Ctrl-C` can be used to
7204 interrupt execution.
7205
7206 If the pragma ``Unreserve_All_Interrupts`` appears anywhere in any unit in
7207 a program, then all such interrupts are unreserved. This allows the
7208 program to handle these interrupts, but disables their standard
7209 functions. For example, if this pragma is used, then pressing
7210 :kbd:`Ctrl-C` will not automatically interrupt execution. However,
7211 a program can then handle the ``SIGINT`` interrupt as it chooses.
7212
7213 For a full list of the interrupts handled in a specific implementation,
7214 see the source code for the spec of ``Ada.Interrupts.Names`` in
7215 file :file:`a-intnam.ads`. This is a target dependent file that contains the
7216 list of interrupts recognized for a given target. The documentation in
7217 this file also specifies what interrupts are affected by the use of
7218 the ``Unreserve_All_Interrupts`` pragma.
7219
7220 For a more general facility for controlling what interrupts can be
7221 handled, see pragma ``Interrupt_State``, which subsumes the functionality
7222 of the ``Unreserve_All_Interrupts`` pragma.
7223
7224 Pragma Unsuppress
7225 =================
7226
7227 Syntax:
7228
7229
7230 ::
7231
7232 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7233
7234
7235 This pragma undoes the effect of a previous pragma ``Suppress``. If
7236 there is no corresponding pragma ``Suppress`` in effect, it has no
7237 effect. The range of the effect is the same as for pragma
7238 ``Suppress``. The meaning of the arguments is identical to that used
7239 in pragma ``Suppress``.
7240
7241 One important application is to ensure that checks are on in cases where
7242 code depends on the checks for its correct functioning, so that the code
7243 will compile correctly even if the compiler switches are set to suppress
7244 checks. For example, in a program that depends on external names of tagged
7245 types and wants to ensure that the duplicated tag check occurs even if all
7246 run-time checks are suppressed by a compiler switch, the following
7247 configuration pragma will ensure this test is not suppressed:
7248
7249
7250 .. code-block:: ada
7251
7252 pragma Unsuppress (Duplicated_Tag_Check);
7253
7254
7255 This pragma is standard in Ada 2005. It is available in all earlier versions
7256 of Ada as an implementation-defined pragma.
7257
7258 Note that in addition to the checks defined in the Ada RM, GNAT recogizes a
7259 number of implementation-defined check names. See the description of pragma
7260 ``Suppress`` for full details.
7261
7262 Pragma Use_VADS_Size
7263 ====================
7264 .. index:: Size, VADS compatibility
7265
7266 .. index:: Rational profile
7267
7268
7269 Syntax:
7270
7271
7272 .. code-block:: ada
7273
7274 pragma Use_VADS_Size;
7275
7276
7277 This is a configuration pragma. In a unit to which it applies, any use
7278 of the 'Size attribute is automatically interpreted as a use of the
7279 'VADS_Size attribute. Note that this may result in incorrect semantic
7280 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
7281 the handling of existing code which depends on the interpretation of Size
7282 as implemented in the VADS compiler. See description of the VADS_Size
7283 attribute for further details.
7284
7285 .. _Pragma-Unused:
7286
7287 Pragma Unused
7288 =============
7289 .. index:: Warnings, unused
7290
7291 Syntax:
7292
7293
7294 ::
7295
7296 pragma Unused (LOCAL_NAME {, LOCAL_NAME});
7297
7298
7299 This pragma signals that the assignable entities (variables,
7300 ``out`` parameters, and ``in out`` parameters) whose names are listed
7301 deliberately do not get assigned or referenced in the current source unit
7302 after the occurrence of the pragma in the current source unit. This
7303 suppresses warnings about the entities that are unreferenced and/or not
7304 assigned, and, in addition, a warning will be generated if one of these
7305 entities gets assigned or subsequently referenced in the same unit as the
7306 pragma (in the corresponding body or one of its subunits).
7307
7308 This is particularly useful for clearly signaling that a particular
7309 parameter is not modified or referenced, even though the spec suggests
7310 that it might be.
7311
7312 For the variable case, warnings are never given for unreferenced
7313 variables whose name contains one of the substrings
7314 ``DISCARD, DUMMY, IGNORE, JUNK, UNUSED`` in any casing. Such names
7315 are typically to be used in cases where such warnings are expected.
7316 Thus it is never necessary to use ``pragma Unmodified`` for such
7317 variables, though it is harmless to do so.
7318
7319 Pragma Validity_Checks
7320 ======================
7321
7322 Syntax:
7323
7324
7325 .. code-block:: ada
7326
7327 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7328
7329
7330 This pragma is used in conjunction with compiler switches to control the
7331 built-in validity checking provided by GNAT. The compiler switches, if set
7332 provide an initial setting for the switches, and this pragma may be used
7333 to modify these settings, or the settings may be provided entirely by
7334 the use of the pragma. This pragma can be used anywhere that a pragma
7335 is legal, including use as a configuration pragma (including use in
7336 the :file:`gnat.adc` file).
7337
7338 The form with a string literal specifies which validity options are to be
7339 activated. The validity checks are first set to include only the default
7340 reference manual settings, and then a string of letters in the string
7341 specifies the exact set of options required. The form of this string
7342 is exactly as described for the *-gnatVx* compiler switch (see the
7343 GNAT User's Guide for details). For example the following two
7344 methods can be used to enable validity checking for mode ``in`` and
7345 ``in out`` subprogram parameters:
7346
7347 *
7348
7349 .. code-block:: ada
7350
7351 pragma Validity_Checks ("im");
7352
7353
7354 *
7355
7356 .. code-block:: sh
7357
7358 $ gcc -c -gnatVim ...
7359
7360
7361 The form ALL_CHECKS activates all standard checks (its use is equivalent
7362 to the use of the :switch:`gnatVa` switch).
7363
7364 The forms with ``Off`` and ``On`` can be used to temporarily disable
7365 validity checks as shown in the following example:
7366
7367
7368 .. code-block:: ada
7369
7370 pragma Validity_Checks ("c"); -- validity checks for copies
7371 pragma Validity_Checks (Off); -- turn off validity checks
7372 A := B; -- B will not be validity checked
7373 pragma Validity_Checks (On); -- turn validity checks back on
7374 A := C; -- C will be validity checked
7375
7376 .. _Pragma-Volatile:
7377
7378 Pragma Volatile
7379 ===============
7380
7381 Syntax:
7382
7383
7384 .. code-block:: ada
7385
7386 pragma Volatile (LOCAL_NAME);
7387
7388
7389 This pragma is defined by the Ada Reference Manual, and the GNAT
7390 implementation is fully conformant with this definition. The reason it
7391 is mentioned in this section is that a pragma of the same name was supplied
7392 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
7393 implementation of pragma Volatile is upwards compatible with the
7394 implementation in DEC Ada 83.
7395
7396 .. _Pragma-Volatile_Full_Access:
7397
7398 Pragma Volatile_Full_Access
7399 ===========================
7400
7401 Syntax:
7402
7403
7404 .. code-block:: ada
7405
7406 pragma Volatile_Full_Access (LOCAL_NAME);
7407
7408
7409 This is similar in effect to pragma Volatile, except that any reference to the
7410 object is guaranteed to be done only with instructions that read or write all
7411 the bits of the object. Furthermore, if the object is of a composite type,
7412 then any reference to a subcomponent of the object is guaranteed to read
7413 and/or write all the bits of the object.
7414
7415 The intention is that this be suitable for use with memory-mapped I/O devices
7416 on some machines. Note that there are two important respects in which this is
7417 different from ``pragma Atomic``. First a reference to a ``Volatile_Full_Access``
7418 object is not a sequential action in the RM 9.10 sense and, therefore, does
7419 not create a synchronization point. Second, in the case of ``pragma Atomic``,
7420 there is no guarantee that all the bits will be accessed if the reference
7421 is not to the whole object; the compiler is allowed (and generally will)
7422 access only part of the object in this case.
7423
7424 .. _Pragma-Volatile_Function:
7425
7426 Pragma Volatile_Function
7427 ========================
7428
7429 Syntax:
7430
7431 .. code-block:: ada
7432
7433 pragma Volatile_Function [ (boolean_EXPRESSION) ];
7434
7435 For the semantics of this pragma, see the entry for aspect ``Volatile_Function``
7436 in the SPARK 2014 Reference Manual, section 7.1.2.
7437
7438 Pragma Warning_As_Error
7439 =======================
7440
7441 Syntax:
7442
7443
7444 .. code-block:: ada
7445
7446 pragma Warning_As_Error (static_string_EXPRESSION);
7447
7448
7449 This configuration pragma allows the programmer to specify a set
7450 of warnings that will be treated as errors. Any warning that
7451 matches the pattern given by the pragma argument will be treated
7452 as an error. This gives more precise control than -gnatwe,
7453 which treats warnings as errors.
7454
7455 This pragma can apply to regular warnings (messages enabled by -gnatw)
7456 and to style warnings (messages that start with "(style)",
7457 enabled by -gnaty).
7458
7459 The pattern may contain asterisks, which match zero or more characters
7460 in the message. For example, you can use ``pragma Warning_As_Error
7461 ("bits of*unused")`` to treat the warning message ``warning: 960 bits of
7462 "a" unused`` as an error. All characters other than asterisk are treated
7463 as literal characters in the match. The match is case insensitive; for
7464 example XYZ matches xyz.
7465
7466 Note that the pattern matches if it occurs anywhere within the warning
7467 message string (it is not necessary to put an asterisk at the start and
7468 the end of the message, since this is implied).
7469
7470 Another possibility for the static_string_EXPRESSION which works whether
7471 or not error tags are enabled (*-gnatw.d*) is to use a single
7472 *-gnatw* tag string, enclosed in brackets,
7473 as shown in the example below, to treat one category of warnings as errors.
7474 Note that if you want to treat multiple categories of warnings as errors,
7475 you can use multiple pragma Warning_As_Error.
7476
7477 The above use of patterns to match the message applies only to warning
7478 messages generated by the front end. This pragma can also be applied to
7479 warnings provided by the back end and mentioned in :ref:`Pragma_Warnings`.
7480 By using a single full *-Wxxx* switch in the pragma, such warnings
7481 can also be treated as errors.
7482
7483 The pragma can appear either in a global configuration pragma file
7484 (e.g. :file:`gnat.adc`), or at the start of a file. Given a global
7485 configuration pragma file containing:
7486
7487
7488 .. code-block:: ada
7489
7490 pragma Warning_As_Error ("[-gnatwj]");
7491
7492
7493 which will treat all obsolescent feature warnings as errors, the
7494 following program compiles as shown (compile options here are
7495 *-gnatwa.d -gnatl -gnatj55*).
7496
7497
7498 ::
7499
7500 1. pragma Warning_As_Error ("*never assigned*");
7501 2. function Warnerr return String is
7502 3. X : Integer;
7503 |
7504 >>> error: variable "X" is never read and
7505 never assigned [-gnatwv] [warning-as-error]
7506
7507 4. Y : Integer;
7508 |
7509 >>> warning: variable "Y" is assigned but
7510 never read [-gnatwu]
7511
7512 5. begin
7513 6. Y := 0;
7514 7. return %ABC%;
7515 |
7516 >>> error: use of "%" is an obsolescent
7517 feature (RM J.2(4)), use """ instead
7518 [-gnatwj] [warning-as-error]
7519
7520 8. end;
7521
7522 8 lines: No errors, 3 warnings (2 treated as errors)
7523
7524
7525 Note that this pragma does not affect the set of warnings issued in
7526 any way, it merely changes the effect of a matching warning if one
7527 is produced as a result of other warnings options. As shown in this
7528 example, if the pragma results in a warning being treated as an error,
7529 the tag is changed from "warning:" to "error:" and the string
7530 "[warning-as-error]" is appended to the end of the message.
7531
7532 .. _Pragma_Warnings:
7533
7534 Pragma Warnings
7535 ===============
7536
7537 Syntax:
7538
7539
7540 .. code-block:: ada
7541
7542 pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]);
7543
7544 DETAILS ::= On | Off
7545 DETAILS ::= On | Off, local_NAME
7546 DETAILS ::= static_string_EXPRESSION
7547 DETAILS ::= On | Off, static_string_EXPRESSION
7548
7549 TOOL_NAME ::= GNAT | GNATprove
7550
7551 REASON ::= Reason => STRING_LITERAL {& STRING_LITERAL}
7552
7553 Note: in Ada 83 mode, a string literal may be used in place of a static string
7554 expression (which does not exist in Ada 83).
7555
7556 Note if the second argument of ``DETAILS`` is a ``local_NAME`` then the
7557 second form is always understood. If the intention is to use
7558 the fourth form, then you can write ``NAME & ""`` to force the
7559 intepretation as a *static_string_EXPRESSION*.
7560
7561 Note: if the first argument is a valid ``TOOL_NAME``, it will be interpreted
7562 that way. The use of the ``TOOL_NAME`` argument is relevant only to users
7563 of SPARK and GNATprove, see last part of this section for details.
7564
7565 Normally warnings are enabled, with the output being controlled by
7566 the command line switch. Warnings (``Off``) turns off generation of
7567 warnings until a Warnings (``On``) is encountered or the end of the
7568 current unit. If generation of warnings is turned off using this
7569 pragma, then some or all of the warning messages are suppressed,
7570 regardless of the setting of the command line switches.
7571
7572 The ``Reason`` parameter may optionally appear as the last argument
7573 in any of the forms of this pragma. It is intended purely for the
7574 purposes of documenting the reason for the ``Warnings`` pragma.
7575 The compiler will check that the argument is a static string but
7576 otherwise ignore this argument. Other tools may provide specialized
7577 processing for this string.
7578
7579 The form with a single argument (or two arguments if Reason present),
7580 where the first argument is ``ON`` or ``OFF``
7581 may be used as a configuration pragma.
7582
7583 If the ``LOCAL_NAME`` parameter is present, warnings are suppressed for
7584 the specified entity. This suppression is effective from the point where
7585 it occurs till the end of the extended scope of the variable (similar to
7586 the scope of ``Suppress``). This form cannot be used as a configuration
7587 pragma.
7588
7589 In the case where the first argument is other than ``ON`` or
7590 ``OFF``,
7591 the third form with a single static_string_EXPRESSION argument (and possible
7592 reason) provides more precise
7593 control over which warnings are active. The string is a list of letters
7594 specifying which warnings are to be activated and which deactivated. The
7595 code for these letters is the same as the string used in the command
7596 line switch controlling warnings. For a brief summary, use the gnatmake
7597 command with no arguments, which will generate usage information containing
7598 the list of warnings switches supported. For
7599 full details see the section on ``Warning Message Control`` in the
7600 :title:`GNAT User's Guide`.
7601 This form can also be used as a configuration pragma.
7602
7603 The warnings controlled by the :switch:`-gnatw` switch are generated by the
7604 front end of the compiler. The GCC back end can provide additional warnings
7605 and they are controlled by the :switch:`-W` switch. Such warnings can be
7606 identified by the appearance of a string of the form ``[-W{xxx}]`` in the
7607 message which designates the :switch:`-W{xxx}` switch that controls the message.
7608 The form with a single *static_string_EXPRESSION* argument also works for these
7609 warnings, but the string must be a single full :switch:`-W{xxx}` switch in this
7610 case. The above reference lists a few examples of these additional warnings.
7611
7612 The specified warnings will be in effect until the end of the program
7613 or another pragma ``Warnings`` is encountered. The effect of the pragma is
7614 cumulative. Initially the set of warnings is the standard default set
7615 as possibly modified by compiler switches. Then each pragma Warning
7616 modifies this set of warnings as specified. This form of the pragma may
7617 also be used as a configuration pragma.
7618
7619 The fourth form, with an ``On|Off`` parameter and a string, is used to
7620 control individual messages, based on their text. The string argument
7621 is a pattern that is used to match against the text of individual
7622 warning messages (not including the initial "warning: " tag).
7623
7624 The pattern may contain asterisks, which match zero or more characters in
7625 the message. For example, you can use
7626 ``pragma Warnings (Off, "bits of*unused")`` to suppress the warning
7627 message ``warning: 960 bits of "a" unused``. No other regular
7628 expression notations are permitted. All characters other than asterisk in
7629 these three specific cases are treated as literal characters in the match.
7630 The match is case insensitive, for example XYZ matches xyz.
7631
7632 Note that the pattern matches if it occurs anywhere within the warning
7633 message string (it is not necessary to put an asterisk at the start and
7634 the end of the message, since this is implied).
7635
7636 The above use of patterns to match the message applies only to warning
7637 messages generated by the front end. This form of the pragma with a string
7638 argument can also be used to control warnings provided by the back end and
7639 mentioned above. By using a single full :switch:`-W{xxx}` switch in the pragma,
7640 such warnings can be turned on and off.
7641
7642 There are two ways to use the pragma in this form. The OFF form can be used
7643 as a configuration pragma. The effect is to suppress all warnings (if any)
7644 that match the pattern string throughout the compilation (or match the
7645 -W switch in the back end case).
7646
7647 The second usage is to suppress a warning locally, and in this case, two
7648 pragmas must appear in sequence:
7649
7650
7651 .. code-block:: ada
7652
7653 pragma Warnings (Off, Pattern);
7654 ... code where given warning is to be suppressed
7655 pragma Warnings (On, Pattern);
7656
7657
7658 In this usage, the pattern string must match in the Off and On
7659 pragmas, and (if *-gnatw.w* is given) at least one matching
7660 warning must be suppressed.
7661
7662 Note: if the ON form is not found, then the effect of the OFF form extends
7663 until the end of the file (pragma Warnings is purely textual, so its effect
7664 does not stop at the end of the enclosing scope).
7665
7666 Note: to write a string that will match any warning, use the string
7667 ``"***"``. It will not work to use a single asterisk or two
7668 asterisks since this looks like an operator name. This form with three
7669 asterisks is similar in effect to specifying ``pragma Warnings (Off)`` except (if :switch:`-gnatw.w` is given) that a matching
7670 ``pragma Warnings (On, "***")`` will be required. This can be
7671 helpful in avoiding forgetting to turn warnings back on.
7672
7673 Note: the debug flag :switch:`-gnatd.i` can be
7674 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7675 be useful in checking whether obsolete pragmas in existing programs are hiding
7676 real problems.
7677
7678 Note: pragma Warnings does not affect the processing of style messages. See
7679 separate entry for pragma Style_Checks for control of style messages.
7680
7681 Users of the formal verification tool GNATprove for the SPARK subset of Ada may
7682 use the version of the pragma with a ``TOOL_NAME`` parameter.
7683
7684 If present, ``TOOL_NAME`` is the name of a tool, currently either ``GNAT`` for the
7685 compiler or ``GNATprove`` for the formal verification tool. A given tool only
7686 takes into account pragma Warnings that do not specify a tool name, or that
7687 specify the matching tool name. This makes it possible to disable warnings
7688 selectively for each tool, and as a consequence to detect useless pragma
7689 Warnings with switch :switch:`-gnatw.w`.
7690
7691 Pragma Weak_External
7692 ====================
7693
7694 Syntax:
7695
7696
7697 .. code-block:: ada
7698
7699 pragma Weak_External ([Entity =>] LOCAL_NAME);
7700
7701
7702 ``LOCAL_NAME`` must refer to an object that is declared at the library
7703 level. This pragma specifies that the given entity should be marked as a
7704 weak symbol for the linker. It is equivalent to ``__attribute__((weak))``
7705 in GNU C and causes ``LOCAL_NAME`` to be emitted as a weak symbol instead
7706 of a regular symbol, that is to say a symbol that does not have to be
7707 resolved by the linker if used in conjunction with a pragma Import.
7708
7709 When a weak symbol is not resolved by the linker, its address is set to
7710 zero. This is useful in writing interfaces to external modules that may
7711 or may not be linked in the final executable, for example depending on
7712 configuration settings.
7713
7714 If a program references at run time an entity to which this pragma has been
7715 applied, and the corresponding symbol was not resolved at link time, then
7716 the execution of the program is erroneous. It is not erroneous to take the
7717 Address of such an entity, for example to guard potential references,
7718 as shown in the example below.
7719
7720 Some file formats do not support weak symbols so not all target machines
7721 support this pragma.
7722
7723
7724 .. code-block:: ada
7725
7726 -- Example of the use of pragma Weak_External
7727
7728 package External_Module is
7729 key : Integer;
7730 pragma Import (C, key);
7731 pragma Weak_External (key);
7732 function Present return boolean;
7733 end External_Module;
7734
7735 with System; use System;
7736 package body External_Module is
7737 function Present return boolean is
7738 begin
7739 return key'Address /= System.Null_Address;
7740 end Present;
7741 end External_Module;
7742
7743
7744 Pragma Wide_Character_Encoding
7745 ==============================
7746
7747 Syntax:
7748
7749
7750 .. code-block:: ada
7751
7752 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7753
7754
7755 This pragma specifies the wide character encoding to be used in program
7756 source text appearing subsequently. It is a configuration pragma, but may
7757 also be used at any point that a pragma is allowed, and it is permissible
7758 to have more than one such pragma in a file, allowing multiple encodings
7759 to appear within the same file.
7760
7761 However, note that the pragma cannot immediately precede the relevant
7762 wide character, because then the previous encoding will still be in
7763 effect, causing "illegal character" errors.
7764
7765 The argument can be an identifier or a character literal. In the identifier
7766 case, it is one of ``HEX``, ``UPPER``, ``SHIFT_JIS``,
7767 ``EUC``, ``UTF8``, or ``BRACKETS``. In the character literal
7768 case it is correspondingly one of the characters :kbd:`h`, :kbd:`u`,
7769 :kbd:`s`, :kbd:`e`, :kbd:`8`, or :kbd:`b`.
7770
7771 Note that when the pragma is used within a file, it affects only the
7772 encoding within that file, and does not affect withed units, specs,
7773 or subunits.