2015-02-20 Arnaud Charlet <charlet@adacore.com>
[official-gcc.git] / gcc / ada / doc / gnat_rm / implementation_defined_pragmas.rst
bloba1147adca1c1ad7dc3fc44f1fb7a7e6d686bc008
1 .. _Implementation_Defined_Pragmas:
3 ******************************
4 Implementation Defined Pragmas
5 ******************************
7 Ada defines a set of pragmas that can be used to supply additional
8 information to the compiler.  These language defined pragmas are
9 implemented in GNAT and work as described in the Ada Reference Manual.
11 In addition, Ada allows implementations to define additional pragmas
12 whose meaning is defined by the implementation.  GNAT provides a number
13 of these implementation-defined pragmas, which can be used to extend
14 and enhance the functionality of the compiler.  This section of the GNAT
15 Reference Manual describes these additional pragmas.
17 Note that any program using these pragmas might not be portable to other
18 compilers (although GNAT implements this set of pragmas on all
19 platforms).  Therefore if portability to other compilers is an important
20 consideration, the use of these pragmas should be minimized.
22 Pragma Abort_Defer
23 ==================
25 .. index:: Deferring aborts
27 Syntax:
29 .. code-block:: ada
31   pragma Abort_Defer;
34 This pragma must appear at the start of the statement sequence of a
35 handled sequence of statements (right after the `begin`).  It has
36 the effect of deferring aborts for the sequence of statements (but not
37 for the declarations or handlers, if any, associated with this statement
38 sequence).
40 Pragma Abstract_State
41 =====================
43 For the description of this pragma, see SPARK 2014 Reference Manual,
44 section 7.1.4.
46 Pragma Ada_83
47 =============
49 Syntax:
51 .. code-block:: ada
53   pragma Ada_83;
56 A configuration pragma that establishes Ada 83 mode for the unit to
57 which it applies, regardless of the mode set by the command line
58 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
59 the syntax and semantics of Ada 83, as defined in the original Ada
60 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
61 and Ada 2005 are not recognized, optional package bodies are allowed,
62 and generics may name types with unknown discriminants without using
63 the `(<>)` notation.  In addition, some but not all of the additional
64 restrictions of Ada 83 are enforced.
66 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
67 Ada 83 code to be compiled and adapted to GNAT with less effort.
68 Secondly, it aids in keeping code backwards compatible with Ada 83.
69 However, there is no guarantee that code that is processed correctly
70 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
71 83 compiler, since GNAT does not enforce all the additional checks
72 required by Ada 83.
74 Pragma Ada_95
75 =============
77 Syntax:
79 .. code-block:: ada
81   pragma Ada_95;
84 A configuration pragma that establishes Ada 95 mode for the unit to which
85 it applies, regardless of the mode set by the command line switches.
86 This mode is set automatically for the `Ada` and `System`
87 packages and their children, so you need not specify it in these
88 contexts.  This pragma is useful when writing a reusable component that
89 itself uses Ada 95 features, but which is intended to be usable from
90 either Ada 83 or Ada 95 programs.
92 Pragma Ada_05
93 =============
95 Syntax:
97 .. code-block:: ada
99   pragma Ada_05;
100   pragma Ada_05 (local_NAME);
103 A configuration pragma that establishes Ada 2005 mode for the unit to which
104 it applies, regardless of the mode set by the command line switches.
105 This pragma is useful when writing a reusable component that
106 itself uses Ada 2005 features, but which is intended to be usable from
107 either Ada 83 or Ada 95 programs.
109 The one argument form (which is not a configuration pragma)
110 is used for managing the transition from
111 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
112 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
113 mode will generate a warning. In addition, in Ada_83 or Ada_95
114 mode, a preference rule is established which does not choose
115 such an entity unless it is unambiguously specified. This avoids
116 extra subprograms marked this way from generating ambiguities in
117 otherwise legal pre-Ada_2005 programs. The one argument form is
118 intended for exclusive use in the GNAT run-time library.
120 Pragma Ada_2005
121 ===============
123 Syntax:
125 .. code-block:: ada
127   pragma Ada_2005;
130 This configuration pragma is a synonym for pragma Ada_05 and has the
131 same syntax and effect.
133 Pragma Ada_12
134 =============
136 Syntax:
138 .. code-block:: ada
140   pragma Ada_12;
141   pragma Ada_12 (local_NAME);
144 A configuration pragma that establishes Ada 2012 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 2012 features, but which is intended to be usable from
150 Ada 83, Ada 95, or Ada 2005 programs.
152 The one argument form, which is not a configuration pragma,
153 is used for managing the transition from Ada
154 2005 to Ada 2012 in the run-time library. If an entity is marked
155 as Ada_201 only, then referencing the entity in any pre-Ada_2012
156 mode will generate a warning. In addition, in any pre-Ada_2012
157 mode, a preference rule is established which does not choose
158 such an entity unless it is unambiguously specified. This avoids
159 extra subprograms marked this way from generating ambiguities in
160 otherwise legal pre-Ada_2012 programs. The one argument form is
161 intended for exclusive use in the GNAT run-time library.
163 Pragma Ada_2012
164 ===============
166 Syntax:
168 .. code-block:: ada
170   pragma Ada_2012;
173 This configuration pragma is a synonym for pragma Ada_12 and has the
174 same syntax and effect.
176 Pragma Allow_Integer_Address
177 ============================
179 Syntax:
181 .. code-block:: ada
183   pragma Allow_Integer_Address;
186 In almost all versions of GNAT, `System.Address` is a private
187 type in accordance with the implementation advice in the RM. This
188 means that integer values,
189 in particular integer literals, are not allowed as address values.
190 If the configuration pragma
191 `Allow_Integer_Address` is given, then integer expressions may
192 be used anywhere a value of type `System.Address` is required.
193 The effect is to introduce an implicit unchecked conversion from the
194 integer value to type `System.Address`. The reverse case of using
195 an address where an integer type is required is handled analogously.
196 The following example compiles without errors:
199 .. code-block:: ada
201   pragma Allow_Integer_Address;
202   with System; use System;
203   package AddrAsInt is
204      X : Integer;
205      Y : Integer;
206      for X'Address use 16#1240#;
207      for Y use at 16#3230#;
208      m : Address := 16#4000#;
209      n : constant Address := 4000;
210      p : constant Address := Address (X + Y);
211      v : Integer := y'Address;
212      w : constant Integer := Integer (Y'Address);
213      type R is new integer;
214      RR : R := 1000;
215      Z : Integer;
216      for Z'Address use RR;
217   end AddrAsInt;
220 Note that pragma `Allow_Integer_Address` is ignored if `System.Address`
221 is not a private type. In implementations of `GNAT` where
222 System.Address is a visible integer type,
223 this pragma serves no purpose but is ignored
224 rather than rejected to allow common sets of sources to be used
225 in the two situations.
227 Pragma Annotate
228 ===============
230 Syntax::
232   pragma Annotate (IDENTIFIER [, IDENTIFIER {, ARG}] [, entity => local_NAME]);
234   ARG ::= NAME | EXPRESSION
237 This pragma is used to annotate programs.  `identifier` identifies
238 the type of annotation.  GNAT verifies that it is an identifier, but does
239 not otherwise analyze it. The second optional identifier is also left
240 unanalyzed, and by convention is used to control the action of the tool to
241 which the annotation is addressed.  The remaining `arg` arguments
242 can be either string literals or more generally expressions.
243 String literals are assumed to be either of type
244 `Standard.String` or else `Wide_String` or `Wide_Wide_String`
245 depending on the character literals they contain.
246 All other kinds of arguments are analyzed as expressions, and must be
247 unambiguous. The last argument if present must have the identifier
248 `Entity` and GNAT verifies that a local name is given.
250 The analyzed pragma is retained in the tree, but not otherwise processed
251 by any part of the GNAT compiler, except to generate corresponding note
252 lines in the generated ALI file. For the format of these note lines, see
253 the compiler source file lib-writ.ads. This pragma is intended for use by
254 external tools, including ASIS. The use of pragma Annotate does not
255 affect the compilation process in any way. This pragma may be used as
256 a configuration pragma.
258 Pragma Assert
259 =============
261 Syntax::
263   pragma Assert (
264     boolean_EXPRESSION
265     [, string_EXPRESSION]);
268 The effect of this pragma depends on whether the corresponding command
269 line switch is set to activate assertions.  The pragma expands into code
270 equivalent to the following:
272 .. code-block:: ada
274   if assertions-enabled then
275      if not boolean_EXPRESSION then
276         System.Assertions.Raise_Assert_Failure
277           (string_EXPRESSION);
278      end if;
279   end if;
282 The string argument, if given, is the message that will be associated
283 with the exception occurrence if the exception is raised.  If no second
284 argument is given, the default message is `file`:`nnn`,
285 where `file` is the name of the source file containing the assert,
286 and `nnn` is the line number of the assert.  A pragma is not a
287 statement, so if a statement sequence contains nothing but a pragma
288 assert, then a null statement is required in addition, as in:
290 .. code-block:: ada
292   ...
293   if J > 3 then
294      pragma Assert (K > 3, "Bad value for K");
295      null;
296   end if;
299 Note that, as with the `if` statement to which it is equivalent, the
300 type of the expression is either `Standard.Boolean`, or any type derived
301 from this standard type.
303 Assert checks can be either checked or ignored. By default they are ignored.
304 They will be checked if either the command line switch *-gnata* is
305 used, or if an `Assertion_Policy` or `Check_Policy` pragma is used
306 to enable `Assert_Checks`.
308 If assertions are ignored, then there
309 is no run-time effect (and in particular, any side effects from the
310 expression will not occur at run time).  (The expression is still
311 analyzed at compile time, and may cause types to be frozen if they are
312 mentioned here for the first time).
314 If assertions are checked, then the given expression is tested, and if
315 it is `False` then `System.Assertions.Raise_Assert_Failure` is called
316 which results in the raising of `Assert_Failure` with the given message.
318 You should generally avoid side effects in the expression arguments of
319 this pragma, because these side effects will turn on and off with the
320 setting of the assertions mode, resulting in assertions that have an
321 effect on the program.  However, the expressions are analyzed for
322 semantic correctness whether or not assertions are enabled, so turning
323 assertions on and off cannot affect the legality of a program.
325 Note that the implementation defined policy `DISABLE`, given in a
326 pragma `Assertion_Policy`, can be used to suppress this semantic analysis.
328 Note: this is a standard language-defined pragma in versions
329 of Ada from 2005 on. In GNAT, it is implemented in all versions
330 of Ada, and the DISABLE policy is an implementation-defined
331 addition.
333 Pragma Assert_And_Cut
334 =====================
336 Syntax::
338   pragma Assert_And_Cut (
339     boolean_EXPRESSION
340     [, string_EXPRESSION]);
343 The effect of this pragma is identical to that of pragma `Assert`,
344 except that in an `Assertion_Policy` pragma, the identifier
345 `Assert_And_Cut` is used to control whether it is ignored or checked
346 (or disabled).
348 The intention is that this be used within a subprogram when the
349 given test expresion sums up all the work done so far in the
350 subprogram, so that the rest of the subprogram can be verified
351 (informally or formally) using only the entry preconditions,
352 and the expression in this pragma. This allows dividing up
353 a subprogram into sections for the purposes of testing or
354 formal verification. The pragma also serves as useful
355 documentation.
357 Pragma Assertion_Policy
358 =======================
360 Syntax::
362   pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
364   pragma Assertion_Policy (
365       ASSERTION_KIND => POLICY_IDENTIFIER
366    {, ASSERTION_KIND => POLICY_IDENTIFIER});
368   ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
370   RM_ASSERTION_KIND ::= Assert               |
371                         Static_Predicate     |
372                         Dynamic_Predicate    |
373                         Pre                  |
374                         Pre'Class            |
375                         Post                 |
376                         Post'Class           |
377                         Type_Invariant       |
378                         Type_Invariant'Class
380   ID_ASSERTION_KIND ::= Assertions           |
381                         Assert_And_Cut       |
382                         Assume               |
383                         Contract_Cases       |
384                         Debug                |
385                         Invariant            |
386                         Invariant'Class      |
387                         Loop_Invariant       |
388                         Loop_Variant         |
389                         Postcondition        |
390                         Precondition         |
391                         Predicate            |
392                         Refined_Post         |
393                         Statement_Assertions
395   POLICY_IDENTIFIER ::= Check | Disable | Ignore
398 This is a standard Ada 2012 pragma that is available as an
399 implementation-defined pragma in earlier versions of Ada.
400 The assertion kinds `RM_ASSERTION_KIND` are those defined in
401 the Ada standard. The assertion kinds `ID_ASSERTION_KIND`
402 are implementation defined additions recognized by the GNAT compiler.
404 The pragma applies in both cases to pragmas and aspects with matching
405 names, e.g. `Pre` applies to the Pre aspect, and `Precondition`
406 applies to both the `Precondition` pragma
407 and the aspect `Precondition`. Note that the identifiers for
408 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
409 Pre_Class and Post_Class), since these pragmas are intended to be
410 identical to the corresponding aspects).
412 If the policy is `CHECK`, then assertions are enabled, i.e.
413 the corresponding pragma or aspect is activated.
414 If the policy is `IGNORE`, then assertions are ignored, i.e.
415 the corresponding pragma or aspect is deactivated.
416 This pragma overrides the effect of the *-gnata* switch on the
417 command line.
419 The implementation defined policy `DISABLE` is like
420 `IGNORE` except that it completely disables semantic
421 checking of the corresponding pragma or aspect. This is
422 useful when the pragma or aspect argument references subprograms
423 in a with'ed package which is replaced by a dummy package
424 for the final build.
426 The implementation defined assertion kind `Assertions` applies to all
427 assertion kinds. The form with no assertion kind given implies this
428 choice, so it applies to all assertion kinds (RM defined, and
429 implementation defined).
431 The implementation defined assertion kind `Statement_Assertions`
432 applies to `Assert`, `Assert_And_Cut`,
433 `Assume`, `Loop_Invariant`, and `Loop_Variant`.
435 Pragma Assume
436 =============
438 Syntax:
442   pragma Assume (
443     boolean_EXPRESSION
444     [, string_EXPRESSION]);
447 The effect of this pragma is identical to that of pragma `Assert`,
448 except that in an `Assertion_Policy` pragma, the identifier
449 `Assume` is used to control whether it is ignored or checked
450 (or disabled).
452 The intention is that this be used for assumptions about the
453 external environment. So you cannot expect to verify formally
454 or informally that the condition is met, this must be
455 established by examining things outside the program itself.
456 For example, we may have code that depends on the size of
457 `Long_Long_Integer` being at least 64. So we could write:
459 .. code-block:: ada
461   pragma Assume (Long_Long_Integer'Size >= 64);
464 This assumption cannot be proved from the program itself,
465 but it acts as a useful run-time check that the assumption
466 is met, and documents the need to ensure that it is met by
467 reference to information outside the program.
469 Pragma Assume_No_Invalid_Values
470 ===============================
471 .. index:: Invalid representations
473 .. index:: Invalid values
475 Syntax:
477 .. code-block:: ada
479   pragma Assume_No_Invalid_Values (On | Off);
482 This is a configuration pragma that controls the assumptions made by the
483 compiler about the occurrence of invalid representations (invalid values)
484 in the code.
486 The default behavior (corresponding to an Off argument for this pragma), is
487 to assume that values may in general be invalid unless the compiler can
488 prove they are valid. Consider the following example:
490 .. code-block:: ada
492   V1 : Integer range 1 .. 10;
493   V2 : Integer range 11 .. 20;
494   ...
495   for J in V2 .. V1 loop
496      ...
497   end loop;
500 if V1 and V2 have valid values, then the loop is known at compile
501 time not to execute since the lower bound must be greater than the
502 upper bound. However in default mode, no such assumption is made,
503 and the loop may execute. If `Assume_No_Invalid_Values (On)`
504 is given, the compiler will assume that any occurrence of a variable
505 other than in an explicit `'Valid` test always has a valid
506 value, and the loop above will be optimized away.
508 The use of `Assume_No_Invalid_Values (On)` is appropriate if
509 you know your code is free of uninitialized variables and other
510 possible sources of invalid representations, and may result in
511 more efficient code. A program that accesses an invalid representation
512 with this pragma in effect is erroneous, so no guarantees can be made
513 about its behavior.
515 It is peculiar though permissible to use this pragma in conjunction
516 with validity checking (-gnatVa). In such cases, accessing invalid
517 values will generally give an exception, though formally the program
518 is erroneous so there are no guarantees that this will always be the
519 case, and it is recommended that these two options not be used together.
521 Pragma Async_Readers
522 ====================
524 For the description of this pragma, see SPARK 2014 Reference Manual,
525 section 7.1.2.
527 Pragma Async_Writers
528 ====================
530 For the description of this pragma, see SPARK 2014 Reference Manual,
531 section 7.1.2.
533 Pragma Attribute_Definition
534 ===========================
536 Syntax:
540   pragma Attribute_Definition
541     ([Attribute  =>] ATTRIBUTE_DESIGNATOR,
542      [Entity     =>] LOCAL_NAME,
543      [Expression =>] EXPRESSION | NAME);
546 If `Attribute` is a known attribute name, this pragma is equivalent to
547 the attribute definition clause:
550 .. code-block:: ada
552     for Entity'Attribute use Expression;
555 If `Attribute` is not a recognized attribute name, the pragma is
556 ignored, and a warning is emitted. This allows source
557 code to be written that takes advantage of some new attribute, while remaining
558 compilable with earlier compilers.
560 Pragma C_Pass_By_Copy
561 =====================
562 .. index:: Passing by copy
565 Syntax:
569   pragma C_Pass_By_Copy
570     ([Max_Size =>] static_integer_EXPRESSION);
573 Normally the default mechanism for passing C convention records to C
574 convention subprograms is to pass them by reference, as suggested by RM
575 B.3(69).  Use the configuration pragma `C_Pass_By_Copy` to change
576 this default, by requiring that record formal parameters be passed by
577 copy if all of the following conditions are met:
580   The size of the record type does not exceed the value specified for
581   `Max_Size`.
583   The record type has `Convention C`.
585   The formal parameter has this record type, and the subprogram has a
586   foreign (non-Ada) convention.
588 If these conditions are met the argument is passed by copy; i.e., in a
589 manner consistent with what C expects if the corresponding formal in the
590 C prototype is a struct (rather than a pointer to a struct).
592 You can also pass records by copy by specifying the convention
593 `C_Pass_By_Copy` for the record type, or by using the extended
594 `Import` and `Export` pragmas, which allow specification of
595 passing mechanisms on a parameter by parameter basis.
597 Pragma Check
598 ============
599 .. index:: Assertions
601 .. index:: Named assertions
604 Syntax:
608   pragma Check (
609        [Name    =>] CHECK_KIND,
610        [Check   =>] Boolean_EXPRESSION
611     [, [Message =>] string_EXPRESSION] );
613   CHECK_KIND ::= IDENTIFIER           |
614                  Pre'Class            |
615                  Post'Class           |
616                  Type_Invariant'Class |
617                  Invariant'Class
620 This pragma is similar to the predefined pragma `Assert` except that an
621 extra identifier argument is present. In conjunction with pragma
622 `Check_Policy`, this can be used to define groups of assertions that can
623 be independently controlled. The identifier `Assertion` is special, it
624 refers to the normal set of pragma `Assert` statements.
626 Checks introduced by this pragma are normally deactivated by default. They can
627 be activated either by the command line option *-gnata*, which turns on
628 all checks, or individually controlled using pragma `Check_Policy`.
630 The identifiers `Assertions` and `Statement_Assertions` are not
631 permitted as check kinds, since this would cause confusion with the use
632 of these identifiers in `Assertion_Policy` and `Check_Policy`
633 pragmas, where they are used to refer to sets of assertions.
635 Pragma Check_Float_Overflow
636 ===========================
637 .. index:: Floating-point overflow
640 Syntax:
642 .. code-block:: ada
644   pragma Check_Float_Overflow;
647 In Ada, the predefined floating-point types (`Short_Float`,
648 `Float`, `Long_Float`, `Long_Long_Float`) are
649 defined to be *unconstrained*. This means that even though each
650 has a well-defined base range, an operation that delivers a result
651 outside this base range is not required to raise an exception.
652 This implementation permission accommodates the notion
653 of infinities in IEEE floating-point, and corresponds to the
654 efficient execution mode on most machines. GNAT will not raise
655 overflow exceptions on these machines; instead it will generate
656 infinities and NaN's as defined in the IEEE standard.
658 Generating infinities, although efficient, is not always desirable.
659 Often the preferable approach is to check for overflow, even at the
660 (perhaps considerable) expense of run-time performance.
661 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
662 range constraints -- and indeed such a subtype
663 can have the same base range as its base type. For example:
666 .. code-block:: ada
668   subtype My_Float is Float range Float'Range;
671 Here `My_Float` has the same range as
672 `Float` but is constrained, so operations on
673 `My_Float` values will be checked for overflow
674 against this range.
676 This style will achieve the desired goal, but
677 it is often more convenient to be able to simply use
678 the standard predefined floating-point types as long
679 as overflow checking could be guaranteed.
680 The `Check_Float_Overflow`
681 configuration pragma achieves this effect. If a unit is compiled
682 subject to this configuration pragma, then all operations
683 on predefined floating-point types including operations on
684 base types of these floating-point types will be treated as
685 though those types were constrained, and overflow checks
686 will be generated. The `Constraint_Error`
687 exception is raised if the result is out of range.
689 This mode can also be set by use of the compiler
690 switch *-gnateF*.
692 Pragma Check_Name
693 =================
694 .. index:: Defining check names
696 .. index:: Check names, defining
699 Syntax:
701 .. code-block:: ada
703   pragma Check_Name (check_name_IDENTIFIER);
706 This is a configuration pragma that defines a new implementation
707 defined check name (unless IDENTIFIER matches one of the predefined
708 check names, in which case the pragma has no effect). Check names
709 are global to a partition, so if two or more configuration pragmas
710 are present in a partition mentioning the same name, only one new
711 check name is introduced.
713 An implementation defined check name introduced with this pragma may
714 be used in only three contexts: `pragma Suppress`,
715 `pragma Unsuppress`,
716 and as the prefix of a `Check_Name'Enabled` attribute reference. For
717 any of these three cases, the check name must be visible. A check
718 name is visible if it is in the configuration pragmas applying to
719 the current unit, or if it appears at the start of any unit that
720 is part of the dependency set of the current unit (e.g., units that
721 are mentioned in `with` clauses).
723 Check names introduced by this pragma are subject to control by compiler
724 switches (in particular -gnatp) in the usual manner.
726 Pragma Check_Policy
727 ===================
728 .. index:: Controlling assertions
730 .. index:: Assertions, control
732 .. index:: Check pragma control
734 .. index:: Named assertions
737 Syntax:
741   pragma Check_Policy
742    ([Name   =>] CHECK_KIND,
743     [Policy =>] POLICY_IDENTIFIER);
745   pragma Check_Policy (
746       CHECK_KIND => POLICY_IDENTIFIER
747    {, CHECK_KIND => POLICY_IDENTIFIER});
749   ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
751   CHECK_KIND ::= IDENTIFIER           |
752                  Pre'Class            |
753                  Post'Class           |
754                  Type_Invariant'Class |
755                  Invariant'Class
757   The identifiers Name and Policy are not allowed as CHECK_KIND values. This
758   avoids confusion between the two possible syntax forms for this pragma.
760   POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
763 This pragma is used to set the checking policy for assertions (specified
764 by aspects or pragmas), the `Debug` pragma, or additional checks
765 to be checked using the `Check` pragma. It may appear either as
766 a configuration pragma, or within a declarative part of package. In the
767 latter case, it applies from the point where it appears to the end of
768 the declarative region (like pragma `Suppress`).
770 The `Check_Policy` pragma is similar to the
771 predefined `Assertion_Policy` pragma,
772 and if the check kind corresponds to one of the assertion kinds that
773 are allowed by `Assertion_Policy`, then the effect is identical.
775 If the first argument is Debug, then the policy applies to Debug pragmas,
776 disabling their effect if the policy is `OFF`, `DISABLE`, or
777 `IGNORE`, and allowing them to execute with normal semantics if
778 the policy is `ON` or `CHECK`. In addition if the policy is
779 `DISABLE`, then the procedure call in `Debug` pragmas will
780 be totally ignored and not analyzed semantically.
782 Finally the first argument may be some other identifier than the above
783 possibilities, in which case it controls a set of named assertions
784 that can be checked using pragma `Check`. For example, if the pragma:
787 .. code-block:: ada
789   pragma Check_Policy (Critical_Error, OFF);
792 is given, then subsequent `Check` pragmas whose first argument is also
793 `Critical_Error` will be disabled.
795 The check policy is `OFF` to turn off corresponding checks, and `ON`
796 to turn on corresponding checks. The default for a set of checks for which no
797 `Check_Policy` is given is `OFF` unless the compiler switch
798 *-gnata* is given, which turns on all checks by default.
800 The check policy settings `CHECK` and `IGNORE` are recognized
801 as synonyms for `ON` and `OFF`. These synonyms are provided for
802 compatibility with the standard `Assertion_Policy` pragma. The check
803 policy setting `DISABLE` causes the second argument of a corresponding
804 `Check` pragma to be completely ignored and not analyzed.
806 Pragma CIL_Constructor
807 ======================
809 Syntax:
814   pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
817 This pragma is used to assert that the specified Ada function should be
818 mapped to the .NET constructor for some Ada tagged record type.
820 See section 4.1 of the
821 `GNAT User's Guide: Supplement for the .NET Platform.`
822 for related information.
824 Pragma Comment
825 ==============
827 Syntax:
830 .. code-block:: ada
832   pragma Comment (static_string_EXPRESSION);
835 This is almost identical in effect to pragma `Ident`.  It allows the
836 placement of a comment into the object file and hence into the
837 executable file if the operating system permits such usage.  The
838 difference is that `Comment`, unlike `Ident`, has
839 no limitations on placement of the pragma (it can be placed
840 anywhere in the main source unit), and if more than one pragma
841 is used, all comments are retained.
843 Pragma Common_Object
844 ====================
846 Syntax:
851   pragma Common_Object (
852        [Internal =>] LOCAL_NAME
853     [, [External =>] EXTERNAL_SYMBOL]
854     [, [Size     =>] EXTERNAL_SYMBOL] );
856   EXTERNAL_SYMBOL ::=
857     IDENTIFIER
858   | static_string_EXPRESSION
861 This pragma enables the shared use of variables stored in overlaid
862 linker areas corresponding to the use of `COMMON`
863 in Fortran.  The single
864 object `LOCAL_NAME` is assigned to the area designated by
865 the `External` argument.
866 You may define a record to correspond to a series
867 of fields.  The `Size` argument
868 is syntax checked in GNAT, but otherwise ignored.
870 `Common_Object` is not supported on all platforms.  If no
871 support is available, then the code generator will issue a message
872 indicating that the necessary attribute for implementation of this
873 pragma is not available.
875 Pragma Compile_Time_Error
876 =========================
878 Syntax:
881 .. code-block:: ada
883   pragma Compile_Time_Error
884            (boolean_EXPRESSION, static_string_EXPRESSION);
887 This pragma can be used to generate additional compile time
888 error messages. It
889 is particularly useful in generics, where errors can be issued for
890 specific problematic instantiations. The first parameter is a boolean
891 expression. The pragma is effective only if the value of this expression
892 is known at compile time, and has the value True. The set of expressions
893 whose values are known at compile time includes all static boolean
894 expressions, and also other values which the compiler can determine
895 at compile time (e.g., the size of a record type set by an explicit
896 size representation clause, or the value of a variable which was
897 initialized to a constant and is known not to have been modified).
898 If these conditions are met, an error message is generated using
899 the value given as the second argument. This string value may contain
900 embedded ASCII.LF characters to break the message into multiple lines.
902 Pragma Compile_Time_Warning
903 ===========================
905 Syntax:
908 .. code-block:: ada
910   pragma Compile_Time_Warning
911            (boolean_EXPRESSION, static_string_EXPRESSION);
914 Same as pragma Compile_Time_Error, except a warning is issued instead
915 of an error message. Note that if this pragma is used in a package that
916 is with'ed by a client, the client will get the warning even though it
917 is issued by a with'ed package (normally warnings in with'ed units are
918 suppressed, but this is a special exception to that rule).
920 One typical use is within a generic where compile time known characteristics
921 of formal parameters are tested, and warnings given appropriately. Another use
922 with a first parameter of True is to warn a client about use of a package,
923 for example that it is not fully implemented.
925 Pragma Compiler_Unit
926 ====================
928 Syntax:
931 .. code-block:: ada
933   pragma Compiler_Unit;
936 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
937 retained so that old versions of the GNAT run-time that use this pragma can
938 be compiled with newer versions of the compiler.
940 Pragma Compiler_Unit_Warning
941 ============================
943 Syntax:
946 .. code-block:: ada
948   pragma Compiler_Unit_Warning;
951 This pragma is intended only for internal use in the GNAT run-time library.
952 It indicates that the unit is used as part of the compiler build. The effect
953 is to generate warnings for the use of constructs (for example, conditional
954 expressions) that would cause trouble when bootstrapping using an older
955 version of GNAT. For the exact list of restrictions, see the compiler sources
956 and references to Check_Compiler_Unit.
958 Pragma Complete_Representation
959 ==============================
961 Syntax:
964 .. code-block:: ada
966   pragma Complete_Representation;
969 This pragma must appear immediately within a record representation
970 clause. Typical placements are before the first component clause
971 or after the last component clause. The effect is to give an error
972 message if any component is missing a component clause. This pragma
973 may be used to ensure that a record representation clause is
974 complete, and that this invariant is maintained if fields are
975 added to the record in the future.
977 Pragma Complex_Representation
978 =============================
980 Syntax:
985   pragma Complex_Representation
986           ([Entity =>] LOCAL_NAME);
989 The `Entity` argument must be the name of a record type which has
990 two fields of the same floating-point type.  The effect of this pragma is
991 to force gcc to use the special internal complex representation form for
992 this record, which may be more efficient.  Note that this may result in
993 the code for this type not conforming to standard ABI (application
994 binary interface) requirements for the handling of record types.  For
995 example, in some environments, there is a requirement for passing
996 records by pointer, and the use of this pragma may result in passing
997 this type in floating-point registers.
999 Pragma Component_Alignment
1000 ==========================
1001 .. index:: Alignments of components
1002 .. index:: Pragma Component_Alignment
1005 Syntax:
1009   pragma Component_Alignment (
1010        [Form =>] ALIGNMENT_CHOICE
1011     [, [Name =>] type_LOCAL_NAME]);
1013   ALIGNMENT_CHOICE ::=
1014     Component_Size
1015   | Component_Size_4
1016   | Storage_Unit
1017   | Default
1020 Specifies the alignment of components in array or record types.
1021 The meaning of the `Form` argument is as follows:
1024   .. index:: Component_Size (in pragma Component_Alignment)
1026 *Component_Size*
1027   Aligns scalar components and subcomponents of the array or record type
1028   on boundaries appropriate to their inherent size (naturally
1029   aligned).  For example, 1-byte components are aligned on byte boundaries,
1030   2-byte integer components are aligned on 2-byte boundaries, 4-byte
1031   integer components are aligned on 4-byte boundaries and so on.  These
1032   alignment rules correspond to the normal rules for C compilers on all
1033   machines except the VAX.
1035   .. index:: Component_Size_4 (in pragma Component_Alignment)
1037 *Component_Size_4*
1038   Naturally aligns components with a size of four or fewer
1039   bytes.  Components that are larger than 4 bytes are placed on the next
1040   4-byte boundary.
1042   .. index:: Storage_Unit (in pragma Component_Alignment)
1044 *Storage_Unit*
1045   Specifies that array or record components are byte aligned, i.e.,
1046   aligned on boundaries determined by the value of the constant
1047   `System.Storage_Unit`.
1049   .. index:: Default (in pragma Component_Alignment)
1051 *Default*
1052   Specifies that array or record components are aligned on default
1053   boundaries, appropriate to the underlying hardware or operating system or
1054   both. The `Default` choice is the same as `Component_Size` (natural
1055   alignment).
1057 If the `Name` parameter is present, `type_LOCAL_NAME` must
1058 refer to a local record or array type, and the specified alignment
1059 choice applies to the specified type.  The use of
1060 `Component_Alignment` together with a pragma `Pack` causes the
1061 `Component_Alignment` pragma to be ignored.  The use of
1062 `Component_Alignment` together with a record representation clause
1063 is only effective for fields not specified by the representation clause.
1065 If the `Name` parameter is absent, the pragma can be used as either
1066 a configuration pragma, in which case it applies to one or more units in
1067 accordance with the normal rules for configuration pragmas, or it can be
1068 used within a declarative part, in which case it applies to types that
1069 are declared within this declarative part, or within any nested scope
1070 within this declarative part.  In either case it specifies the alignment
1071 to be applied to any record or array type which has otherwise standard
1072 representation.
1074 If the alignment for a record or array type is not specified (using
1075 pragma `Pack`, pragma `Component_Alignment`, or a record rep
1076 clause), the GNAT uses the default alignment as described previously.
1078 Pragma Contract_Cases
1079 =====================
1080 .. index:: Contract cases
1083 Syntax:
1088   pragma Contract_Cases (
1089      Condition => Consequence
1090    {,Condition => Consequence});
1093 The `Contract_Cases` pragma allows defining fine-grain specifications
1094 that can complement or replace the contract given by a precondition and a
1095 postcondition. Additionally, the `Contract_Cases` pragma can be used
1096 by testing and formal verification tools. The compiler checks its validity and,
1097 depending on the assertion policy at the point of declaration of the pragma,
1098 it may insert a check in the executable. For code generation, the contract
1099 cases
1102 .. code-block:: ada
1104   pragma Contract_Cases (
1105     Cond1 => Pred1,
1106     Cond2 => Pred2);
1109 are equivalent to
1112 .. code-block:: ada
1114   C1 : constant Boolean := Cond1;  --  evaluated at subprogram entry
1115   C2 : constant Boolean := Cond2;  --  evaluated at subprogram entry
1116   pragma Precondition ((C1 and not C2) or (C2 and not C1));
1117   pragma Postcondition (if C1 then Pred1);
1118   pragma Postcondition (if C2 then Pred2);
1121 The precondition ensures that one and only one of the conditions is
1122 satisfied on entry to the subprogram.
1123 The postcondition ensures that for the condition that was True on entry,
1124 the corrresponding consequence is True on exit. Other consequence expressions
1125 are not evaluated.
1127 A precondition `P` and postcondition `Q` can also be
1128 expressed as contract cases:
1130 .. code-block:: ada
1132   pragma Contract_Cases (P => Q);
1135 The placement and visibility rules for `Contract_Cases` pragmas are
1136 identical to those described for preconditions and postconditions.
1138 The compiler checks that boolean expressions given in conditions and
1139 consequences are valid, where the rules for conditions are the same as
1140 the rule for an expression in `Precondition` and the rules for
1141 consequences are the same as the rule for an expression in
1142 `Postcondition`. In particular, attributes `'Old` and
1143 `'Result` can only be used within consequence expressions.
1144 The condition for the last contract case may be `others`, to denote
1145 any case not captured by the previous cases. The
1146 following is an example of use within a package spec:
1149 .. code-block:: ada
1151   package Math_Functions is
1152      ...
1153      function Sqrt (Arg : Float) return Float;
1154      pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
1155                             Arg >= 100       => Sqrt'Result >= 10,
1156                             others           => Sqrt'Result = 0);
1157      ...
1158   end Math_Functions;
1161 The meaning of contract cases is that only one case should apply at each
1162 call, as determined by the corresponding condition evaluating to True,
1163 and that the consequence for this case should hold when the subprogram
1164 returns.
1166 Pragma Convention_Identifier
1167 ============================
1168 .. index:: Conventions, synonyms
1170 Syntax:
1175   pragma Convention_Identifier (
1176            [Name =>]       IDENTIFIER,
1177            [Convention =>] convention_IDENTIFIER);
1180 This pragma provides a mechanism for supplying synonyms for existing
1181 convention identifiers. The `Name` identifier can subsequently
1182 be used as a synonym for the given convention in other pragmas (including
1183 for example pragma `Import` or another `Convention_Identifier`
1184 pragma). As an example of the use of this, suppose you had legacy code
1185 which used Fortran77 as the identifier for Fortran. Then the pragma:
1188 .. code-block:: ada
1190   pragma Convention_Identifier (Fortran77, Fortran);
1193 would allow the use of the convention identifier `Fortran77` in
1194 subsequent code, avoiding the need to modify the sources. As another
1195 example, you could use this to parameterize convention requirements
1196 according to systems. Suppose you needed to use `Stdcall` on
1197 windows systems, and `C` on some other system, then you could
1198 define a convention identifier `Library` and use a single
1199 `Convention_Identifier` pragma to specify which convention
1200 would be used system-wide.
1202 Pragma CPP_Class
1203 ================
1204 .. index:: Interfacing with C++
1206 Syntax:
1211   pragma CPP_Class ([Entity =>] LOCAL_NAME);
1214 The argument denotes an entity in the current declarative region that is
1215 declared as a record type. It indicates that the type corresponds to an
1216 externally declared C++ class type, and is to be laid out the same way
1217 that C++ would lay out the type. If the C++ class has virtual primitives
1218 then the record must be declared as a tagged record type.
1220 Types for which `CPP_Class` is specified do not have assignment or
1221 equality operators defined (such operations can be imported or declared
1222 as subprograms as required). Initialization is allowed only by constructor
1223 functions (see pragma `CPP_Constructor`). Such types are implicitly
1224 limited if not explicitly declared as limited or derived from a limited
1225 type, and an error is issued in that case.
1227 See :ref:`Interfacing_to_C++` for related information.
1229 Note: Pragma `CPP_Class` is currently obsolete. It is supported
1230 for backward compatibility but its functionality is available
1231 using pragma `Import` with `Convention` = `CPP`.
1233 Pragma CPP_Constructor
1234 ======================
1235 .. index:: Interfacing with C++
1238 Syntax:
1243   pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1244     [, [External_Name =>] static_string_EXPRESSION ]
1245     [, [Link_Name     =>] static_string_EXPRESSION ]);
1248 This pragma identifies an imported function (imported in the usual way
1249 with pragma `Import`) as corresponding to a C++ constructor. If
1250 `External_Name` and `Link_Name` are not specified then the
1251 `Entity` argument is a name that must have been previously mentioned
1252 in a pragma `Import` with `Convention` = `CPP`. Such name
1253 must be of one of the following forms:
1256   **function** `Fname` **return** T`
1259   **function** `Fname` **return** T'Class
1262   **function** `Fname` (...) **return** T`
1265   **function** `Fname` (...) **return** T'Class
1267 where `T` is a limited record type imported from C++ with pragma
1268 `Import` and `Convention` = `CPP`.
1270 The first two forms import the default constructor, used when an object
1271 of type `T` is created on the Ada side with no explicit constructor.
1272 The latter two forms cover all the non-default constructors of the type.
1273 See the GNAT User's Guide for details.
1275 If no constructors are imported, it is impossible to create any objects
1276 on the Ada side and the type is implicitly declared abstract.
1278 Pragma `CPP_Constructor` is intended primarily for automatic generation
1279 using an automatic binding generator tool (such as the `-fdump-ada-spec`
1280 GCC switch).
1281 See :ref:`Interfacing_to_C++` for more related information.
1283 Note: The use of functions returning class-wide types for constructors is
1284 currently obsolete. They are supported for backward compatibility. The
1285 use of functions returning the type T leave the Ada sources more clear
1286 because the imported C++ constructors always return an object of type T;
1287 that is, they never return an object whose type is a descendant of type T.
1289 Pragma CPP_Virtual
1290 ==================
1291 .. index:: Interfacing to C++
1294 This pragma is now obsolete and, other than generating a warning if warnings
1295 on obsolescent features are enabled, is completely ignored.
1296 It is retained for compatibility
1297 purposes. It used to be required to ensure compoatibility with C++, but
1298 is no longer required for that purpose because GNAT generates
1299 the same object layout as the G++ compiler by default.
1301 See :ref:`Interfacing_to_C++` for related information.
1303 Pragma CPP_Vtable
1304 =================
1305 .. index:: Interfacing with C++
1308 This pragma is now obsolete and, other than generating a warning if warnings
1309 on obsolescent features are enabled, is completely ignored.
1310 It used to be required to ensure compatibility with C++, but
1311 is no longer required for that purpose because GNAT generates
1312 the same object layout as the G++ compiler by default.
1314 See :ref:`Interfacing_to_C++` for related information.
1316 Pragma CPU
1317 ==========
1319 Syntax:
1322 .. code-block:: ada
1324   pragma CPU (EXPRESSION);
1327 This pragma is standard in Ada 2012, but is available in all earlier
1328 versions of Ada as an implementation-defined pragma.
1329 See Ada 2012 Reference Manual for details.
1331 Pragma Debug
1332 ============
1334 Syntax:
1339   pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1341   PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1342     PROCEDURE_NAME
1343   | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1346 The procedure call argument has the syntactic form of an expression, meeting
1347 the syntactic requirements for pragmas.
1349 If debug pragmas are not enabled or if the condition is present and evaluates
1350 to False, this pragma has no effect. If debug pragmas are enabled, the
1351 semantics of the pragma is exactly equivalent to the procedure call statement
1352 corresponding to the argument with a terminating semicolon. Pragmas are
1353 permitted in sequences of declarations, so you can use pragma `Debug` to
1354 intersperse calls to debug procedures in the middle of declarations. Debug
1355 pragmas can be enabled either by use of the command line switch *-gnata*
1356 or by use of the pragma `Check_Policy` with a first argument of
1357 `Debug`.
1359 Pragma Debug_Policy
1360 ===================
1362 Syntax:
1365 .. code-block:: ada
1367   pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
1370 This pragma is equivalent to a corresponding `Check_Policy` pragma
1371 with a first argument of `Debug`. It is retained for historical
1372 compatibility reasons.
1374 Pragma Default_Scalar_Storage_Order
1375 ===================================
1376 .. index:: Default_Scalar_Storage_Order
1378 .. index:: Scalar_Storage_Order
1381 Syntax:
1384 .. code-block:: ada
1386   pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
1389 Normally if no explicit `Scalar_Storage_Order` is given for a record
1390 type or array type, then the scalar storage order defaults to the ordinary
1391 default for the target. But this default may be overridden using this pragma.
1392 The pragma may appear as a configuration pragma, or locally within a package
1393 spec or declarative part. In the latter case, it applies to all subsequent
1394 types declared within that package spec or declarative part.
1396 The following example shows the use of this pragma:
1399 .. code-block:: ada
1401   pragma Default_Scalar_Storage_Order (High_Order_First);
1402   with System; use System;
1403   package DSSO1 is
1404      type H1 is record
1405         a : Integer;
1406      end record;
1408      type L2 is record
1409         a : Integer;
1410      end record;
1411      for L2'Scalar_Storage_Order use Low_Order_First;
1413      type L2a is new L2;
1415      package Inner is
1416         type H3 is record
1417            a : Integer;
1418         end record;
1420         pragma Default_Scalar_Storage_Order (Low_Order_First);
1422         type L4 is record
1423            a : Integer;
1424         end record;
1425      end Inner;
1427      type H4a is new Inner.L4;
1429      type H5 is record
1430         a : Integer;
1431      end record;
1432   end DSSO1;
1435 In this example record types L.. have `Low_Order_First` scalar
1436 storage order, and record types H.. have `High_Order_First`.
1437 Note that in the case of `H4a`, the order is not inherited
1438 from the parent type. Only an explicitly set `Scalar_Storage_Order`
1439 gets inherited on type derivation.
1441 If this pragma is used as a configuration pragma which appears within a
1442 configuration pragma file (as opposed to appearing explicitly at the start
1443 of a single unit), then the binder will require that all units in a partition
1444 be compiled in a similar manner, other than run-time units, which are not
1445 affected by this pragma. Note that the use of this form is discouraged because
1446 it may significantly degrade the run-time performance of the software, instead
1447 the default scalar storage order ought to be changed only on a local basis.
1449 Pragma Default_Storage_Pool
1450 ===========================
1451 .. index:: Default_Storage_Pool
1454 Syntax:
1457 .. code-block:: ada
1459   pragma Default_Storage_Pool (storage_pool_NAME | null);
1462 This pragma is standard in Ada 2012, but is available in all earlier
1463 versions of Ada as an implementation-defined pragma.
1464 See Ada 2012 Reference Manual for details.
1466 Pragma Depends
1467 ==============
1469 For the description of this pragma, see SPARK 2014 Reference Manual,
1470 section 6.1.5.
1472 Pragma Detect_Blocking
1473 ======================
1475 Syntax:
1477 .. code-block:: ada
1479   pragma Detect_Blocking;
1482 This is a standard pragma in Ada 2005, that is available in all earlier
1483 versions of Ada as an implementation-defined pragma.
1485 This is a configuration pragma that forces the detection of potentially
1486 blocking operations within a protected operation, and to raise Program_Error
1487 if that happens.
1489 Pragma Disable_Atomic_Synchronization
1490 =====================================
1492 .. index:: Atomic Synchronization
1494 Syntax:
1498   pragma Disable_Atomic_Synchronization [(Entity)];
1501 Ada requires that accesses (reads or writes) of an atomic variable be
1502 regarded as synchronization points in the case of multiple tasks.
1503 Particularly in the case of multi-processors this may require special
1504 handling, e.g. the generation of memory barriers. This capability may
1505 be turned off using this pragma in cases where it is known not to be
1506 required.
1508 The placement and scope rules for this pragma are the same as those
1509 for `pragma Suppress`. In particular it can be used as a
1510 configuration  pragma, or in a declaration sequence where it applies
1511 till the end of the scope. If an `Entity` argument is present,
1512 the action applies only to that entity.
1514 Pragma Dispatching_Domain
1515 =========================
1517 Syntax:
1520 .. code-block:: ada
1522   pragma Dispatching_Domain (EXPRESSION);
1525 This pragma is standard in Ada 2012, but is available in all earlier
1526 versions of Ada as an implementation-defined pragma.
1527 See Ada 2012 Reference Manual for details.
1529 Pragma Effective_Reads
1530 ======================
1532 For the description of this pragma, see SPARK 2014 Reference Manual,
1533 section 7.1.2.
1535 Pragma Effective_Writes
1536 =======================
1538 For the description of this pragma, see SPARK 2014 Reference Manual,
1539 section 7.1.2.
1541 Pragma Elaboration_Checks
1542 =========================
1543 .. index:: Elaboration control
1546 Syntax:
1549 .. code-block:: ada
1551   pragma Elaboration_Checks (Dynamic | Static);
1554 This is a configuration pragma that provides control over the
1555 elaboration model used by the compilation affected by the
1556 pragma.  If the parameter is `Dynamic`,
1557 then the dynamic elaboration
1558 model described in the Ada Reference Manual is used, as though
1559 the *-gnatE* switch had been specified on the command
1560 line.  If the parameter is `Static`, then the default GNAT static
1561 model is used.  This configuration pragma overrides the setting
1562 of the command line.  For full details on the elaboration models
1563 used by the GNAT compiler, see the chapter on elaboration order handling
1564 in the *GNAT User's Guide*.
1566 Pragma Eliminate
1567 ================
1568 .. index:: Elimination of unused subprograms
1571 Syntax:
1576   pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
1577                     [Source_Location =>] STRING_LITERAL);
1580 The string literal given for the source location is a string which
1581 specifies the line number of the occurrence of the entity, using
1582 the syntax for SOURCE_TRACE given below:
1587    SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
1589    LBRACKET         ::= [
1590    RBRACKET         ::= ]
1592    SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1594    LINE_NUMBER      ::= DIGIT {DIGIT}
1597 Spaces around the colon in a `Source_Reference` are optional.
1599 The `DEFINING_DESIGNATOR` matches the defining designator used in an
1600 explicit subprogram declaration, where the `entity` name in this
1601 designator appears on the source line specified by the source location.
1603 The source trace that is given as the `Source_Location` shall obey the
1604 following rules. The `FILE_NAME` is the short name (with no directory
1605 information) of an Ada source file, given using exactly the required syntax
1606 for the underlying file system (e.g. case is important if the underlying
1607 operating system is case sensitive). `LINE_NUMBER` gives the line
1608 number of the occurrence of the `entity`
1609 as a decimal literal without an exponent or point. If an `entity` is not
1610 declared in a generic instantiation (this includes generic subprogram
1611 instances), the source trace includes only one source reference. If an entity
1612 is declared inside a generic instantiation, its source trace (when parsing
1613 from left to right) starts with the source location of the declaration of the
1614 entity in the generic unit and ends with the source location of the
1615 instantiation (it is given in square brackets). This approach is recursively
1616 used in case of nested instantiations: the rightmost (nested most deeply in
1617 square brackets) element of the source trace is the location of the outermost
1618 instantiation, the next to left element is the location of the next (first
1619 nested) instantiation in the code of the corresponding generic unit, and so
1620 on, and the leftmost element (that is out of any square brackets) is the
1621 location of the declaration of the entity to eliminate in a generic unit.
1623 Note that the `Source_Location` argument specifies which of a set of
1624 similarly named entities is being eliminated, dealing both with overloading,
1625 and also appearance of the same entity name in different scopes.
1627 This pragma indicates that the given entity is not used in the program to be
1628 compiled and built. The effect of the pragma is to allow the compiler to
1629 eliminate the code or data associated with the named entity. Any reference to
1630 an eliminated entity causes a compile-time or link-time error.
1632 The intention of pragma `Eliminate` is to allow a program to be compiled
1633 in a system-independent manner, with unused entities eliminated, without
1634 needing to modify the source text. Normally the required set of
1635 `Eliminate` pragmas is constructed automatically using the gnatelim tool.
1637 Any source file change that removes, splits, or
1638 adds lines may make the set of Eliminate pragmas invalid because their
1639 `Source_Location` argument values may get out of date.
1641 Pragma `Eliminate` may be used where the referenced entity is a dispatching
1642 operation. In this case all the subprograms to which the given operation can
1643 dispatch are considered to be unused (are never called as a result of a direct
1644 or a dispatching call).
1646 Pragma Enable_Atomic_Synchronization
1647 ====================================
1648 .. index:: Atomic Synchronization
1651 Syntax:
1656   pragma Enable_Atomic_Synchronization [(Entity)];
1659 Ada requires that accesses (reads or writes) of an atomic variable be
1660 regarded as synchronization points in the case of multiple tasks.
1661 Particularly in the case of multi-processors this may require special
1662 handling, e.g. the generation of memory barriers. This synchronization
1663 is performed by default, but can be turned off using
1664 `pragma Disable_Atomic_Synchronization`. The
1665 `Enable_Atomic_Synchronization` pragma can be used to turn
1666 it back on.
1668 The placement and scope rules for this pragma are the same as those
1669 for `pragma Unsuppress`. In particular it can be used as a
1670 configuration  pragma, or in a declaration sequence where it applies
1671 till the end of the scope. If an `Entity` argument is present,
1672 the action applies only to that entity.
1674 Pragma Export_Function
1675 ======================
1676 .. index:: Argument passing mechanisms
1679 Syntax:
1684   pragma Export_Function (
1685        [Internal         =>] LOCAL_NAME
1686     [, [External         =>] EXTERNAL_SYMBOL]
1687     [, [Parameter_Types  =>] PARAMETER_TYPES]
1688     [, [Result_Type      =>] result_SUBTYPE_MARK]
1689     [, [Mechanism        =>] MECHANISM]
1690     [, [Result_Mechanism =>] MECHANISM_NAME]);
1692   EXTERNAL_SYMBOL ::=
1693     IDENTIFIER
1694   | static_string_EXPRESSION
1695   | ""
1697   PARAMETER_TYPES ::=
1698     null
1699   | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
1701   TYPE_DESIGNATOR ::=
1702     subtype_NAME
1703   | subtype_Name ' Access
1705   MECHANISM ::=
1706     MECHANISM_NAME
1707   | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
1709   MECHANISM_ASSOCIATION ::=
1710     [formal_parameter_NAME =>] MECHANISM_NAME
1712   MECHANISM_NAME ::= Value | Reference
1715 Use this pragma to make a function externally callable and optionally
1716 provide information on mechanisms to be used for passing parameter and
1717 result values.  We recommend, for the purposes of improving portability,
1718 this pragma always be used in conjunction with a separate pragma
1719 `Export`, which must precede the pragma `Export_Function`.
1720 GNAT does not require a separate pragma `Export`, but if none is
1721 present, `Convention Ada` is assumed, which is usually
1722 not what is wanted, so it is usually appropriate to use this
1723 pragma in conjunction with a `Export` or `Convention`
1724 pragma that specifies the desired foreign convention.
1725 Pragma `Export_Function`
1726 (and `Export`, if present) must appear in the same declarative
1727 region as the function to which they apply.
1729 `internal_name` must uniquely designate the function to which the
1730 pragma applies.  If more than one function name exists of this name in
1731 the declarative part you must use the `Parameter_Types` and
1732 `Result_Type` parameters is mandatory to achieve the required
1733 unique designation.  `subtype_mark`s in these parameters must
1734 exactly match the subtypes in the corresponding function specification,
1735 using positional notation to match parameters with subtype marks.
1736 The form with an `'Access` attribute can be used to match an
1737 anonymous access parameter.
1739 .. index:: Suppressing external name
1741 Special treatment is given if the EXTERNAL is an explicit null
1742 string or a static string expressions that evaluates to the null
1743 string. In this case, no external name is generated. This form
1744 still allows the specification of parameter mechanisms.
1746 Pragma Export_Object
1747 ====================
1749 Syntax:
1754   pragma Export_Object
1755         [Internal =>] LOCAL_NAME
1756      [, [External =>] EXTERNAL_SYMBOL]
1757      [, [Size     =>] EXTERNAL_SYMBOL]
1759   EXTERNAL_SYMBOL ::=
1760     IDENTIFIER
1761   | static_string_EXPRESSION
1764 This pragma designates an object as exported, and apart from the
1765 extended rules for external symbols, is identical in effect to the use of
1766 the normal `Export` pragma applied to an object.  You may use a
1767 separate Export pragma (and you probably should from the point of view
1768 of portability), but it is not required.  `Size` is syntax checked,
1769 but otherwise ignored by GNAT.
1771 Pragma Export_Procedure
1772 =======================
1774 Syntax:
1779   pragma Export_Procedure (
1780        [Internal        =>] LOCAL_NAME
1781     [, [External        =>] EXTERNAL_SYMBOL]
1782     [, [Parameter_Types =>] PARAMETER_TYPES]
1783     [, [Mechanism       =>] MECHANISM]);
1785   EXTERNAL_SYMBOL ::=
1786     IDENTIFIER
1787   | static_string_EXPRESSION
1788   | ""
1790   PARAMETER_TYPES ::=
1791     null
1792   | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
1794   TYPE_DESIGNATOR ::=
1795     subtype_NAME
1796   | subtype_Name ' Access
1798   MECHANISM ::=
1799     MECHANISM_NAME
1800   | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
1802   MECHANISM_ASSOCIATION ::=
1803     [formal_parameter_NAME =>] MECHANISM_NAME
1805   MECHANISM_NAME ::= Value | Reference
1808 This pragma is identical to `Export_Function` except that it
1809 applies to a procedure rather than a function and the parameters
1810 `Result_Type` and `Result_Mechanism` are not permitted.
1811 GNAT does not require a separate pragma `Export`, but if none is
1812 present, `Convention Ada` is assumed, which is usually
1813 not what is wanted, so it is usually appropriate to use this
1814 pragma in conjunction with a `Export` or `Convention`
1815 pragma that specifies the desired foreign convention.
1817 .. index:: Suppressing external name
1819 Special treatment is given if the EXTERNAL is an explicit null
1820 string or a static string expressions that evaluates to the null
1821 string. In this case, no external name is generated. This form
1822 still allows the specification of parameter mechanisms.
1824 Pragma Export_Value
1825 ===================
1827 Syntax:
1832   pragma Export_Value (
1833     [Value     =>] static_integer_EXPRESSION,
1834     [Link_Name =>] static_string_EXPRESSION);
1837 This pragma serves to export a static integer value for external use.
1838 The first argument specifies the value to be exported. The Link_Name
1839 argument specifies the symbolic name to be associated with the integer
1840 value. This pragma is useful for defining a named static value in Ada
1841 that can be referenced in assembly language units to be linked with
1842 the application. This pragma is currently supported only for the
1843 AAMP target and is ignored for other targets.
1845 Pragma Export_Valued_Procedure
1846 ==============================
1848 Syntax:
1853   pragma Export_Valued_Procedure (
1854        [Internal        =>] LOCAL_NAME
1855     [, [External        =>] EXTERNAL_SYMBOL]
1856     [, [Parameter_Types =>] PARAMETER_TYPES]
1857     [, [Mechanism       =>] MECHANISM]);
1859   EXTERNAL_SYMBOL ::=
1860     IDENTIFIER
1861   | static_string_EXPRESSION
1862   | ""
1864   PARAMETER_TYPES ::=
1865     null
1866   | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
1868   TYPE_DESIGNATOR ::=
1869     subtype_NAME
1870   | subtype_Name ' Access
1872   MECHANISM ::=
1873     MECHANISM_NAME
1874   | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
1876   MECHANISM_ASSOCIATION ::=
1877     [formal_parameter_NAME =>] MECHANISM_NAME
1879   MECHANISM_NAME ::= Value | Reference
1882 This pragma is identical to `Export_Procedure` except that the
1883 first parameter of `LOCAL_NAME`, which must be present, must be of
1884 mode `OUT`, and externally the subprogram is treated as a function
1885 with this parameter as the result of the function.  GNAT provides for
1886 this capability to allow the use of `OUT` and `IN OUT`
1887 parameters in interfacing to external functions (which are not permitted
1888 in Ada functions).
1889 GNAT does not require a separate pragma `Export`, but if none is
1890 present, `Convention Ada` is assumed, which is almost certainly
1891 not what is wanted since the whole point of this pragma is to interface
1892 with foreign language functions, so it is usually appropriate to use this
1893 pragma in conjunction with a `Export` or `Convention`
1894 pragma that specifies the desired foreign convention.
1896 .. index:: Suppressing external name
1898 Special treatment is given if the EXTERNAL is an explicit null
1899 string or a static string expressions that evaluates to the null
1900 string. In this case, no external name is generated. This form
1901 still allows the specification of parameter mechanisms.
1903 Pragma Extend_System
1904 ====================
1905 .. index:: System, extending
1907 .. index:: DEC Ada 83
1910 Syntax:
1915   pragma Extend_System ([Name =>] IDENTIFIER);
1918 This pragma is used to provide backwards compatibility with other
1919 implementations that extend the facilities of package `System`.  In
1920 GNAT, `System` contains only the definitions that are present in
1921 the Ada RM.  However, other implementations, notably the DEC Ada 83
1922 implementation, provide many extensions to package `System`.
1924 For each such implementation accommodated by this pragma, GNAT provides a
1925 package `Aux_`xxx``, e.g., `Aux_DEC` for the DEC Ada 83
1926 implementation, which provides the required additional definitions.  You
1927 can use this package in two ways.  You can `with` it in the normal
1928 way and access entities either by selection or using a `use`
1929 clause.  In this case no special processing is required.
1931 However, if existing code contains references such as
1932 `System.`xxx`` where `xxx` is an entity in the extended
1933 definitions provided in package `System`, you may use this pragma
1934 to extend visibility in `System` in a non-standard way that
1935 provides greater compatibility with the existing code.  Pragma
1936 `Extend_System` is a configuration pragma whose single argument is
1937 the name of the package containing the extended definition
1938 (e.g., `Aux_DEC` for the DEC Ada case).  A unit compiled under
1939 control of this pragma will be processed using special visibility
1940 processing that looks in package `System.Aux_`xxx`` where
1941 `Aux_`xxx`` is the pragma argument for any entity referenced in
1942 package `System`, but not found in package `System`.
1944 You can use this pragma either to access a predefined `System`
1945 extension supplied with the compiler, for example `Aux_DEC` or
1946 you can construct your own extension unit following the above
1947 definition.  Note that such a package is a child of `System`
1948 and thus is considered part of the implementation.
1949 To compile it you will have to use the *-gnatg* switch
1950 for compiling System units, as explained in the
1951 GNAT User's Guide.
1953 Pragma Extensions_Allowed
1954 =========================
1955 .. index:: Ada Extensions
1957 .. index:: GNAT Extensions
1960 Syntax:
1962 .. code-block:: ada
1964   pragma Extensions_Allowed (On | Off);
1967 This configuration pragma enables or disables the implementation
1968 extension mode (the use of Off as a parameter cancels the effect
1969 of the *-gnatX* command switch).
1971 In extension mode, the latest version of the Ada language is
1972 implemented (currently Ada 2012), and in addition a small number
1973 of GNAT specific extensions are recognized as follows:
1977 *Constrained attribute for generic objects*
1978   The `Constrained` attribute is permitted for objects of
1979   generic types. The result indicates if the corresponding actual
1980   is constrained.
1983 Pragma External
1984 ===============
1986 Syntax:
1991   pragma External (
1992     [   Convention    =>] convention_IDENTIFIER,
1993     [   Entity        =>] LOCAL_NAME
1994     [, [External_Name =>] static_string_EXPRESSION ]
1995     [, [Link_Name     =>] static_string_EXPRESSION ]);
1998 This pragma is identical in syntax and semantics to pragma
1999 `Export` as defined in the Ada Reference Manual.  It is
2000 provided for compatibility with some Ada 83 compilers that
2001 used this pragma for exactly the same purposes as pragma
2002 `Export` before the latter was standardized.
2004 Pragma External_Name_Casing
2005 ===========================
2006 .. index:: Dec Ada 83 casing compatibility
2008 .. index:: External Names, casing
2010 .. index:: Casing of External names
2013 Syntax:
2018   pragma External_Name_Casing (
2019     Uppercase | Lowercase
2020     [, Uppercase | Lowercase | As_Is]);
2023 This pragma provides control over the casing of external names associated
2024 with Import and Export pragmas.  There are two cases to consider:
2028 * Implicit external names
2030   Implicit external names are derived from identifiers.  The most common case
2031   arises when a standard Ada Import or Export pragma is used with only two
2032   arguments, as in:
2034   .. code-block:: ada
2036        pragma Import (C, C_Routine);
2038   Since Ada is a case-insensitive language, the spelling of the identifier in
2039   the Ada source program does not provide any information on the desired
2040   casing of the external name, and so a convention is needed.  In GNAT the
2041   default treatment is that such names are converted to all lower case
2042   letters.  This corresponds to the normal C style in many environments.
2043   The first argument of pragma `External_Name_Casing` can be used to
2044   control this treatment.  If `Uppercase` is specified, then the name
2045   will be forced to all uppercase letters.  If `Lowercase` is specified,
2046   then the normal default of all lower case letters will be used.
2048   This same implicit treatment is also used in the case of extended DEC Ada 83
2049   compatible Import and Export pragmas where an external name is explicitly
2050   specified using an identifier rather than a string.
2053 * Explicit external names
2055   Explicit external names are given as string literals.  The most common case
2056   arises when a standard Ada Import or Export pragma is used with three
2057   arguments, as in:
2059   .. code-block:: ada
2061     pragma Import (C, C_Routine, "C_routine");
2063   In this case, the string literal normally provides the exact casing required
2064   for the external name.  The second argument of pragma
2065   `External_Name_Casing` may be used to modify this behavior.
2066   If `Uppercase` is specified, then the name
2067   will be forced to all uppercase letters.  If `Lowercase` is specified,
2068   then the name will be forced to all lowercase letters.  A specification of
2069   `As_Is` provides the normal default behavior in which the casing is
2070   taken from the string provided.
2072 This pragma may appear anywhere that a pragma is valid.  In particular, it
2073 can be used as a configuration pragma in the :file:`gnat.adc` file, in which
2074 case it applies to all subsequent compilations, or it can be used as a program
2075 unit pragma, in which case it only applies to the current unit, or it can
2076 be used more locally to control individual Import/Export pragmas.
2078 It was primarily intended for use with OpenVMS systems, where many
2079 compilers convert all symbols to upper case by default.  For interfacing to
2080 such compilers (e.g., the DEC C compiler), it may be convenient to use
2081 the pragma:
2083 .. code-block:: ada
2085   pragma External_Name_Casing (Uppercase, Uppercase);
2088 to enforce the upper casing of all external symbols.
2090 Pragma Fast_Math
2091 ================
2093 Syntax:
2096 .. code-block:: ada
2098   pragma Fast_Math;
2101 This is a configuration pragma which activates a mode in which speed is
2102 considered more important for floating-point operations than absolutely
2103 accurate adherence to the requirements of the standard. Currently the
2104 following operations are affected:
2108 *Complex Multiplication*
2109   The normal simple formula for complex multiplication can result in intermediate
2110   overflows for numbers near the end of the range. The Ada standard requires that
2111   this situation be detected and corrected by scaling, but in Fast_Math mode such
2112   cases will simply result in overflow. Note that to take advantage of this you
2113   must instantiate your own version of `Ada.Numerics.Generic_Complex_Types`
2114   under control of the pragma, rather than use the preinstantiated versions.
2116 Pragma Favor_Top_Level
2117 ======================
2119 Syntax:
2122 .. code-block:: ada
2124   pragma Favor_Top_Level (type_NAME);
2127 The named type must be an access-to-subprogram type. This pragma is an
2128 efficiency hint to the compiler, regarding the use of 'Access or
2129 'Unrestricted_Access on nested (non-library-level) subprograms. The
2130 pragma means that nested subprograms are not used with this type, or
2131 are rare, so that the generated code should be efficient in the
2132 top-level case. When this pragma is used, dynamically generated
2133 trampolines may be used on some targets for nested subprograms.
2134 See also the No_Implicit_Dynamic_Code restriction.
2136 Pragma Finalize_Storage_Only
2137 ============================
2139 Syntax:
2142 .. code-block:: ada
2144   pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2147 This pragma allows the compiler not to emit a Finalize call for objects
2148 defined at the library level.  This is mostly useful for types where
2149 finalization is only used to deal with storage reclamation since in most
2150 environments it is not necessary to reclaim memory just before terminating
2151 execution, hence the name.
2153 Pragma Float_Representation
2154 ===========================
2156 Syntax::
2158   pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2160   FLOAT_REP ::= VAX_Float | IEEE_Float
2163 In the one argument form, this pragma is a configuration pragma which
2164 allows control over the internal representation chosen for the predefined
2165 floating point types declared in the packages `Standard` and
2166 `System`. This pragma is only provided for compatibility and has no effect.
2168 The two argument form specifies the representation to be used for
2169 the specified floating-point type. The argument must
2170 be `IEEE_Float` to specify the use of IEEE format, as follows:
2173   For a digits value of 6, 32-bit IEEE short format will be used.
2175   For a digits value of 15, 64-bit IEEE long format will be used.
2177   No other value of digits is permitted.
2179 Pragma Global
2180 =============
2182 For the description of this pragma, see SPARK 2014 Reference Manual,
2183 section 6.1.4.
2185 Pragma Ident
2186 ============
2188 Syntax:
2191 .. code-block:: ada
2193   pragma Ident (static_string_EXPRESSION);
2196 This pragma is identical in effect to pragma `Comment`. It is provided
2197 for compatibility with other Ada compilers providing this pragma.
2199 Pragma Implementation_Defined
2200 =============================
2202 Syntax:
2205 .. code-block:: ada
2207   pragma Implementation_Defined (local_NAME);
2210 This pragma marks a previously declared entioty as implementation-defined.
2211 For an overloaded entity, applies to the most recent homonym.
2214 .. code-block:: ada
2216   pragma Implementation_Defined;
2219 The form with no arguments appears anywhere within a scope, most
2220 typically a package spec, and indicates that all entities that are
2221 defined within the package spec are Implementation_Defined.
2223 This pragma is used within the GNAT runtime library to identify
2224 implementation-defined entities introduced in language-defined units,
2225 for the purpose of implementing the No_Implementation_Identifiers
2226 restriction.
2228 Pragma Implemented
2229 ==================
2231 Syntax:
2236   pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2238   implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2241 This is an Ada 2012 representation pragma which applies to protected, task
2242 and synchronized interface primitives. The use of pragma Implemented provides
2243 a way to impose a static requirement on the overriding operation by adhering
2244 to one of the three implementation kinds: entry, protected procedure or any of
2245 the above. This pragma is available in all earlier versions of Ada as an
2246 implementation-defined pragma.
2249 .. code-block:: ada
2251   type Synch_Iface is synchronized interface;
2252   procedure Prim_Op (Obj : in out Iface) is abstract;
2253   pragma Implemented (Prim_Op, By_Protected_Procedure);
2255   protected type Prot_1 is new Synch_Iface with
2256      procedure Prim_Op;  --  Legal
2257   end Prot_1;
2259   protected type Prot_2 is new Synch_Iface with
2260      entry Prim_Op;      --  Illegal
2261   end Prot_2;
2263   task type Task_Typ is new Synch_Iface with
2264      entry Prim_Op;      --  Illegal
2265   end Task_Typ;
2268 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2269 Implemented determines the runtime behavior of the requeue. Implementation kind
2270 By_Entry guarantees that the action of requeueing will proceed from an entry to
2271 another entry. Implementation kind By_Protected_Procedure transforms the
2272 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2273 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2274 the target's overriding subprogram kind.
2276 Pragma Implicit_Packing
2277 =======================
2278 .. index:: Rational Profile
2280 Syntax:
2283 .. code-block:: ada
2285   pragma Implicit_Packing;
2288 This is a configuration pragma that requests implicit packing for packed
2289 arrays for which a size clause is given but no explicit pragma Pack or
2290 specification of Component_Size is present. It also applies to records
2291 where no record representation clause is present. Consider this example:
2294 .. code-block:: ada
2296   type R is array (0 .. 7) of Boolean;
2297   for R'Size use 8;
2300 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2301 does not change the layout of a composite object. So the Size clause in the
2302 above example is normally rejected, since the default layout of the array uses
2303 8-bit components, and thus the array requires a minimum of 64 bits.
2305 If this declaration is compiled in a region of code covered by an occurrence
2306 of the configuration pragma Implicit_Packing, then the Size clause in this
2307 and similar examples will cause implicit packing and thus be accepted. For
2308 this implicit packing to occur, the type in question must be an array of small
2309 components whose size is known at compile time, and the Size clause must
2310 specify the exact size that corresponds to the number of elements in the array
2311 multiplied by the size in bits of the component type (both single and
2312 multi-dimensioned arrays can be controlled with this pragma).
2314 .. index:: Array packing
2316 Similarly, the following example shows the use in the record case
2319 .. code-block:: ada
2321   type r is record
2322      a, b, c, d, e, f, g, h : boolean;
2323      chr                    : character;
2324   end record;
2325   for r'size use 16;
2328 Without a pragma Pack, each Boolean field requires 8 bits, so the
2329 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2330 sufficient. The use of pragma Implicit_Packing allows this record
2331 declaration to compile without an explicit pragma Pack.
2333 Pragma Import_Function
2334 ======================
2336 Syntax:
2341   pragma Import_Function (
2342        [Internal                 =>] LOCAL_NAME,
2343     [, [External                 =>] EXTERNAL_SYMBOL]
2344     [, [Parameter_Types          =>] PARAMETER_TYPES]
2345     [, [Result_Type              =>] SUBTYPE_MARK]
2346     [, [Mechanism                =>] MECHANISM]
2347     [, [Result_Mechanism         =>] MECHANISM_NAME]);
2349   EXTERNAL_SYMBOL ::=
2350     IDENTIFIER
2351   | static_string_EXPRESSION
2353   PARAMETER_TYPES ::=
2354     null
2355   | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2357   TYPE_DESIGNATOR ::=
2358     subtype_NAME
2359   | subtype_Name ' Access
2361   MECHANISM ::=
2362     MECHANISM_NAME
2363   | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2365   MECHANISM_ASSOCIATION ::=
2366     [formal_parameter_NAME =>] MECHANISM_NAME
2368   MECHANISM_NAME ::=
2369     Value
2370   | Reference
2373 This pragma is used in conjunction with a pragma `Import` to
2374 specify additional information for an imported function.  The pragma
2375 `Import` (or equivalent pragma `Interface`) must precede the
2376 `Import_Function` pragma and both must appear in the same
2377 declarative part as the function specification.
2379 The `Internal` argument must uniquely designate
2380 the function to which the
2381 pragma applies.  If more than one function name exists of this name in
2382 the declarative part you must use the `Parameter_Types` and
2383 `Result_Type` parameters to achieve the required unique
2384 designation.  Subtype marks in these parameters must exactly match the
2385 subtypes in the corresponding function specification, using positional
2386 notation to match parameters with subtype marks.
2387 The form with an `'Access` attribute can be used to match an
2388 anonymous access parameter.
2390 You may optionally use the `Mechanism` and `Result_Mechanism`
2391 parameters to specify passing mechanisms for the
2392 parameters and result.  If you specify a single mechanism name, it
2393 applies to all parameters.  Otherwise you may specify a mechanism on a
2394 parameter by parameter basis using either positional or named
2395 notation.  If the mechanism is not specified, the default mechanism
2396 is used.
2398 Pragma Import_Object
2399 ====================
2401 Syntax:
2406   pragma Import_Object
2407        [Internal =>] LOCAL_NAME
2408     [, [External =>] EXTERNAL_SYMBOL]
2409     [, [Size     =>] EXTERNAL_SYMBOL]);
2411   EXTERNAL_SYMBOL ::=
2412     IDENTIFIER
2413   | static_string_EXPRESSION
2416 This pragma designates an object as imported, and apart from the
2417 extended rules for external symbols, is identical in effect to the use of
2418 the normal `Import` pragma applied to an object.  Unlike the
2419 subprogram case, you need not use a separate `Import` pragma,
2420 although you may do so (and probably should do so from a portability
2421 point of view).  `size` is syntax checked, but otherwise ignored by
2422 GNAT.
2424 Pragma Import_Procedure
2425 =======================
2427 Syntax:
2432   pragma Import_Procedure (
2433        [Internal                 =>] LOCAL_NAME
2434     [, [External                 =>] EXTERNAL_SYMBOL]
2435     [, [Parameter_Types          =>] PARAMETER_TYPES]
2436     [, [Mechanism                =>] MECHANISM]);
2438   EXTERNAL_SYMBOL ::=
2439     IDENTIFIER
2440   | static_string_EXPRESSION
2442   PARAMETER_TYPES ::=
2443     null
2444   | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2446   TYPE_DESIGNATOR ::=
2447     subtype_NAME
2448   | subtype_Name ' Access
2450   MECHANISM ::=
2451     MECHANISM_NAME
2452   | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2454   MECHANISM_ASSOCIATION ::=
2455     [formal_parameter_NAME =>] MECHANISM_NAME
2457   MECHANISM_NAME ::= Value | Reference
2460 This pragma is identical to `Import_Function` except that it
2461 applies to a procedure rather than a function and the parameters
2462 `Result_Type` and `Result_Mechanism` are not permitted.
2464 Pragma Import_Valued_Procedure
2465 ==============================
2467 Syntax:
2472   pragma Import_Valued_Procedure (
2473        [Internal                 =>] LOCAL_NAME
2474     [, [External                 =>] EXTERNAL_SYMBOL]
2475     [, [Parameter_Types          =>] PARAMETER_TYPES]
2476     [, [Mechanism                =>] MECHANISM]);
2478   EXTERNAL_SYMBOL ::=
2479     IDENTIFIER
2480   | static_string_EXPRESSION
2482   PARAMETER_TYPES ::=
2483     null
2484   | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2486   TYPE_DESIGNATOR ::=
2487     subtype_NAME
2488   | subtype_Name ' Access
2490   MECHANISM ::=
2491     MECHANISM_NAME
2492   | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2494   MECHANISM_ASSOCIATION ::=
2495     [formal_parameter_NAME =>] MECHANISM_NAME
2497   MECHANISM_NAME ::= Value | Reference
2500 This pragma is identical to `Import_Procedure` except that the
2501 first parameter of `LOCAL_NAME`, which must be present, must be of
2502 mode `OUT`, and externally the subprogram is treated as a function
2503 with this parameter as the result of the function.  The purpose of this
2504 capability is to allow the use of `OUT` and `IN OUT`
2505 parameters in interfacing to external functions (which are not permitted
2506 in Ada functions).  You may optionally use the `Mechanism`
2507 parameters to specify passing mechanisms for the parameters.
2508 If you specify a single mechanism name, it applies to all parameters.
2509 Otherwise you may specify a mechanism on a parameter by parameter
2510 basis using either positional or named notation.  If the mechanism is not
2511 specified, the default mechanism is used.
2513 Note that it is important to use this pragma in conjunction with a separate
2514 pragma Import that specifies the desired convention, since otherwise the
2515 default convention is Ada, which is almost certainly not what is required.
2517 Pragma Independent
2518 ==================
2520 Syntax:
2523 .. code-block:: ada
2525   pragma Independent (Local_NAME);
2528 This pragma is standard in Ada 2012 mode (which also provides an aspect
2529 of the same name). It is also available as an implementation-defined
2530 pragma in all earlier versions. It specifies that the
2531 designated object or all objects of the designated type must be
2532 independently addressable. This means that separate tasks can safely
2533 manipulate such objects. For example, if two components of a record are
2534 independent, then two separate tasks may access these two components.
2535 This may place
2536 constraints on the representation of the object (for instance prohibiting
2537 tight packing).
2539 Pragma Independent_Components
2540 =============================
2542 Syntax:
2545 .. code-block:: ada
2547   pragma Independent_Components (Local_NAME);
2550 This pragma is standard in Ada 2012 mode (which also provides an aspect
2551 of the same name). It is also available as an implementation-defined
2552 pragma in all earlier versions. It specifies that the components of the
2553 designated object, or the components of each object of the designated
2554 type, must be
2555 independently addressable. This means that separate tasks can safely
2556 manipulate separate components in the composite object. This may place
2557 constraints on the representation of the object (for instance prohibiting
2558 tight packing).
2560 Pragma Initial_Condition
2561 ========================
2563 For the description of this pragma, see SPARK 2014 Reference Manual,
2564 section 7.1.6.
2566 Pragma Initialize_Scalars
2567 =========================
2568 .. index:: debugging with Initialize_Scalars
2570 Syntax:
2573 .. code-block:: ada
2575   pragma Initialize_Scalars;
2578 This pragma is similar to `Normalize_Scalars` conceptually but has
2579 two important differences.  First, there is no requirement for the pragma
2580 to be used uniformly in all units of a partition, in particular, it is fine
2581 to use this just for some or all of the application units of a partition,
2582 without needing to recompile the run-time library.
2584 In the case where some units are compiled with the pragma, and some without,
2585 then a declaration of a variable where the type is defined in package
2586 Standard or is locally declared will always be subject to initialization,
2587 as will any declaration of a scalar variable.  For composite variables,
2588 whether the variable is initialized may also depend on whether the package
2589 in which the type of the variable is declared is compiled with the pragma.
2591 The other important difference is that you can control the value used
2592 for initializing scalar objects.  At bind time, you can select several
2593 options for initialization. You can
2594 initialize with invalid values (similar to Normalize_Scalars, though for
2595 Initialize_Scalars it is not always possible to determine the invalid
2596 values in complex cases like signed component fields with non-standard
2597 sizes). You can also initialize with high or
2598 low values, or with a specified bit pattern.  See the GNAT
2599 User's Guide for binder options for specifying these cases.
2601 This means that you can compile a program, and then without having to
2602 recompile the program, you can run it with different values being used
2603 for initializing otherwise uninitialized values, to test if your program
2604 behavior depends on the choice.  Of course the behavior should not change,
2605 and if it does, then most likely you have an incorrect reference to an
2606 uninitialized value.
2608 It is even possible to change the value at execution time eliminating even
2609 the need to rebind with a different switch using an environment variable.
2610 See the GNAT User's Guide for details.
2612 Note that pragma `Initialize_Scalars` is particularly useful in
2613 conjunction with the enhanced validity checking that is now provided
2614 in GNAT, which checks for invalid values under more conditions.
2615 Using this feature (see description of the *-gnatV* flag in the
2616 GNAT User's Guide) in conjunction with
2617 pragma `Initialize_Scalars`
2618 provides a powerful new tool to assist in the detection of problems
2619 caused by uninitialized variables.
2621 Note: the use of `Initialize_Scalars` has a fairly extensive
2622 effect on the generated code. This may cause your code to be
2623 substantially larger. It may also cause an increase in the amount
2624 of stack required, so it is probably a good idea to turn on stack
2625 checking (see description of stack checking in the GNAT
2626 User's Guide) when using this pragma.
2628 Pragma Initializes
2629 ==================
2631 For the description of this pragma, see SPARK 2014 Reference Manual,
2632 section 7.1.5.
2634 Pragma Inline_Always
2635 ====================
2637 Syntax:
2642   pragma Inline_Always (NAME [, NAME]);
2645 Similar to pragma `Inline` except that inlining is not subject to
2646 the use of option *-gnatn* or *-gnatN* and the inlining
2647 happens regardless of whether these options are used.
2649 Pragma Inline_Generic
2650 =====================
2652 Syntax:
2657   pragma Inline_Generic (GNAME {, GNAME});
2659   GNAME ::= generic_unit_NAME | generic_instance_NAME
2662 This pragma is provided for compatibility with Dec Ada 83. It has
2663 no effect in `GNAT` (which always inlines generics), other
2664 than to check that the given names are all names of generic units or
2665 generic instances.
2667 Pragma Interface
2668 ================
2670 Syntax:
2675   pragma Interface (
2676        [Convention    =>] convention_identifier,
2677        [Entity        =>] local_NAME
2678     [, [External_Name =>] static_string_expression]
2679     [, [Link_Name     =>] static_string_expression]);
2682 This pragma is identical in syntax and semantics to
2683 the standard Ada pragma `Import`.  It is provided for compatibility
2684 with Ada 83.  The definition is upwards compatible both with pragma
2685 `Interface` as defined in the Ada 83 Reference Manual, and also
2686 with some extended implementations of this pragma in certain Ada 83
2687 implementations.  The only difference between pragma `Interface`
2688 and pragma `Import` is that there is special circuitry to allow
2689 both pragmas to appear for the same subprogram entity (normally it
2690 is illegal to have multiple `Import` pragmas. This is useful in
2691 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2692 Ada 83 compilers.
2694 Pragma Interface_Name
2695 =====================
2697 Syntax:
2702   pragma Interface_Name (
2703        [Entity        =>] LOCAL_NAME
2704     [, [External_Name =>] static_string_EXPRESSION]
2705     [, [Link_Name     =>] static_string_EXPRESSION]);
2708 This pragma provides an alternative way of specifying the interface name
2709 for an interfaced subprogram, and is provided for compatibility with Ada
2710 83 compilers that use the pragma for this purpose.  You must provide at
2711 least one of `External_Name` or `Link_Name`.
2713 Pragma Interrupt_Handler
2714 ========================
2716 Syntax:
2719 .. code-block:: ada
2721   pragma Interrupt_Handler (procedure_LOCAL_NAME);
2724 This program unit pragma is supported for parameterless protected procedures
2725 as described in Annex C of the Ada Reference Manual. On the AAMP target
2726 the pragma can also be specified for nonprotected parameterless procedures
2727 that are declared at the library level (which includes procedures
2728 declared at the top level of a library package). In the case of AAMP,
2729 when this pragma is applied to a nonprotected procedure, the instruction
2730 `IERET` is generated for returns from the procedure, enabling
2731 maskable interrupts, in place of the normal return instruction.
2733 Pragma Interrupt_State
2734 ======================
2736 Syntax:
2741   pragma Interrupt_State
2742    ([Name  =>] value,
2743     [State =>] SYSTEM | RUNTIME | USER);
2746 Normally certain interrupts are reserved to the implementation.  Any attempt
2747 to attach an interrupt causes Program_Error to be raised, as described in
2748 RM C.3.2(22).  A typical example is the `SIGINT` interrupt used in
2749 many systems for an :kbd:`Ctrl-C` interrupt.  Normally this interrupt is
2750 reserved to the implementation, so that :kbd:`Ctrl-C` can be used to
2751 interrupt execution.  Additionally, signals such as `SIGSEGV`,
2752 `SIGABRT`, `SIGFPE` and `SIGILL` are often mapped to specific
2753 Ada exceptions, or used to implement run-time functions such as the
2754 `abort` statement and stack overflow checking.
2756 Pragma `Interrupt_State` provides a general mechanism for overriding
2757 such uses of interrupts.  It subsumes the functionality of pragma
2758 `Unreserve_All_Interrupts`.  Pragma `Interrupt_State` is not
2759 available on Windows or VMS.  On all other platforms than VxWorks,
2760 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2761 and may be used to mark interrupts required by the board support package
2762 as reserved.
2764 Interrupts can be in one of three states:
2766 * System
2768   The interrupt is reserved (no Ada handler can be installed), and the
2769   Ada run-time may not install a handler. As a result you are guaranteed
2770   standard system default action if this interrupt is raised.
2772 * Runtime
2774   The interrupt is reserved (no Ada handler can be installed). The run time
2775   is allowed to install a handler for internal control purposes, but is
2776   not required to do so.
2778 * User
2780   The interrupt is unreserved.  The user may install a handler to provide
2781   some other action.
2783 These states are the allowed values of the `State` parameter of the
2784 pragma.  The `Name` parameter is a value of the type
2785 `Ada.Interrupts.Interrupt_ID`.  Typically, it is a name declared in
2786 `Ada.Interrupts.Names`.
2788 This is a configuration pragma, and the binder will check that there
2789 are no inconsistencies between different units in a partition in how a
2790 given interrupt is specified. It may appear anywhere a pragma is legal.
2792 The effect is to move the interrupt to the specified state.
2794 By declaring interrupts to be SYSTEM, you guarantee the standard system
2795 action, such as a core dump.
2797 By declaring interrupts to be USER, you guarantee that you can install
2798 a handler.
2800 Note that certain signals on many operating systems cannot be caught and
2801 handled by applications.  In such cases, the pragma is ignored.  See the
2802 operating system documentation, or the value of the array `Reserved`
2803 declared in the spec of package `System.OS_Interface`.
2805 Overriding the default state of signals used by the Ada runtime may interfere
2806 with an application's runtime behavior in the cases of the synchronous signals,
2807 and in the case of the signal used to implement the `abort` statement.
2809 Pragma Invariant
2810 ================
2812 Syntax:
2817   pragma Invariant
2818     ([Entity =>]    private_type_LOCAL_NAME,
2819      [Check  =>]    EXPRESSION
2820      [,[Message =>] String_Expression]);
2823 This pragma provides exactly the same capabilities as the Type_Invariant aspect
2824 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
2825 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
2826 requires the use of the aspect syntax, which is not available except in 2012
2827 mode, it is not possible to use the Type_Invariant aspect in earlier versions
2828 of Ada. However the Invariant pragma may be used in any version of Ada. Also
2829 note that the aspect Invariant is a synonym in GNAT for the aspect
2830 Type_Invariant, but there is no pragma Type_Invariant.
2832 The pragma must appear within the visible part of the package specification,
2833 after the type to which its Entity argument appears. As with the Invariant
2834 aspect, the Check expression is not analyzed until the end of the visible
2835 part of the package, so it may contain forward references. The Message
2836 argument, if present, provides the exception message used if the invariant
2837 is violated. If no Message parameter is provided, a default message that
2838 identifies the line on which the pragma appears is used.
2840 It is permissible to have multiple Invariants for the same type entity, in
2841 which case they are and'ed together. It is permissible to use this pragma
2842 in Ada 2012 mode, but you cannot have both an invariant aspect and an
2843 invariant pragma for the same entity.
2845 For further details on the use of this pragma, see the Ada 2012 documentation
2846 of the Type_Invariant aspect.
2848 Pragma Java_Constructor
2849 =======================
2851 Syntax:
2856   pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
2859 This pragma is used to assert that the specified Ada function should be
2860 mapped to the Java constructor for some Ada tagged record type.
2862 See section 7.3.2 of the
2863 `GNAT User's Guide: Supplement for the JVM Platform.`
2864 for related information.
2866 Pragma Java_Interface
2867 =====================
2869 Syntax:
2874   pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
2877 This pragma is used to assert that the specified Ada abstract tagged type
2878 is to be mapped to a Java interface name.
2880 See sections 7.1 and 7.2 of the
2881 `GNAT User's Guide: Supplement for the JVM Platform.`
2882 for related information.
2884 Pragma Keep_Names
2885 =================
2887 Syntax:
2892   pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2895 The `LOCAL_NAME` argument
2896 must refer to an enumeration first subtype
2897 in the current declarative part. The effect is to retain the enumeration
2898 literal names for use by `Image` and `Value` even if a global
2899 `Discard_Names` pragma applies. This is useful when you want to
2900 generally suppress enumeration literal names and for example you therefore
2901 use a `Discard_Names` pragma in the :file:`gnat.adc` file, but you
2902 want to retain the names for specific enumeration types.
2904 Pragma License
2905 ==============
2906 .. index:: License checking
2908 Syntax:
2911 .. code-block:: ada
2913   pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2916 This pragma is provided to allow automated checking for appropriate license
2917 conditions with respect to the standard and modified GPL.  A pragma
2918 `License`, which is a configuration pragma that typically appears at
2919 the start of a source file or in a separate :file:`gnat.adc` file, specifies
2920 the licensing conditions of a unit as follows:
2922 * Unrestricted
2923   This is used for a unit that can be freely used with no license restrictions.
2924   Examples of such units are public domain units, and units from the Ada
2925   Reference Manual.
2927 * GPL
2928   This is used for a unit that is licensed under the unmodified GPL, and which
2929   therefore cannot be `with`'ed by a restricted unit.
2931 * Modified_GPL
2932   This is used for a unit licensed under the GNAT modified GPL that includes
2933   a special exception paragraph that specifically permits the inclusion of
2934   the unit in programs without requiring the entire program to be released
2935   under the GPL.
2937 * Restricted
2938   This is used for a unit that is restricted in that it is not permitted to
2939   depend on units that are licensed under the GPL.  Typical examples are
2940   proprietary code that is to be released under more restrictive license
2941   conditions.  Note that restricted units are permitted to `with` units
2942   which are licensed under the modified GPL (this is the whole point of the
2943   modified GPL).
2946 Normally a unit with no `License` pragma is considered to have an
2947 unknown license, and no checking is done.  However, standard GNAT headers
2948 are recognized, and license information is derived from them as follows.
2950 A GNAT license header starts with a line containing 78 hyphens.  The following
2951 comment text is searched for the appearance of any of the following strings.
2953 If the string 'GNU General Public License' is found, then the unit is assumed
2954 to have GPL license, unless the string 'As a special exception' follows, in
2955 which case the license is assumed to be modified GPL.
2957 If one of the strings
2958 'This specification is adapted from the Ada Semantic Interface' or
2959 'This specification is derived from the Ada Reference Manual' is found
2960 then the unit is assumed to be unrestricted.
2962 These default actions means that a program with a restricted license pragma
2963 will automatically get warnings if a GPL unit is inappropriately
2964 `with`'ed.  For example, the program:
2966 .. code-block:: ada
2968   with Sem_Ch3;
2969   with GNAT.Sockets;
2970   procedure Secret_Stuff is
2971     ...
2972   end Secret_Stuff
2975 if compiled with pragma `License` (`Restricted`) in a
2976 :file:`gnat.adc` file will generate the warning::
2978   1.  with Sem_Ch3;
2979           |
2980      >>> license of withed unit "Sem_Ch3" is incompatible
2982   2.  with GNAT.Sockets;
2983   3.  procedure Secret_Stuff is
2986 Here we get a warning on `Sem_Ch3` since it is part of the GNAT
2987 compiler and is licensed under the
2988 GPL, but no warning for `GNAT.Sockets` which is part of the GNAT
2989 run time, and is therefore licensed under the modified GPL.
2991 Pragma Link_With
2992 ================
2994 Syntax:
2999   pragma Link_With (static_string_EXPRESSION {,static_string_EXPRESSION});
3002 This pragma is provided for compatibility with certain Ada 83 compilers.
3003 It has exactly the same effect as pragma `Linker_Options` except
3004 that spaces occurring within one of the string expressions are treated
3005 as separators. For example, in the following case:
3007 .. code-block:: ada
3009   pragma Link_With ("-labc -ldef");
3012 results in passing the strings `-labc` and `-ldef` as two
3013 separate arguments to the linker. In addition pragma Link_With allows
3014 multiple arguments, with the same effect as successive pragmas.
3016 Pragma Linker_Alias
3017 ===================
3019 Syntax:
3024   pragma Linker_Alias (
3025     [Entity =>] LOCAL_NAME,
3026     [Target =>] static_string_EXPRESSION);
3029 `LOCAL_NAME` must refer to an object that is declared at the library
3030 level. This pragma establishes the given entity as a linker alias for the
3031 given target. It is equivalent to `__attribute__((alias))` in GNU C
3032 and causes `LOCAL_NAME` to be emitted as an alias for the symbol
3033 `static_string_EXPRESSION` in the object file, that is to say no space
3034 is reserved for `LOCAL_NAME` by the assembler and it will be resolved
3035 to the same address as `static_string_EXPRESSION` by the linker.
3037 The actual linker name for the target must be used (e.g., the fully
3038 encoded name with qualification in Ada, or the mangled name in C++),
3039 or it must be declared using the C convention with `pragma Import`
3040 or `pragma Export`.
3042 Not all target machines support this pragma. On some of them it is accepted
3043 only if `pragma Weak_External` has been applied to `LOCAL_NAME`.
3046 .. code-block:: ada
3048   --  Example of the use of pragma Linker_Alias
3050   package p is
3051     i : Integer := 1;
3052     pragma Export (C, i);
3054     new_name_for_i : Integer;
3055     pragma Linker_Alias (new_name_for_i, "i");
3056   end p;
3059 Pragma Linker_Constructor
3060 =========================
3062 Syntax:
3065 .. code-block:: ada
3067   pragma Linker_Constructor (procedure_LOCAL_NAME);
3070 `procedure_LOCAL_NAME` must refer to a parameterless procedure that
3071 is declared at the library level. A procedure to which this pragma is
3072 applied will be treated as an initialization routine by the linker.
3073 It is equivalent to `__attribute__((constructor))` in GNU C and
3074 causes `procedure_LOCAL_NAME` to be invoked before the entry point
3075 of the executable is called (or immediately after the shared library is
3076 loaded if the procedure is linked in a shared library), in particular
3077 before the Ada run-time environment is set up.
3079 Because of these specific contexts, the set of operations such a procedure
3080 can perform is very limited and the type of objects it can manipulate is
3081 essentially restricted to the elementary types. In particular, it must only
3082 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3084 This pragma is used by GNAT to implement auto-initialization of shared Stand
3085 Alone Libraries, which provides a related capability without the restrictions
3086 listed above. Where possible, the use of Stand Alone Libraries is preferable
3087 to the use of this pragma.
3089 Pragma Linker_Destructor
3090 ========================
3092 Syntax:
3095 .. code-block:: ada
3097   pragma Linker_Destructor (procedure_LOCAL_NAME);
3100 `procedure_LOCAL_NAME` must refer to a parameterless procedure that
3101 is declared at the library level. A procedure to which this pragma is
3102 applied will be treated as a finalization routine by the linker.
3103 It is equivalent to `__attribute__((destructor))` in GNU C and
3104 causes `procedure_LOCAL_NAME` to be invoked after the entry point
3105 of the executable has exited (or immediately before the shared library
3106 is unloaded if the procedure is linked in a shared library), in particular
3107 after the Ada run-time environment is shut down.
3109 See `pragma Linker_Constructor` for the set of restrictions that apply
3110 because of these specific contexts.
3112 Pragma Linker_Section
3113 =====================
3115 Syntax:
3120   pragma Linker_Section (
3121     [Entity  =>] LOCAL_NAME,
3122     [Section =>] static_string_EXPRESSION);
3125 `LOCAL_NAME` must refer to an object, type, or subprogram that is
3126 declared at the library level. This pragma specifies the name of the
3127 linker section for the given entity. It is equivalent to
3128 `__attribute__((section))` in GNU C and causes `LOCAL_NAME` to
3129 be placed in the `static_string_EXPRESSION` section of the
3130 executable (assuming the linker doesn't rename the section).
3131 GNAT also provides an implementation defined aspect of the same name.
3133 In the case of specifying this aspect for a type, the effect is to
3134 specify the corresponding for all library level objects of the type which
3135 do not have an explicit linker section set. Note that this only applies to
3136 whole objects, not to components of composite objects.
3138 In the case of a subprogram, the linker section applies to all previously
3139 declared matching overloaded subprograms in the current declarative part
3140 which do not already have a linker section assigned. The linker section
3141 aspect is useful in this case for specifying different linker sections
3142 for different elements of such an overloaded set.
3144 Note that an empty string specifies that no linker section is specified.
3145 This is not quite the same as omitting the pragma or aspect, since it
3146 can be used to specify that one element of an overloaded set of subprograms
3147 has the default linker section, or that one object of a type for which a
3148 linker section is specified should has the default linker section.
3150 The compiler normally places library-level entities in standard sections
3151 depending on the class: procedures and functions generally go in the
3152 `.text` section, initialized variables in the `.data` section
3153 and uninitialized variables in the `.bss` section.
3155 Other, special sections may exist on given target machines to map special
3156 hardware, for example I/O ports or flash memory. This pragma is a means to
3157 defer the final layout of the executable to the linker, thus fully working
3158 at the symbolic level with the compiler.
3160 Some file formats do not support arbitrary sections so not all target
3161 machines support this pragma. The use of this pragma may cause a program
3162 execution to be erroneous if it is used to place an entity into an
3163 inappropriate section (e.g., a modified variable into the `.text`
3164 section). See also `pragma Persistent_BSS`.
3167 .. code-block:: ada
3169   --  Example of the use of pragma Linker_Section
3171   package IO_Card is
3172     Port_A : Integer;
3173     pragma Volatile (Port_A);
3174     pragma Linker_Section (Port_A, ".bss.port_a");
3176     Port_B : Integer;
3177     pragma Volatile (Port_B);
3178     pragma Linker_Section (Port_B, ".bss.port_b");
3180     type Port_Type is new Integer with Linker_Section => ".bss";
3181     PA : Port_Type with Linker_Section => ".bss.PA";
3182     PB : Port_Type; --  ends up in linker section ".bss"
3184     procedure Q with Linker_Section => "Qsection";
3185   end IO_Card;
3188 Pragma Lock_Free
3189 ================
3191 Syntax:
3192 This pragma may be specified for protected types or objects. It specifies that
3193 the implementation of protected operations must be implemented without locks.
3194 Compilation fails if the compiler cannot generate lock-free code for the
3195 operations.
3197 Pragma Loop_Invariant
3198 =====================
3200 Syntax:
3203 .. code-block:: ada
3205   pragma Loop_Invariant ( boolean_EXPRESSION );
3208 The effect of this pragma is similar to that of pragma `Assert`,
3209 except that in an `Assertion_Policy` pragma, the identifier
3210 `Loop_Invariant` is used to control whether it is ignored or checked
3211 (or disabled).
3213 `Loop_Invariant` can only appear as one of the items in the sequence
3214 of statements of a loop body, or nested inside block statements that
3215 appear in the sequence of statements of a loop body.
3216 The intention is that it be used to
3217 represent a "loop invariant" assertion, i.e. something that is true each
3218 time through the loop, and which can be used to show that the loop is
3219 achieving its purpose.
3221 Multiple `Loop_Invariant` and `Loop_Variant` pragmas that
3222 apply to the same loop should be grouped in the same sequence of
3223 statements.
3225 To aid in writing such invariants, the special attribute `Loop_Entry`
3226 may be used to refer to the value of an expression on entry to the loop. This
3227 attribute can only be used within the expression of a `Loop_Invariant`
3228 pragma. For full details, see documentation of attribute `Loop_Entry`.
3230 Pragma Loop_Optimize
3231 ====================
3233 Syntax:
3238   pragma Loop_Optimize (OPTIMIZATION_HINT {, OPTIMIZATION_HINT});
3240   OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
3243 This pragma must appear immediately within a loop statement.  It allows the
3244 programmer to specify optimization hints for the enclosing loop.  The hints
3245 are not mutually exclusive and can be freely mixed, but not all combinations
3246 will yield a sensible outcome.
3248 There are five supported optimization hints for a loop:
3250 * Ivdep
3252   The programmer asserts that there are no loop-carried dependencies
3253   which would prevent consecutive iterations of the loop from being
3254   executed simultaneously.
3256 * No_Unroll
3258   The loop must not be unrolled.  This is a strong hint: the compiler will not
3259   unroll a loop marked with this hint.
3261 * Unroll
3263   The loop should be unrolled.  This is a weak hint: the compiler will try to
3264   apply unrolling to this loop preferably to other optimizations, notably
3265   vectorization, but there is no guarantee that the loop will be unrolled.
3267 * No_Vector
3269   The loop must not be vectorized.  This is a strong hint: the compiler will not
3270   vectorize a loop marked with this hint.
3272 * Vector
3274   The loop should be vectorized.  This is a weak hint: the compiler will try to
3275   apply vectorization to this loop preferably to other optimizations, notably
3276   unrolling, but there is no guarantee that the loop will be vectorized.
3279 These hints do not remove the need to pass the appropriate switches to the
3280 compiler in order to enable the relevant optimizations, that is to say
3281 *-funroll-loops* for unrolling and *-ftree-vectorize* for
3282 vectorization.
3284 Pragma Loop_Variant
3285 ===================
3287 Syntax:
3292   pragma Loop_Variant ( LOOP_VARIANT_ITEM {, LOOP_VARIANT_ITEM } );
3293   LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
3294   CHANGE_DIRECTION ::= Increases | Decreases
3297 `Loop_Variant` can only appear as one of the items in the sequence
3298 of statements of a loop body, or nested inside block statements that
3299 appear in the sequence of statements of a loop body.
3300 It allows the specification of quantities which must always
3301 decrease or increase in successive iterations of the loop. In its simplest
3302 form, just one expression is specified, whose value must increase or decrease
3303 on each iteration of the loop.
3305 In a more complex form, multiple arguments can be given which are intepreted
3306 in a nesting lexicographic manner. For example:
3308 .. code-block:: ada
3310   pragma Loop_Variant (Increases => X, Decreases => Y);
3313 specifies that each time through the loop either X increases, or X stays
3314 the same and Y decreases. A `Loop_Variant` pragma ensures that the
3315 loop is making progress. It can be useful in helping to show informally
3316 or prove formally that the loop always terminates.
3318 `Loop_Variant` is an assertion whose effect can be controlled using
3319 an `Assertion_Policy` with a check name of `Loop_Variant`. The
3320 policy can be `Check` to enable the loop variant check, `Ignore`
3321 to ignore the check (in which case the pragma has no effect on the program),
3322 or `Disable` in which case the pragma is not even checked for correct
3323 syntax.
3325 Multiple `Loop_Invariant` and `Loop_Variant` pragmas that
3326 apply to the same loop should be grouped in the same sequence of
3327 statements.
3329 The `Loop_Entry` attribute may be used within the expressions of the
3330 `Loop_Variant` pragma to refer to values on entry to the loop.
3332 Pragma Machine_Attribute
3333 ========================
3335 Syntax:
3340   pragma Machine_Attribute (
3341        [Entity         =>] LOCAL_NAME,
3342        [Attribute_Name =>] static_string_EXPRESSION
3343     [, [Info           =>] static_EXPRESSION] );
3346 Machine-dependent attributes can be specified for types and/or
3347 declarations.  This pragma is semantically equivalent to
3348 `__attribute__((`attribute_name`))` (if `info` is not
3349 specified) or `__attribute__((`attribute_name`(`info`)))
3350 in GNU C, where ``attribute_name`` is recognized by the
3351 compiler middle-end or the `TARGET_ATTRIBUTE_TABLE` machine
3352 specific macro.  A string literal for the optional parameter `info`
3353 is transformed into an identifier, which may make this pragma unusable
3354 for some attributes.
3355 For further information see :title:`GNU Compiler Collection (GCC) Internals`.
3357 Pragma Main
3358 ===========
3360 Syntax::
3362   pragma Main
3363    (MAIN_OPTION [, MAIN_OPTION]);
3365   MAIN_OPTION ::=
3366     [Stack_Size              =>] static_integer_EXPRESSION
3367   | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3368   | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3371 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3372 no effect in GNAT, other than being syntax checked.
3374 Pragma Main_Storage
3375 ===================
3377 Syntax::
3379   pragma Main_Storage
3380     (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3382   MAIN_STORAGE_OPTION ::=
3383     [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3384   | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3387 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3388 no effect in GNAT, other than being syntax checked.
3390 Pragma No_Body
3391 ==============
3393 Syntax:
3396 .. code-block:: ada
3398   pragma No_Body;
3401 There are a number of cases in which a package spec does not require a body,
3402 and in fact a body is not permitted. GNAT will not permit the spec to be
3403 compiled if there is a body around. The pragma No_Body allows you to provide
3404 a body file, even in a case where no body is allowed. The body file must
3405 contain only comments and a single No_Body pragma. This is recognized by
3406 the compiler as indicating that no body is logically present.
3408 This is particularly useful during maintenance when a package is modified in
3409 such a way that a body needed before is no longer needed. The provision of a
3410 dummy body with a No_Body pragma ensures that there is no interference from
3411 earlier versions of the package body.
3413 Pragma No_Elaboration_Code_All
3414 ==============================
3416 Syntax:
3421   pragma No_Elaboration_Code_All [(program_unit_NAME)];
3424 This is a program unit pragma (there is also an equivalent aspect of the
3425 same name) that establishes the restriction `No_Elaboration_Code` for
3426 the current unit and any extended main source units (body and subunits.
3427 It also has has the effect of enforcing a transitive application of this
3428 aspect, so that if any unit is implicitly or explicitly WITH'ed by the
3429 current unit, it must also have the No_Elaboration_Code_All aspect set.
3430 It may be applied to package or subprogram specs or their generic versions.
3432 Pragma No_Inline
3433 ================
3435 Syntax:
3440   pragma No_Inline (NAME {, NAME});
3443 This pragma suppresses inlining for the callable entity or the instances of
3444 the generic subprogram designated by `NAME`, including inlining that
3445 results from the use of pragma `Inline`.  This pragma is always active,
3446 in particular it is not subject to the use of option *-gnatn* or
3447 *-gnatN*.  It is illegal to specify both pragma `No_Inline` and
3448 pragma `Inline_Always` for the same `NAME`.
3450 Pragma No_Return
3451 ================
3453 Syntax:
3458   pragma No_Return (procedure_LOCAL_NAME {, procedure_LOCAL_NAME});
3461 Each `procedure_LOCAL_NAME` argument must refer to one or more procedure
3462 declarations in the current declarative part.  A procedure to which this
3463 pragma is applied may not contain any explicit `return` statements.
3464 In addition, if the procedure contains any implicit returns from falling
3465 off the end of a statement sequence, then execution of that implicit
3466 return will cause Program_Error to be raised.
3468 One use of this pragma is to identify procedures whose only purpose is to raise
3469 an exception. Another use of this pragma is to suppress incorrect warnings
3470 about missing returns in functions, where the last statement of a function
3471 statement sequence is a call to such a procedure.
3473 Note that in Ada 2005 mode, this pragma is part of the language. It is
3474 available in all earlier versions of Ada as an implementation-defined
3475 pragma.
3477 Pragma No_Run_Time
3478 ==================
3480 Syntax:
3483 .. code-block:: ada
3485   pragma No_Run_Time;
3488 This is an obsolete configuration pragma that historically was used to
3489 set up a runtime library with no object code. It is now used only for
3490 internal testing. The pragma has been superseded by the reconfigurable
3491 runtime capability of `GNAT`.
3493 Pragma No_Strict_Aliasing
3494 =========================
3496 Syntax:
3501   pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3504 `type_LOCAL_NAME` must refer to an access type
3505 declaration in the current declarative part.  The effect is to inhibit
3506 strict aliasing optimization for the given type.  The form with no
3507 arguments is a configuration pragma which applies to all access types
3508 declared in units to which the pragma applies. For a detailed
3509 description of the strict aliasing optimization, and the situations
3510 in which it must be suppressed, see the section on Optimization and Strict Aliasing
3511 in the :title:`GNAT User's Guide`.
3513 This pragma currently has no effects on access to unconstrained array types.
3515 Pragma No_Tagged_Streams
3516 ========================
3518 Syntax:
3523   pragma No_Tagged_Streams;
3524   pragma No_Tagged_Streams [([Entity =>] tagged_type_LOCAL_NAME)];
3527 Normally when a tagged type is introduced using a full type declaration,
3528 part of the processing includes generating stream access routines to be
3529 used by stream attributes referencing the type (or one of its subtypes
3530 or derived types). This can involve the generation of significant amounts
3531 of code which is wasted space if stream routines are not needed for the
3532 type in question.
3534 The `No_Tagged_Streams` pragma causes the generation of these stream
3535 routines to be skipped, and any attempt to use stream operations on
3536 types subject to this pragma will be statically rejected as illegal.
3538 There are two forms of the pragma. The form with no arguments must appear
3539 in a declarative sequence or in the declarations of a package spec. This
3540 pragma affects all subsequent root tagged types declared in the declaration
3541 sequence, and specifies that no stream routines be generated. The form with
3542 an argument (for which there is also a corresponding aspect) specifies a
3543 single root tagged type for which stream routines are not to be generated.
3545 Once the pragma has been given for a particular root tagged type, all subtypes
3546 and derived types of this type inherit the pragma automatically, so the effect
3547 applies to a complete hierarchy (this is necessary to deal with the class-wide
3548 dispatching versions of the stream routines).
3550 Pragma Normalize_Scalars
3551 ========================
3553 Syntax:
3556 .. code-block:: ada
3558   pragma Normalize_Scalars;
3561 This is a language defined pragma which is fully implemented in GNAT.  The
3562 effect is to cause all scalar objects that are not otherwise initialized
3563 to be initialized.  The initial values are implementation dependent and
3564 are as follows:
3568 *Standard.Character*
3569   Objects whose root type is Standard.Character are initialized to
3570   Character'Last unless the subtype range excludes NUL (in which case
3571   NUL is used). This choice will always generate an invalid value if
3572   one exists.
3575 *Standard.Wide_Character*
3576   Objects whose root type is Standard.Wide_Character are initialized to
3577   Wide_Character'Last unless the subtype range excludes NUL (in which case
3578   NUL is used). This choice will always generate an invalid value if
3579   one exists.
3582 *Standard.Wide_Wide_Character*
3583   Objects whose root type is Standard.Wide_Wide_Character are initialized to
3584   the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3585   which case NUL is used). This choice will always generate an invalid value if
3586   one exists.
3589 *Integer types*
3590   Objects of an integer type are treated differently depending on whether
3591   negative values are present in the subtype. If no negative values are
3592   present, then all one bits is used as the initial value except in the
3593   special case where zero is excluded from the subtype, in which case
3594   all zero bits are used. This choice will always generate an invalid
3595   value if one exists.
3597   For subtypes with negative values present, the largest negative number
3598   is used, except in the unusual case where this largest negative number
3599   is in the subtype, and the largest positive number is not, in which case
3600   the largest positive value is used. This choice will always generate
3601   an invalid value if one exists.
3604 *Floating-Point Types*
3605   Objects of all floating-point types are initialized to all 1-bits. For
3606   standard IEEE format, this corresponds to a NaN (not a number) which is
3607   indeed an invalid value.
3610 *Fixed-Point Types*
3611   Objects of all fixed-point types are treated as described above for integers,
3612   with the rules applying to the underlying integer value used to represent
3613   the fixed-point value.
3616 *Modular types*
3617   Objects of a modular type are initialized to all one bits, except in
3618   the special case where zero is excluded from the subtype, in which
3619   case all zero bits are used. This choice will always generate an
3620   invalid value if one exists.
3623 *Enumeration types*
3624   Objects of an enumeration type are initialized to all one-bits, i.e., to
3625   the value `2 ** typ'Size - 1` unless the subtype excludes the literal
3626   whose Pos value is zero, in which case a code of zero is used. This choice
3627   will always generate an invalid value if one exists.
3629 .. _Pragma_Obsolescent:
3631 Pragma Obsolescent
3632 ==================
3634 Syntax:
3639   pragma Obsolescent;
3641   pragma Obsolescent (
3642     [Message =>] static_string_EXPRESSION
3643   [,[Version =>] Ada_05]]);
3645   pragma Obsolescent (
3646     [Entity  =>] NAME
3647   [,[Message =>] static_string_EXPRESSION
3648   [,[Version =>] Ada_05]] );
3651 This pragma can occur immediately following a declaration of an entity,
3652 including the case of a record component. If no Entity argument is present,
3653 then this declaration is the one to which the pragma applies. If an Entity
3654 parameter is present, it must either match the name of the entity in this
3655 declaration, or alternatively, the pragma can immediately follow an enumeration
3656 type declaration, where the Entity argument names one of the enumeration
3657 literals.
3659 This pragma is used to indicate that the named entity
3660 is considered obsolescent and should not be used. Typically this is
3661 used when an API must be modified by eventually removing or modifying
3662 existing subprograms or other entities. The pragma can be used at an
3663 intermediate stage when the entity is still present, but will be
3664 removed later.
3666 The effect of this pragma is to output a warning message on a reference to
3667 an entity thus marked that the subprogram is obsolescent if the appropriate
3668 warning option in the compiler is activated. If the Message parameter is
3669 present, then a second warning message is given containing this text. In
3670 addition, a reference to the entity is considered to be a violation of pragma
3671 Restrictions (No_Obsolescent_Features).
3673 This pragma can also be used as a program unit pragma for a package,
3674 in which case the entity name is the name of the package, and the
3675 pragma indicates that the entire package is considered
3676 obsolescent. In this case a client `with`'ing such a package
3677 violates the restriction, and the `with` statement is
3678 flagged with warnings if the warning option is set.
3680 If the Version parameter is present (which must be exactly
3681 the identifier Ada_05, no other argument is allowed), then the
3682 indication of obsolescence applies only when compiling in Ada 2005
3683 mode. This is primarily intended for dealing with the situations
3684 in the predefined library where subprograms or packages
3685 have become defined as obsolescent in Ada 2005
3686 (e.g., in Ada.Characters.Handling), but may be used anywhere.
3688 The following examples show typical uses of this pragma:
3691 .. code-block:: ada
3693   package p is
3694      pragma Obsolescent (p, Message => "use pp instead of p");
3695   end p;
3697   package q is
3698      procedure q2;
3699      pragma Obsolescent ("use q2new instead");
3701      type R is new integer;
3702      pragma Obsolescent
3703        (Entity  => R,
3704         Message => "use RR in Ada 2005",
3705         Version => Ada_05);
3707      type M is record
3708         F1 : Integer;
3709         F2 : Integer;
3710         pragma Obsolescent;
3711         F3 : Integer;
3712      end record;
3714      type E is (a, bc, 'd', quack);
3715      pragma Obsolescent (Entity => bc)
3716      pragma Obsolescent (Entity => 'd')
3718      function "+"
3719        (a, b : character) return character;
3720      pragma Obsolescent (Entity => "+");
3721   end;
3724 Note that, as for all pragmas, if you use a pragma argument identifier,
3725 then all subsequent parameters must also use a pragma argument identifier.
3726 So if you specify "Entity =>" for the Entity argument, and a Message
3727 argument is present, it must be preceded by "Message =>".
3729 Pragma Optimize_Alignment
3730 =========================
3731 .. index:: Alignment, default settings
3733 Syntax:
3736 .. code-block:: ada
3738   pragma Optimize_Alignment (TIME | SPACE | OFF);
3741 This is a configuration pragma which affects the choice of default alignments
3742 for types and objects where no alignment is explicitly specified. There is a
3743 time/space trade-off in the selection of these values. Large alignments result
3744 in more efficient code, at the expense of larger data space, since sizes have
3745 to be increased to match these alignments. Smaller alignments save space, but
3746 the access code is slower. The normal choice of default alignments for types
3747 and individual alignment promotions for objects (which is what you get if you
3748 do not use this pragma, or if you use an argument of OFF), tries to balance
3749 these two requirements.
3751 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3752 First any packed record is given an alignment of 1. Second, if a size is given
3753 for the type, then the alignment is chosen to avoid increasing this size. For
3754 example, consider:
3757 .. code-block:: ada
3759      type R is record
3760         X : Integer;
3761         Y : Character;
3762      end record;
3764      for R'Size use 5*8;
3767 In the default mode, this type gets an alignment of 4, so that access to the
3768 Integer field X are efficient. But this means that objects of the type end up
3769 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3770 allowed to be bigger than the size of the type, but it can waste space if for
3771 example fields of type R appear in an enclosing record. If the above type is
3772 compiled in `Optimize_Alignment (Space)` mode, the alignment is set to 1.
3774 However, there is one case in which SPACE is ignored. If a variable length
3775 record (that is a discriminated record with a component which is an array
3776 whose length depends on a discriminant), has a pragma Pack, then it is not
3777 in general possible to set the alignment of such a record to one, so the
3778 pragma is ignored in this case (with a warning).
3780 Specifying SPACE also disables alignment promotions for standalone objects,
3781 which occur when the compiler increases the alignment of a specific object
3782 without changing the alignment of its type.
3784 Specifying TIME causes larger default alignments to be chosen in the case of
3785 small types with sizes that are not a power of 2. For example, consider:
3788 .. code-block:: ada
3790      type R is record
3791         A : Character;
3792         B : Character;
3793         C : Boolean;
3794      end record;
3796      pragma Pack (R);
3797      for R'Size use 17;
3800 The default alignment for this record is normally 1, but if this type is
3801 compiled in `Optimize_Alignment (Time)` mode, then the alignment is set
3802 to 4, which wastes space for objects of the type, since they are now 4 bytes
3803 long, but results in more efficient access when the whole record is referenced.
3805 As noted above, this is a configuration pragma, and there is a requirement
3806 that all units in a partition be compiled with a consistent setting of the
3807 optimization setting. This would normally be achieved by use of a configuration
3808 pragma file containing the appropriate setting. The exception to this rule is
3809 that units with an explicit configuration pragma in the same file as the source
3810 unit are excluded from the consistency check, as are all predefined units. The
3811 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3812 pragma appears at the start of the file.
3814 Pragma Ordered
3815 ==============
3817 Syntax:
3820 .. code-block:: ada
3822   pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3825 Most enumeration types are from a conceptual point of view unordered.
3826 For example, consider:
3829 .. code-block:: ada
3831   type Color is (Red, Blue, Green, Yellow);
3834 By Ada semantics `Blue > Red` and `Green > Blue`,
3835 but really these relations make no sense; the enumeration type merely
3836 specifies a set of possible colors, and the order is unimportant.
3838 For unordered enumeration types, it is generally a good idea if
3839 clients avoid comparisons (other than equality or inequality) and
3840 explicit ranges. (A *client* is a unit where the type is referenced,
3841 other than the unit where the type is declared, its body, and its subunits.)
3842 For example, if code buried in some client says:
3845 .. code-block:: ada
3847   if Current_Color < Yellow then ...
3848   if Current_Color in Blue .. Green then ...
3851 then the client code is relying on the order, which is undesirable.
3852 It makes the code hard to read and creates maintenance difficulties if
3853 entries have to be added to the enumeration type. Instead,
3854 the code in the client should list the possibilities, or an
3855 appropriate subtype should be declared in the unit that declares
3856 the original enumeration type. E.g., the following subtype could
3857 be declared along with the type `Color`:
3860 .. code-block:: ada
3862   subtype RBG is Color range Red .. Green;
3865 and then the client could write:
3868 .. code-block:: ada
3870   if Current_Color in RBG then ...
3871   if Current_Color = Blue or Current_Color = Green then ...
3874 However, some enumeration types are legitimately ordered from a conceptual
3875 point of view. For example, if you declare:
3878 .. code-block:: ada
3880   type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3883 then the ordering imposed by the language is reasonable, and
3884 clients can depend on it, writing for example:
3887 .. code-block:: ada
3889   if D in Mon .. Fri then ...
3890   if D < Wed then ...
3893 The pragma *Ordered* is provided to mark enumeration types that
3894 are conceptually ordered, alerting the reader that clients may depend
3895 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3896 rather than one to mark them as unordered, since in our experience,
3897 the great majority of enumeration types are conceptually unordered.
3899 The types `Boolean`, `Character`, `Wide_Character`,
3900 and `Wide_Wide_Character`
3901 are considered to be ordered types, so each is declared with a
3902 pragma `Ordered` in package `Standard`.
3904 Normally pragma `Ordered` serves only as documentation and a guide for
3905 coding standards, but GNAT provides a warning switch *-gnatw.u* that
3906 requests warnings for inappropriate uses (comparisons and explicit
3907 subranges) for unordered types. If this switch is used, then any
3908 enumeration type not marked with pragma `Ordered` will be considered
3909 as unordered, and will generate warnings for inappropriate uses.
3911 Note that generic types are not considered ordered or unordered (since the
3912 template can be instantiated for both cases), so we never generate warnings
3913 for the case of generic enumerated types.
3915 For additional information please refer to the description of the
3916 *-gnatw.u* switch in the GNAT User's Guide.
3918 Pragma Overflow_Mode
3919 ====================
3921 Syntax:
3926   pragma Overflow_Mode
3927    (  [General    =>] MODE
3928     [,[Assertions =>] MODE]);
3930   MODE ::= STRICT | MINIMIZED | ELIMINATED
3933 This pragma sets the current overflow mode to the given setting. For details
3934 of the meaning of these modes, please refer to the
3935 'Overflow Check Handling in GNAT' appendix in the
3936 GNAT User's Guide. If only the `General` parameter is present,
3937 the given mode applies to all expressions. If both parameters are present,
3938 the `General` mode applies to expressions outside assertions, and
3939 the `Eliminated` mode applies to expressions within assertions.
3941 The case of the `MODE` parameter is ignored,
3942 so `MINIMIZED`, `Minimized` and
3943 `minimized` all have the same effect.
3945 The `Overflow_Mode` pragma has the same scoping and placement
3946 rules as pragma `Suppress`, so it can occur either as a
3947 configuration pragma, specifying a default for the whole
3948 program, or in a declarative scope, where it applies to the
3949 remaining declarations and statements in that scope.
3951 The pragma `Suppress (Overflow_Check)` suppresses
3952 overflow checking, but does not affect the overflow mode.
3954 The pragma `Unsuppress (Overflow_Check)` unsuppresses (enables)
3955 overflow checking, but does not affect the overflow mode.
3957 Pragma Overriding_Renamings
3958 ===========================
3959 .. index:: Rational profile
3961 .. index:: Rational compatibility
3963 Syntax:
3966 .. code-block:: ada
3968   pragma Overriding_Renamings;
3971 This is a GNAT configuration pragma to simplify porting
3972 legacy code accepted by the Rational
3973 Ada compiler. In the presence of this pragma, a renaming declaration that
3974 renames an inherited operation declared in the same scope is legal if selected
3975 notation is used as in:
3978 .. code-block:: ada
3980   pragma Overriding_Renamings;
3981   ...
3982   package R is
3983     function F (..);
3984     ...
3985     function F (..) renames R.F;
3986   end R;
3989 even though
3990 RM 8.3 (15) stipulates that an overridden operation is not visible within the
3991 declaration of the overriding operation.
3993 Pragma Partition_Elaboration_Policy
3994 ===================================
3996 Syntax:
4001   pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4003   POLICY_IDENTIFIER ::= Concurrent | Sequential
4006 This pragma is standard in Ada 2005, but is available in all earlier
4007 versions of Ada as an implementation-defined pragma.
4008 See Ada 2012 Reference Manual for details.
4010 Pragma Part_Of
4011 ==============
4013 For the description of this pragma, see SPARK 2014 Reference Manual,
4014 section 7.2.6.
4016 Pragma Passive
4017 ==============
4019 Syntax:
4024   pragma Passive [(Semaphore | No)];
4027 Syntax checked, but otherwise ignored by GNAT.  This is recognized for
4028 compatibility with DEC Ada 83 implementations, where it is used within a
4029 task definition to request that a task be made passive.  If the argument
4030 `Semaphore` is present, or the argument is omitted, then DEC Ada 83
4031 treats the pragma as an assertion that the containing task is passive
4032 and that optimization of context switch with this task is permitted and
4033 desired.  If the argument `No` is present, the task must not be
4034 optimized.  GNAT does not attempt to optimize any tasks in this manner
4035 (since protected objects are available in place of passive tasks).
4037 For more information on the subject of passive tasks, see the section
4038 'Passive Task Optimization' in the GNAT Users Guide.
4040 Pragma Persistent_BSS
4041 =====================
4043 Syntax:
4048   pragma Persistent_BSS [(LOCAL_NAME)]
4051 This pragma allows selected objects to be placed in the `.persistent_bss`
4052 section. On some targets the linker and loader provide for special
4053 treatment of this section, allowing a program to be reloaded without
4054 affecting the contents of this data (hence the name persistent).
4056 There are two forms of usage. If an argument is given, it must be the
4057 local name of a library level object, with no explicit initialization
4058 and whose type is potentially persistent. If no argument is given, then
4059 the pragma is a configuration pragma, and applies to all library level
4060 objects with no explicit initialization of potentially persistent types.
4062 A potentially persistent type is a scalar type, or an untagged,
4063 non-discriminated record, all of whose components have no explicit
4064 initialization and are themselves of a potentially persistent type,
4065 or an array, all of whose constraints are static, and whose component
4066 type is potentially persistent.
4068 If this pragma is used on a target where this feature is not supported,
4069 then the pragma will be ignored. See also `pragma Linker_Section`.
4071 Pragma Polling
4072 ==============
4074 Syntax:
4077 .. code-block:: ada
4079   pragma Polling (ON | OFF);
4082 This pragma controls the generation of polling code.  This is normally off.
4083 If `pragma Polling (ON)` is used then periodic calls are generated to
4084 the routine `Ada.Exceptions.Poll`.  This routine is a separate unit in the
4085 runtime library, and can be found in file :file:`a-excpol.adb`.
4087 Pragma `Polling` can appear as a configuration pragma (for example it
4088 can be placed in the :file:`gnat.adc` file) to enable polling globally, or it
4089 can be used in the statement or declaration sequence to control polling
4090 more locally.
4092 A call to the polling routine is generated at the start of every loop and
4093 at the start of every subprogram call.  This guarantees that the `Poll`
4094 routine is called frequently, and places an upper bound (determined by
4095 the complexity of the code) on the period between two `Poll` calls.
4097 The primary purpose of the polling interface is to enable asynchronous
4098 aborts on targets that cannot otherwise support it (for example Windows
4099 NT), but it may be used for any other purpose requiring periodic polling.
4100 The standard version is null, and can be replaced by a user program.  This
4101 will require re-compilation of the `Ada.Exceptions` package that can
4102 be found in files :file:`a-except.ads` and :file:`a-except.adb`.
4104 A standard alternative unit (in file :file:`4wexcpol.adb` in the standard GNAT
4105 distribution) is used to enable the asynchronous abort capability on
4106 targets that do not normally support the capability.  The version of
4107 `Poll` in this file makes a call to the appropriate runtime routine
4108 to test for an abort condition.
4110 Note that polling can also be enabled by use of the *-gnatP* switch.
4111 See the section on switches for gcc in the :title:`GNAT User's Guide`.
4113 Pragma Post
4114 ===========
4115 .. index:: Post
4117 .. index:: Checks, postconditions
4120 Syntax:
4123 .. code-block:: ada
4125   pragma Post (Boolean_Expression);
4128 The `Post` pragma is intended to be an exact replacement for
4129 the language-defined
4130 `Post` aspect, and shares its restrictions and semantics.
4131 It must appear either immediately following the corresponding
4132 subprogram declaration (only other pragmas may intervene), or
4133 if there is no separate subprogram declaration, then it can
4134 appear at the start of the declarations in a subprogram body
4135 (preceded only by other pragmas).
4137 Pragma Postcondition
4138 ====================
4139 .. index:: Postcondition
4141 .. index:: Checks, postconditions
4144 Syntax:
4149   pragma Postcondition (
4150      [Check   =>] Boolean_Expression
4151    [,[Message =>] String_Expression]);
4154 The `Postcondition` pragma allows specification of automatic
4155 postcondition checks for subprograms. These checks are similar to
4156 assertions, but are automatically inserted just prior to the return
4157 statements of the subprogram with which they are associated (including
4158 implicit returns at the end of procedure bodies and associated
4159 exception handlers).
4161 In addition, the boolean expression which is the condition which
4162 must be true may contain references to function'Result in the case
4163 of a function to refer to the returned value.
4165 `Postcondition` pragmas may appear either immediately following the
4166 (separate) declaration of a subprogram, or at the start of the
4167 declarations of a subprogram body. Only other pragmas may intervene
4168 (that is appear between the subprogram declaration and its
4169 postconditions, or appear before the postcondition in the
4170 declaration sequence in a subprogram body). In the case of a
4171 postcondition appearing after a subprogram declaration, the
4172 formal arguments of the subprogram are visible, and can be
4173 referenced in the postcondition expressions.
4175 The postconditions are collected and automatically tested just
4176 before any return (implicit or explicit) in the subprogram body.
4177 A postcondition is only recognized if postconditions are active
4178 at the time the pragma is encountered. The compiler switch *gnata*
4179 turns on all postconditions by default, and pragma `Check_Policy`
4180 with an identifier of `Postcondition` can also be used to
4181 control whether postconditions are active.
4183 The general approach is that postconditions are placed in the spec
4184 if they represent functional aspects which make sense to the client.
4185 For example we might have:
4188 .. code-block:: ada
4190      function Direction return Integer;
4191      pragma Postcondition
4192       (Direction'Result = +1
4193          or else
4194        Direction'Result = -1);
4197 which serves to document that the result must be +1 or -1, and
4198 will test that this is the case at run time if postcondition
4199 checking is active.
4201 Postconditions within the subprogram body can be used to
4202 check that some internal aspect of the implementation,
4203 not visible to the client, is operating as expected.
4204 For instance if a square root routine keeps an internal
4205 counter of the number of times it is called, then we
4206 might have the following postcondition:
4209 .. code-block:: ada
4211      Sqrt_Calls : Natural := 0;
4213      function Sqrt (Arg : Float) return Float is
4214        pragma Postcondition
4215          (Sqrt_Calls = Sqrt_Calls'Old + 1);
4216        ...
4217      end Sqrt
4220 As this example, shows, the use of the `Old` attribute
4221 is often useful in postconditions to refer to the state on
4222 entry to the subprogram.
4224 Note that postconditions are only checked on normal returns
4225 from the subprogram. If an abnormal return results from
4226 raising an exception, then the postconditions are not checked.
4228 If a postcondition fails, then the exception
4229 `System.Assertions.Assert_Failure` is raised. If
4230 a message argument was supplied, then the given string
4231 will be used as the exception message. If no message
4232 argument was supplied, then the default message has
4233 the form "Postcondition failed at file_name:line". The
4234 exception is raised in the context of the subprogram
4235 body, so it is possible to catch postcondition failures
4236 within the subprogram body itself.
4238 Within a package spec, normal visibility rules
4239 in Ada would prevent forward references within a
4240 postcondition pragma to functions defined later in
4241 the same package. This would introduce undesirable
4242 ordering constraints. To avoid this problem, all
4243 postcondition pragmas are analyzed at the end of
4244 the package spec, allowing forward references.
4246 The following example shows that this even allows
4247 mutually recursive postconditions as in:
4250 .. code-block:: ada
4252   package Parity_Functions is
4253      function Odd  (X : Natural) return Boolean;
4254      pragma Postcondition
4255        (Odd'Result =
4256           (x = 1
4257             or else
4258           (x /= 0 and then Even (X - 1))));
4260      function Even (X : Natural) return Boolean;
4261      pragma Postcondition
4262        (Even'Result =
4263           (x = 0
4264             or else
4265           (x /= 1 and then Odd (X - 1))));
4267   end Parity_Functions;
4270 There are no restrictions on the complexity or form of
4271 conditions used within `Postcondition` pragmas.
4272 The following example shows that it is even possible
4273 to verify performance behavior.
4276 .. code-block:: ada
4278   package Sort is
4280      Performance : constant Float;
4281      --  Performance constant set by implementation
4282      --  to match target architecture behavior.
4284      procedure Treesort (Arg : String);
4285      --  Sorts characters of argument using N*logN sort
4286      pragma Postcondition
4287        (Float (Clock - Clock'Old) <=
4288           Float (Arg'Length) *
4289           log (Float (Arg'Length)) *
4290           Performance);
4291   end Sort;
4294 Note: postcondition pragmas associated with subprograms that are
4295 marked as Inline_Always, or those marked as Inline with front-end
4296 inlining (-gnatN option set) are accepted and legality-checked
4297 by the compiler, but are ignored at run-time even if postcondition
4298 checking is enabled.
4300 Note that pragma `Postcondition` differs from the language-defined
4301 `Post` aspect (and corresponding `Post` pragma) in allowing
4302 multiple occurrences, allowing occurences in the body even if there
4303 is a separate spec, and allowing a second string parameter, and the
4304 use of the pragma identifier `Check`. Historically, pragma
4305 `Postcondition` was implemented prior to the development of
4306 Ada 2012, and has been retained in its original form for
4307 compatibility purposes.
4309 Pragma Post_Class
4310 =================
4311 .. index:: Post
4313 .. index:: Checks, postconditions
4316 Syntax:
4319 .. code-block:: ada
4321   pragma Post_Class (Boolean_Expression);
4324 The `Post_Class` pragma is intended to be an exact replacement for
4325 the language-defined
4326 `Post'Class` aspect, and shares its restrictions and semantics.
4327 It must appear either immediately following the corresponding
4328 subprogram declaration (only other pragmas may intervene), or
4329 if there is no separate subprogram declaration, then it can
4330 appear at the start of the declarations in a subprogram body
4331 (preceded only by other pragmas).
4333 Note: This pragma is called `Post_Class` rather than
4334 `Post'Class` because the latter would not be strictly
4335 conforming to the allowed syntax for pragmas. The motivation
4336 for provinding pragmas equivalent to the aspects is to allow a program
4337 to be written using the pragmas, and then compiled if necessary
4338 using an Ada compiler that does not recognize the pragmas or
4339 aspects, but is prepared to ignore the pragmas. The assertion
4340 policy that controls this pragma is `Post'Class`, not
4341 `Post_Class`.
4343 Pragma Pre
4344 ==========
4345 .. index:: Pre
4347 .. index:: Checks, preconditions
4350 Syntax:
4353 .. code-block:: ada
4355   pragma Pre (Boolean_Expression);
4358 The `Pre` pragma is intended to be an exact replacement for
4359 the language-defined
4360 `Pre` aspect, and shares its restrictions and semantics.
4361 It must appear either immediately following the corresponding
4362 subprogram declaration (only other pragmas may intervene), or
4363 if there is no separate subprogram declaration, then it can
4364 appear at the start of the declarations in a subprogram body
4365 (preceded only by other pragmas).
4367 Pragma Precondition
4368 ===================
4369 .. index:: Preconditions
4371 .. index:: Checks, preconditions
4374 Syntax:
4379   pragma Precondition (
4380      [Check   =>] Boolean_Expression
4381    [,[Message =>] String_Expression]);
4384 The `Precondition` pragma is similar to `Postcondition`
4385 except that the corresponding checks take place immediately upon
4386 entry to the subprogram, and if a precondition fails, the exception
4387 is raised in the context of the caller, and the attribute 'Result
4388 cannot be used within the precondition expression.
4390 Otherwise, the placement and visibility rules are identical to those
4391 described for postconditions. The following is an example of use
4392 within a package spec:
4395 .. code-block:: ada
4397   package Math_Functions is
4398      ...
4399      function Sqrt (Arg : Float) return Float;
4400      pragma Precondition (Arg >= 0.0)
4401      ...
4402   end Math_Functions;
4405 `Precondition` pragmas may appear either immediately following the
4406 (separate) declaration of a subprogram, or at the start of the
4407 declarations of a subprogram body. Only other pragmas may intervene
4408 (that is appear between the subprogram declaration and its
4409 postconditions, or appear before the postcondition in the
4410 declaration sequence in a subprogram body).
4412 Note: precondition pragmas associated with subprograms that are
4413 marked as Inline_Always, or those marked as Inline with front-end
4414 inlining (-gnatN option set) are accepted and legality-checked
4415 by the compiler, but are ignored at run-time even if precondition
4416 checking is enabled.
4418 Note that pragma `Precondition` differs from the language-defined
4419 `Pre` aspect (and corresponding `Pre` pragma) in allowing
4420 multiple occurrences, allowing occurences in the body even if there
4421 is a separate spec, and allowing a second string parameter, and the
4422 use of the pragma identifier `Check`. Historically, pragma
4423 `Precondition` was implemented prior to the development of
4424 Ada 2012, and has been retained in its original form for
4425 compatibility purposes.
4427 Pragma Predicate
4428 ================
4430 Syntax:
4435   pragma Predicate
4436     ([Entity =>] type_LOCAL_NAME,
4437      [Check  =>] EXPRESSION);
4440 This pragma (available in all versions of Ada in GNAT) encompasses both
4441 the `Static_Predicate` and `Dynamic_Predicate` aspects in
4442 Ada 2012. A predicate is regarded as static if it has an allowed form
4443 for `Static_Predicate` and is otherwise treated as a
4444 `Dynamic_Predicate`. Otherwise, predicates specified by this
4445 pragma behave exactly as described in the Ada 2012 reference manual.
4446 For example, if we have
4449 .. code-block:: ada
4451   type R is range 1 .. 10;
4452   subtype S is R;
4453   pragma Predicate (Entity => S, Check => S not in 4 .. 6);
4454   subtype Q is R
4455   pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
4458 the effect is identical to the following Ada 2012 code:
4461 .. code-block:: ada
4463   type R is range 1 .. 10;
4464   subtype S is R with
4465     Static_Predicate => S not in 4 .. 6;
4466   subtype Q is R with
4467     Dynamic_Predicate => F(Q) or G(Q);
4470 Note that there is are no pragmas `Dynamic_Predicate`
4471 or `Static_Predicate`. That is
4472 because these pragmas would affect legality and semantics of
4473 the program and thus do not have a neutral effect if ignored.
4474 The motivation behind providing pragmas equivalent to
4475 corresponding aspects is to allow a program to be written
4476 using the pragmas, and then compiled with a compiler that
4477 will ignore the pragmas. That doesn't work in the case of
4478 static and dynamic predicates, since if the corresponding
4479 pragmas are ignored, then the behavior of the program is
4480 fundamentally changed (for example a membership test
4481 `A in B` would not take into account a predicate
4482 defined for subtype B). When following this approach, the
4483 use of predicates should be avoided.
4485 Pragma Preelaborable_Initialization
4486 ===================================
4488 Syntax:
4491 .. code-block:: ada
4493   pragma Preelaborable_Initialization (DIRECT_NAME);
4496 This pragma is standard in Ada 2005, but is available in all earlier
4497 versions of Ada as an implementation-defined pragma.
4498 See Ada 2012 Reference Manual for details.
4500 Pragma Prefix_Exception_Messages
4501 ================================
4502 .. index:: Prefix_Exception_Messages
4504 .. index:: exception
4506 .. index:: Exception_Message
4509 Syntax:
4512 .. code-block:: ada
4514   pragma Prefix_Exception_Messages;
4517 This is an implementation-defined configuration pragma that affects the
4518 behavior of raise statements with a message given as a static string
4519 constant (typically a string literal). In such cases, the string will
4520 be automatically prefixed by the name of the enclosing entity (giving
4521 the package and subprogram containing the raise statement). This helps
4522 to identify where messages are coming from, and this mode is automatic
4523 for the run-time library.
4525 The pragma has no effect if the message is computed with an expression other
4526 than a static string constant, since the assumption in this case is that
4527 the program computes exactly the string it wants. If you still want the
4528 prefixing in this case, you can always call
4529 `GNAT.Source_Info.Enclosing_Entity` and prepend the string manually.
4531 Pragma Pre_Class
4532 ================
4533 .. index:: Pre_Class
4535 .. index:: Checks, preconditions
4538 Syntax:
4541 .. code-block:: ada
4543   pragma Pre_Class (Boolean_Expression);
4546 The `Pre_Class` pragma is intended to be an exact replacement for
4547 the language-defined
4548 `Pre'Class` aspect, and shares its restrictions and semantics.
4549 It must appear either immediately following the corresponding
4550 subprogram declaration (only other pragmas may intervene), or
4551 if there is no separate subprogram declaration, then it can
4552 appear at the start of the declarations in a subprogram body
4553 (preceded only by other pragmas).
4555 Note: This pragma is called `Pre_Class` rather than
4556 `Pre'Class` because the latter would not be strictly
4557 conforming to the allowed syntax for pragmas. The motivation
4558 for providing pragmas equivalent to the aspects is to allow a program
4559 to be written using the pragmas, and then compiled if necessary
4560 using an Ada compiler that does not recognize the pragmas or
4561 aspects, but is prepared to ignore the pragmas. The assertion
4562 policy that controls this pragma is `Pre'Class`, not
4563 `Pre_Class`.
4565 Pragma Priority_Specific_Dispatching
4566 ====================================
4568 Syntax:
4573   pragma Priority_Specific_Dispatching (
4574      POLICY_IDENTIFIER,
4575      first_priority_EXPRESSION,
4576      last_priority_EXPRESSION)
4578   POLICY_IDENTIFIER ::=
4579      EDF_Across_Priorities            |
4580      FIFO_Within_Priorities           |
4581      Non_Preemptive_Within_Priorities |
4582      Round_Robin_Within_Priorities
4585 This pragma is standard in Ada 2005, but is available in all earlier
4586 versions of Ada as an implementation-defined pragma.
4587 See Ada 2012 Reference Manual for details.
4589 Pragma Profile
4590 ==============
4592 Syntax:
4595 .. code-block:: ada
4597   pragma Profile (Ravenscar | Restricted | Rational);
4600 This pragma is standard in Ada 2005, but is available in all earlier
4601 versions of Ada as an implementation-defined pragma. This is a
4602 configuration pragma that establishes a set of configuration pragmas
4603 that depend on the argument. `Ravenscar` is standard in Ada 2005.
4604 The other two possibilities (`Restricted` or `Rational`)
4605 are implementation-defined. The set of configuration pragmas
4606 is defined in the following sections.
4609 * Pragma Profile (Ravenscar)
4611   The `Ravenscar` profile is standard in Ada 2005,
4612   but is available in all earlier
4613   versions of Ada as an implementation-defined pragma. This profile
4614   establishes the following set of configuration pragmas:
4616   * ``Task_Dispatching_Policy (FIFO_Within_Priorities)``
4618     [RM D.2.2] Tasks are dispatched following a preemptive
4619     priority-ordered scheduling policy.
4622   * ``Locking_Policy (Ceiling_Locking)``
4624     [RM D.3] While tasks and interrupts execute a protected action, they inherit
4625     the ceiling priority of the corresponding protected object.
4628   * ``Detect_Blocking``
4630     This pragma forces the detection of potentially blocking operations within a
4631     protected operation, and to raise Program_Error if that happens.
4633   plus the following set of restrictions:
4635   * ``Max_Entry_Queue_Length => 1``
4637     No task can be queued on a protected entry.
4639   * ``Max_Protected_Entries => 1``
4641   * ``Max_Task_Entries => 0``
4643     No rendezvous statements are allowed.
4645   * ``No_Abort_Statements``
4647   * ``No_Dynamic_Attachment``
4649   * ``No_Dynamic_Priorities``
4651   * ``No_Implicit_Heap_Allocations``
4653   * ``No_Local_Protected_Objects``
4655   * ``No_Local_Timing_Events``
4657   * ``No_Protected_Type_Allocators``
4659   * ``No_Relative_Delay``
4661   * ``No_Requeue_Statements``
4663   * ``No_Select_Statements``
4665   * ``No_Specific_Termination_Handlers``
4667   * ``No_Task_Allocators``
4669   * ``No_Task_Hierarchy``
4671   * ``No_Task_Termination``
4673   * ``Simple_Barriers``
4675   The Ravenscar profile also includes the following restrictions that specify
4676   that there are no semantic dependences on the corresponding predefined
4677   packages:
4679   * ``No_Dependence => Ada.Asynchronous_Task_Control``
4681   * ``No_Dependence => Ada.Calendar``
4683   * ``No_Dependence => Ada.Execution_Time.Group_Budget``
4685   * ``No_Dependence => Ada.Execution_Time.Timers``
4687   * ``No_Dependence => Ada.Task_Attributes``
4689   * ``No_Dependence => System.Multiprocessors.Dispatching_Domains``
4691   This set of configuration pragmas and restrictions correspond to the
4692   definition of the 'Ravenscar Profile' for limited tasking, devised and
4693   published by the :title:`International Real-Time Ada Workshop, 1997`.
4694   A description is also available at
4695   `http://www-users.cs.york.ac.uk/~burns/ravenscar.ps <http://www-users.cs.york.ac.uk/~burns/ravenscar.ps>`_.
4697   The original definition of the profile was revised at subsequent IRTAW
4698   meetings. It has been included in the ISO
4699   :title:`Guide for the Use of the Ada Programming Language in High Integrity Systems`,
4700   and was made part of the Ada 2005 standard.
4701   The formal definition given by
4702   the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4703   AI-305) available at
4704   `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
4705   `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>`_.
4707   The above set is a superset of the restrictions provided by pragma
4708   ``Profile (Restricted)``, it includes six additional restrictions
4709   (``Simple_Barriers``, ``No_Select_Statements``,
4710   ``No_Calendar``, ``No_Implicit_Heap_Allocations``,
4711   ``No_Relative_Delay`` and ``No_Task_Termination``).  This means
4712   that pragma ``Profile (Ravenscar)``, like the pragma
4713   ``Profile (Restricted)``,
4714   automatically causes the use of a simplified,
4715   more efficient version of the tasking run-time library.
4717 * Pragma Profile (Restricted)
4719   This profile corresponds to the GNAT restricted run time. It
4720   establishes the following set of restrictions:
4722   * ``No_Abort_Statements``
4723   * ``No_Entry_Queue``
4724   * ``No_Task_Hierarchy``
4725   * ``No_Task_Allocators``
4726   * ``No_Dynamic_Priorities``
4727   * ``No_Terminate_Alternatives``
4728   * ``No_Dynamic_Attachment``
4729   * ``No_Protected_Type_Allocators``
4730   * ``No_Local_Protected_Objects``
4731   * ``No_Requeue_Statements``
4732   * ``No_Task_Attributes_Package``
4733   * ``Max_Asynchronous_Select_Nesting =  0``
4734   * ``Max_Task_Entries =  0``
4735   * ``Max_Protected_Entries = 1``
4736   * ``Max_Select_Alternatives = 0``
4738   This set of restrictions causes the automatic selection of a simplified
4739   version of the run time that provides improved performance for the
4740   limited set of tasking functionality permitted by this set of restrictions.
4742 * Pragma Profile (Rational)
4744   The Rational profile is intended to facilitate porting legacy code that
4745   compiles with the Rational APEX compiler, even when the code includes non-
4746   conforming Ada constructs.  The profile enables the following three pragmas:
4748   * ``pragma Implicit_Packing``
4749   * ``pragma Overriding_Renamings``
4750   * ``pragma Use_VADS_Size``
4753 Pragma Profile_Warnings
4754 =======================
4756 Syntax:
4759 .. code-block:: ada
4761   pragma Profile_Warnings (Ravenscar | Restricted | Rational);
4764 This is an implementation-defined pragma that is similar in
4765 effect to `pragma Profile` except that instead of
4766 generating `Restrictions` pragmas, it generates
4767 `Restriction_Warnings` pragmas. The result is that
4768 violations of the profile generate warning messages instead
4769 of error messages.
4771 Pragma Propagate_Exceptions
4772 ===========================
4773 .. index:: Interfacing to C++
4776 Syntax:
4779 .. code-block:: ada
4781   pragma Propagate_Exceptions;
4784 This pragma is now obsolete and, other than generating a warning if warnings
4785 on obsolescent features are enabled, is ignored.
4786 It is retained for compatibility
4787 purposes. It used to be used in connection with optimization of
4788 a now-obsolete mechanism for implementation of exceptions.
4790 Pragma Provide_Shift_Operators
4791 ==============================
4792 .. index:: Shift operators
4795 Syntax:
4798 .. code-block:: ada
4800   pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
4803 This pragma can be applied to a first subtype local name that specifies
4804 either an unsigned or signed type. It has the effect of providing the
4805 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
4806 Rotate_Left and Rotate_Right) for the given type. It is similar to
4807 including the function declarations for these five operators, together
4808 with the pragma Import (Intrinsic, ...) statements.
4810 Pragma Psect_Object
4811 ===================
4813 Syntax:
4818   pragma Psect_Object (
4819        [Internal =>] LOCAL_NAME,
4820     [, [External =>] EXTERNAL_SYMBOL]
4821     [, [Size     =>] EXTERNAL_SYMBOL]);
4823   EXTERNAL_SYMBOL ::=
4824     IDENTIFIER
4825   | static_string_EXPRESSION
4828 This pragma is identical in effect to pragma `Common_Object`.
4830 Pragma Pure_Function
4831 ====================
4833 Syntax:
4838   pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4841 This pragma appears in the same declarative part as a function
4842 declaration (or a set of function declarations if more than one
4843 overloaded declaration exists, in which case the pragma applies
4844 to all entities).  It specifies that the function `Entity` is
4845 to be considered pure for the purposes of code generation.  This means
4846 that the compiler can assume that there are no side effects, and
4847 in particular that two calls with identical arguments produce the
4848 same result.  It also means that the function can be used in an
4849 address clause.
4851 Note that, quite deliberately, there are no static checks to try
4852 to ensure that this promise is met, so `Pure_Function` can be used
4853 with functions that are conceptually pure, even if they do modify
4854 global variables.  For example, a square root function that is
4855 instrumented to count the number of times it is called is still
4856 conceptually pure, and can still be optimized, even though it
4857 modifies a global variable (the count).  Memo functions are another
4858 example (where a table of previous calls is kept and consulted to
4859 avoid re-computation).
4861 Note also that the normal rules excluding optimization of subprograms
4862 in pure units (when parameter types are descended from System.Address,
4863 or when the full view of a parameter type is limited), do not apply
4864 for the Pure_Function case. If you explicitly specify Pure_Function,
4865 the compiler may optimize away calls with identical arguments, and
4866 if that results in unexpected behavior, the proper action is not to
4867 use the pragma for subprograms that are not (conceptually) pure.
4869 Note: Most functions in a `Pure` package are automatically pure, and
4870 there is no need to use pragma `Pure_Function` for such functions.  One
4871 exception is any function that has at least one formal of type
4872 `System.Address` or a type derived from it.  Such functions are not
4873 considered pure by default, since the compiler assumes that the
4874 `Address` parameter may be functioning as a pointer and that the
4875 referenced data may change even if the address value does not.
4876 Similarly, imported functions are not considered to be pure by default,
4877 since there is no way of checking that they are in fact pure.  The use
4878 of pragma `Pure_Function` for such a function will override these default
4879 assumption, and cause the compiler to treat a designated subprogram as pure
4880 in these cases.
4882 Note: If pragma `Pure_Function` is applied to a renamed function, it
4883 applies to the underlying renamed function.  This can be used to
4884 disambiguate cases of overloading where some but not all functions
4885 in a set of overloaded functions are to be designated as pure.
4887 If pragma `Pure_Function` is applied to a library level function, the
4888 function is also considered pure from an optimization point of view, but the
4889 unit is not a Pure unit in the categorization sense. So for example, a function
4890 thus marked is free to `with` non-pure units.
4892 Pragma Rational
4893 ===============
4895 Syntax:
4898 .. code-block:: ada
4900   pragma Rational;
4903 This pragma is considered obsolescent, but is retained for
4904 compatibility purposes. It is equivalent to:
4907 .. code-block:: ada
4909   pragma Profile (Rational);
4912 Pragma Ravenscar
4913 ================
4915 Syntax:
4918 .. code-block:: ada
4920   pragma Ravenscar;
4923 This pragma is considered obsolescent, but is retained for
4924 compatibility purposes. It is equivalent to:
4927 .. code-block:: ada
4929   pragma Profile (Ravenscar);
4932 which is the preferred method of setting the `Ravenscar` profile.
4934 Pragma Refined_Depends
4935 ======================
4937 For the description of this pragma, see SPARK 2014 Reference Manual,
4938 section 6.1.5.
4940 Pragma Refined_Global
4941 =====================
4943 For the description of this pragma, see SPARK 2014 Reference Manual,
4944 section 6.1.4.
4946 Pragma Refined_Post
4947 ===================
4949 For the description of this pragma, see SPARK 2014 Reference Manual,
4950 section 7.2.7.
4952 Pragma Refined_State
4953 ====================
4955 For the description of this pragma, see SPARK 2014 Reference Manual,
4956 section 7.2.2.
4958 Pragma Relative_Deadline
4959 ========================
4961 Syntax:
4964 .. code-block:: ada
4966   pragma Relative_Deadline (time_span_EXPRESSION);
4969 This pragma is standard in Ada 2005, but is available in all earlier
4970 versions of Ada as an implementation-defined pragma.
4971 See Ada 2012 Reference Manual for details.
4973 Pragma Remote_Access_Type
4974 =========================
4976 Syntax:
4981   pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
4984 This pragma appears in the formal part of a generic declaration.
4985 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
4986 the use of a remote access to class-wide type as actual for a formal
4987 access type.
4989 When this pragma applies to a formal access type `Entity`, that
4990 type is treated as a remote access to class-wide type in the generic.
4991 It must be a formal general access type, and its designated type must
4992 be the class-wide type of a formal tagged limited private type from the
4993 same generic declaration.
4995 In the generic unit, the formal type is subject to all restrictions
4996 pertaining to remote access to class-wide types. At instantiation, the
4997 actual type must be a remote access to class-wide type.
4999 Pragma Restricted_Run_Time
5000 ==========================
5002 Syntax:
5005 .. code-block:: ada
5007   pragma Restricted_Run_Time;
5010 This pragma is considered obsolescent, but is retained for
5011 compatibility purposes. It is equivalent to:
5014 .. code-block:: ada
5016   pragma Profile (Restricted);
5019 which is the preferred method of setting the restricted run time
5020 profile.
5022 Pragma Restriction_Warnings
5023 ===========================
5025 Syntax:
5030   pragma Restriction_Warnings
5031     (restriction_IDENTIFIER {, restriction_IDENTIFIER});
5034 This pragma allows a series of restriction identifiers to be
5035 specified (the list of allowed identifiers is the same as for
5036 pragma `Restrictions`). For each of these identifiers
5037 the compiler checks for violations of the restriction, but
5038 generates a warning message rather than an error message
5039 if the restriction is violated.
5041 One use of this is in situations where you want to know
5042 about violations of a restriction, but you want to ignore some of
5043 these violations. Consider this example, where you want to set
5044 Ada_95 mode and enable style checks, but you want to know about
5045 any other use of implementation pragmas:
5048 .. code-block:: ada
5050   pragma Restriction_Warnings (No_Implementation_Pragmas);
5051   pragma Warnings (Off, "violation of No_Implementation_Pragmas");
5052   pragma Ada_95;
5053   pragma Style_Checks ("2bfhkM160");
5054   pragma Warnings (On, "violation of No_Implementation_Pragmas");
5057 By including the above lines in a configuration pragmas file,
5058 the Ada_95 and Style_Checks pragmas are accepted without
5059 generating a warning, but any other use of implementation
5060 defined pragmas will cause a warning to be generated.
5062 Pragma Reviewable
5063 =================
5065 Syntax:
5068 .. code-block:: ada
5070   pragma Reviewable;
5073 This pragma is an RM-defined standard pragma, but has no effect on the
5074 program being compiled, or on the code generated for the program.
5076 To obtain the required output specified in RM H.3.1, the compiler must be
5077 run with various special switches as follows:
5079 * *Where compiler-generated run-time checks remain*
5081   The switch *-gnatGL*
5082   may be used to list the expanded code in pseudo-Ada form.
5083   Runtime checks show up in the listing either as explicit
5084   checks or operators marked with {} to indicate a check is present.
5087 * *An identification of known exceptions at compile time*
5089   If the program is compiled with *-gnatwa*,
5090   the compiler warning messages will indicate all cases where the compiler
5091   detects that an exception is certain to occur at run time.
5094 * *Possible reads of uninitialized variables*
5096   The compiler warns of many such cases, but its output is incomplete.
5098 .. only:: PRO or GPL
5100   The CodePeer analysis tool
5101   may be used to obtain a comprehensive list of all
5102   possible points at which uninitialized data may be read.
5104 .. only:: FSF
5106   A supplemental static analysis tool
5107   may be used to obtain a comprehensive list of all
5108   possible points at which uninitialized data may be read.
5111 * *Where run-time support routines are implicitly invoked*
5113   In the output from *-gnatGL*,
5114   run-time calls are explicitly listed as calls to the relevant
5115   run-time routine.
5118 * *Object code listing*
5120   This may be obtained either by using the *-S* switch,
5121   or the objdump utility.
5124 * *Constructs known to be erroneous at compile time*
5126   These are identified by warnings issued by the compiler (use *-gnatwa*).
5129 * *Stack usage information*
5131   Static stack usage data (maximum per-subprogram) can be obtained via the
5132   *-fstack-usage* switch to the compiler.
5133   Dynamic stack usage data (per task) can be obtained via the *-u* switch
5134   to gnatbind
5136 .. only:: PRO or GPL
5138   The gnatstack utility
5139   can be used to provide additional information on stack usage.
5142 * *Object code listing of entire partition*
5144   This can be obtained by compiling the partition with *-S*,
5145   or by applying objdump
5146   to all the object files that are part of the partition.
5149 * *A description of the run-time model*
5151   The full sources of the run-time are available, and the documentation of
5152   these routines describes how these run-time routines interface to the
5153   underlying operating system facilities.
5156 * *Control and data-flow information*
5158 .. only:: PRO or GPL
5160   The CodePeer tool
5161   may be used to obtain complete control and data-flow information, as well as
5162   comprehensive messages identifying possible problems based on this
5163   information.
5165 .. only:: FSF
5167   A supplemental static analysis tool
5168   may be used to obtain complete control and data-flow information, as well as
5169   comprehensive messages identifying possible problems based on this
5170   information.
5173 Pragma Share_Generic
5174 ====================
5176 Syntax:
5181   pragma Share_Generic (GNAME {, GNAME});
5183   GNAME ::= generic_unit_NAME | generic_instance_NAME
5186 This pragma is provided for compatibility with Dec Ada 83. It has
5187 no effect in `GNAT` (which does not implement shared generics), other
5188 than to check that the given names are all names of generic units or
5189 generic instances.
5191 Pragma Shared
5192 =============
5194 This pragma is provided for compatibility with Ada 83. The syntax and
5195 semantics are identical to pragma Atomic.
5197 Pragma Short_Circuit_And_Or
5198 ===========================
5200 Syntax:
5203 .. code-block:: ada
5205   pragma Short_Circuit_And_Or;
5208 This configuration pragma causes any occurrence of the AND operator applied to
5209 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5210 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5211 may be useful in the context of certification protocols requiring the use of
5212 short-circuited logical operators. If this configuration pragma occurs locally
5213 within the file being compiled, it applies only to the file being compiled.
5214 There is no requirement that all units in a partition use this option.
5216 Pragma Short_Descriptors
5217 ========================
5219 Syntax:
5222 .. code-block:: ada
5224   pragma Short_Descriptors
5227 This pragma is provided for compatibility with other Ada implementations. It
5228 is recognized but ignored by all current versions of GNAT.
5230 Pragma Simple_Storage_Pool_Type
5231 ===============================
5232 .. index:: Storage pool, simple
5234 .. index:: Simple storage pool
5236 Syntax:
5239 .. code-block:: ada
5241   pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5244 A type can be established as a 'simple storage pool type' by applying
5245 the representation pragma `Simple_Storage_Pool_Type` to the type.
5246 A type named in the pragma must be a library-level immutably limited record
5247 type or limited tagged type declared immediately within a package declaration.
5248 The type can also be a limited private type whose full type is allowed as
5249 a simple storage pool type.
5251 For a simple storage pool type `SSP`, nonabstract primitive subprograms
5252 `Allocate`, `Deallocate`, and `Storage_Size` can be declared that
5253 are subtype conformant with the following subprogram declarations:
5256 .. code-block:: ada
5258   procedure Allocate
5259     (Pool                     : in out SSP;
5260      Storage_Address          : out System.Address;
5261      Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5262      Alignment                : System.Storage_Elements.Storage_Count);
5264   procedure Deallocate
5265     (Pool : in out SSP;
5266      Storage_Address          : System.Address;
5267      Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5268      Alignment                : System.Storage_Elements.Storage_Count);
5270   function Storage_Size (Pool : SSP)
5271     return System.Storage_Elements.Storage_Count;
5274 Procedure `Allocate` must be declared, whereas `Deallocate` and
5275 `Storage_Size` are optional. If `Deallocate` is not declared, then
5276 applying an unchecked deallocation has no effect other than to set its actual
5277 parameter to null. If `Storage_Size` is not declared, then the
5278 `Storage_Size` attribute applied to an access type associated with
5279 a pool object of type SSP returns zero. Additional operations can be declared
5280 for a simple storage pool type (such as for supporting a mark/release
5281 storage-management discipline).
5283 An object of a simple storage pool type can be associated with an access
5284 type by specifying the attribute
5285 :ref:`Simple_Storage_Pool <Attribute_Simple_Storage_Pool>`. For example:
5288 .. code-block:: ada
5290   My_Pool : My_Simple_Storage_Pool_Type;
5292   type Acc is access My_Data_Type;
5294   for Acc'Simple_Storage_Pool use My_Pool;
5298 See attribute :ref:`Simple_Storage_Pool <Attribute_Simple_Storage_Pool>`
5299 for further details.
5301 ..  _Pragma_Source_File_Name:
5303 Pragma Source_File_Name
5304 =======================
5306 Syntax:
5311   pragma Source_File_Name (
5312     [Unit_Name   =>] unit_NAME,
5313     Spec_File_Name =>  STRING_LITERAL,
5314     [Index => INTEGER_LITERAL]);
5316   pragma Source_File_Name (
5317     [Unit_Name   =>] unit_NAME,
5318     Body_File_Name =>  STRING_LITERAL,
5319     [Index => INTEGER_LITERAL]);
5322 Use this to override the normal naming convention.  It is a configuration
5323 pragma, and so has the usual applicability of configuration pragmas
5324 (i.e., it applies to either an entire partition, or to all units in a
5325 compilation, or to a single unit, depending on how it is used.
5326 `unit_name` is mapped to `file_name_literal`.  The identifier for
5327 the second argument is required, and indicates whether this is the file
5328 name for the spec or for the body.
5330 The optional Index argument should be used when a file contains multiple
5331 units, and when you do not want to use `gnatchop` to separate then
5332 into multiple files (which is the recommended procedure to limit the
5333 number of recompilations that are needed when some sources change).
5334 For instance, if the source file :file:`source.ada` contains
5337 .. code-block:: ada
5339   package B is
5340   ...
5341   end B;
5343   with B;
5344   procedure A is
5345   begin
5346      ..
5347   end A;
5350 you could use the following configuration pragmas:
5353 .. code-block:: ada
5355   pragma Source_File_Name
5356     (B, Spec_File_Name => "source.ada", Index => 1);
5357   pragma Source_File_Name
5358     (A, Body_File_Name => "source.ada", Index => 2);
5361 Note that the `gnatname` utility can also be used to generate those
5362 configuration pragmas.
5364 Another form of the `Source_File_Name` pragma allows
5365 the specification of patterns defining alternative file naming schemes
5366 to apply to all files.
5371   pragma Source_File_Name
5372     (  [Spec_File_Name  =>] STRING_LITERAL
5373      [,[Casing          =>] CASING_SPEC]
5374      [,[Dot_Replacement =>] STRING_LITERAL]);
5376   pragma Source_File_Name
5377     (  [Body_File_Name  =>] STRING_LITERAL
5378      [,[Casing          =>] CASING_SPEC]
5379      [,[Dot_Replacement =>] STRING_LITERAL]);
5381   pragma Source_File_Name
5382     (  [Subunit_File_Name =>] STRING_LITERAL
5383      [,[Casing            =>] CASING_SPEC]
5384      [,[Dot_Replacement   =>] STRING_LITERAL]);
5386   CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
5389 The first argument is a pattern that contains a single asterisk indicating
5390 the point at which the unit name is to be inserted in the pattern string
5391 to form the file name.  The second argument is optional.  If present it
5392 specifies the casing of the unit name in the resulting file name string.
5393 The default is lower case.  Finally the third argument allows for systematic
5394 replacement of any dots in the unit name by the specified string literal.
5396 Note that Source_File_Name pragmas should not be used if you are using
5397 project files. The reason for this rule is that the project manager is not
5398 aware of these pragmas, and so other tools that use the projet file would not
5399 be aware of the intended naming conventions. If you are using project files,
5400 file naming is controlled by Source_File_Name_Project pragmas, which are
5401 usually supplied automatically by the project manager. A pragma
5402 Source_File_Name cannot appear after a :ref:`Pragma_Source_File_Name_Project`.
5404 For more details on the use of the `Source_File_Name` pragma, see the
5405 sections on `Using Other File Names` and `Alternative File Naming Schemes'
5406 in the :title:`GNAT User's Guide`.
5408 ..  _Pragma_Source_File_Name_Project:
5410 Pragma Source_File_Name_Project
5411 ===============================
5413 This pragma has the same syntax and semantics as pragma Source_File_Name.
5414 It is only allowed as a stand alone configuration pragma.
5415 It cannot appear after a :ref:`Pragma_Source_File_Name`, and
5416 most importantly, once pragma Source_File_Name_Project appears,
5417 no further Source_File_Name pragmas are allowed.
5419 The intention is that Source_File_Name_Project pragmas are always
5420 generated by the Project Manager in a manner consistent with the naming
5421 specified in a project file, and when naming is controlled in this manner,
5422 it is not permissible to attempt to modify this naming scheme using
5423 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5424 known to the project manager).
5426 Pragma Source_Reference
5427 =======================
5429 Syntax:
5432 .. code-block:: ada
5434   pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5437 This pragma must appear as the first line of a source file.
5438 `integer_literal` is the logical line number of the line following
5439 the pragma line (for use in error messages and debugging
5440 information).  `string_literal` is a static string constant that
5441 specifies the file name to be used in error messages and debugging
5442 information.  This is most notably used for the output of `gnatchop`
5443 with the *-r* switch, to make sure that the original unchopped
5444 source file is the one referred to.
5446 The second argument must be a string literal, it cannot be a static
5447 string expression other than a string literal.  This is because its value
5448 is needed for error messages issued by all phases of the compiler.
5450 Pragma SPARK_Mode
5451 =================
5453 Syntax:
5458   pragma SPARK_Mode [(On | Off)] ;
5461 In general a program can have some parts that are in SPARK 2014 (and
5462 follow all the rules in the SPARK Reference Manual), and some parts
5463 that are full Ada 2012.
5465 The SPARK_Mode pragma is used to identify which parts are in SPARK
5466 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
5467 be used in the following places:
5471   As a configuration pragma, in which case it sets the default mode for
5472   all units compiled with this pragma.
5475   Immediately following a library-level subprogram spec
5478   Immediately within a library-level package body
5481   Immediately following the `private` keyword of a library-level
5482   package spec
5485   Immediately following the `begin` keyword of a library-level
5486   package body
5489   Immediately within a library-level subprogram body
5492 Normally a subprogram or package spec/body inherits the current mode
5493 that is active at the point it is declared. But this can be overridden
5494 by pragma within the spec or body as above.
5496 The basic consistency rule is that you can't turn SPARK_Mode back
5497 `On`, once you have explicitly (with a pragma) turned if
5498 `Off`. So the following rules apply:
5500 If a subprogram spec has SPARK_Mode `Off`, then the body must
5501 also have SPARK_Mode `Off`.
5503 For a package, we have four parts:
5506   the package public declarations
5508   the package private part
5510   the body of the package
5512   the elaboration code after `begin`
5514 For a package, the rule is that if you explicitly turn SPARK_Mode
5515 `Off` for any part, then all the following parts must have
5516 SPARK_Mode `Off`. Note that this may require repeating a pragma
5517 SPARK_Mode (`Off`) in the body. For example, if we have a
5518 configuration pragma SPARK_Mode (`On`) that turns the mode on by
5519 default everywhere, and one particular package spec has pragma
5520 SPARK_Mode (`Off`), then that pragma will need to be repeated in
5521 the package body.
5523 Pragma Static_Elaboration_Desired
5524 =================================
5526 Syntax:
5529 .. code-block:: ada
5531   pragma Static_Elaboration_Desired;
5534 This pragma is used to indicate that the compiler should attempt to initialize
5535 statically the objects declared in the library unit to which the pragma applies,
5536 when these objects are initialized (explicitly or implicitly) by an aggregate.
5537 In the absence of this pragma, aggregates in object declarations are expanded
5538 into assignments and loops, even when the aggregate components are static
5539 constants. When the aggregate is present the compiler builds a static expression
5540 that requires no run-time code, so that the initialized object can be placed in
5541 read-only data space. If the components are not static, or the aggregate has
5542 more that 100 components, the compiler emits a warning that the pragma cannot
5543 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
5544 construction of larger aggregates with static components that include an others
5545 choice.)
5547 Pragma Stream_Convert
5548 =====================
5550 Syntax:
5555   pragma Stream_Convert (
5556     [Entity =>] type_LOCAL_NAME,
5557     [Read   =>] function_NAME,
5558     [Write  =>] function_NAME);
5561 This pragma provides an efficient way of providing user-defined stream
5562 attributes.  Not only is it simpler to use than specifying the attributes
5563 directly, but more importantly, it allows the specification to be made in such
5564 a way that the predefined unit Ada.Streams is not loaded unless it is actually
5565 needed (i.e. unless the stream attributes are actually used); the use of
5566 the Stream_Convert pragma adds no overhead at all, unless the stream
5567 attributes are actually used on the designated type.
5569 The first argument specifies the type for which stream functions are
5570 provided.  The second parameter provides a function used to read values
5571 of this type.  It must name a function whose argument type may be any
5572 subtype, and whose returned type must be the type given as the first
5573 argument to the pragma.
5575 The meaning of the `Read` parameter is that if a stream attribute directly
5576 or indirectly specifies reading of the type given as the first parameter,
5577 then a value of the type given as the argument to the Read function is
5578 read from the stream, and then the Read function is used to convert this
5579 to the required target type.
5581 Similarly the `Write` parameter specifies how to treat write attributes
5582 that directly or indirectly apply to the type given as the first parameter.
5583 It must have an input parameter of the type specified by the first parameter,
5584 and the return type must be the same as the input type of the Read function.
5585 The effect is to first call the Write function to convert to the given stream
5586 type, and then write the result type to the stream.
5588 The Read and Write functions must not be overloaded subprograms.  If necessary
5589 renamings can be supplied to meet this requirement.
5590 The usage of this attribute is best illustrated by a simple example, taken
5591 from the GNAT implementation of package Ada.Strings.Unbounded:
5594 .. code-block:: ada
5596   function To_Unbounded (S : String) return Unbounded_String
5597     renames To_Unbounded_String;
5599   pragma Stream_Convert
5600     (Unbounded_String, To_Unbounded, To_String);
5603 The specifications of the referenced functions, as given in the Ada
5604 Reference Manual are:
5607 .. code-block:: ada
5609   function To_Unbounded_String (Source : String)
5610     return Unbounded_String;
5612   function To_String (Source : Unbounded_String)
5613     return String;
5616 The effect is that if the value of an unbounded string is written to a stream,
5617 then the representation of the item in the stream is in the same format that
5618 would be used for `Standard.String'Output`, and this same representation
5619 is expected when a value of this type is read from the stream. Note that the
5620 value written always includes the bounds, even for Unbounded_String'Write,
5621 since Unbounded_String is not an array type.
5623 Note that the `Stream_Convert` pragma is not effective in the case of
5624 a derived type of a non-limited tagged type. If such a type is specified then
5625 the pragma is silently ignored, and the default implementation of the stream
5626 attributes is used instead.
5628 Pragma Style_Checks
5629 ===================
5631 Syntax:
5636   pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5637                        On | Off [, LOCAL_NAME]);
5640 This pragma is used in conjunction with compiler switches to control the
5641 built in style checking provided by GNAT.  The compiler switches, if set,
5642 provide an initial setting for the switches, and this pragma may be used
5643 to modify these settings, or the settings may be provided entirely by
5644 the use of the pragma.  This pragma can be used anywhere that a pragma
5645 is legal, including use as a configuration pragma (including use in
5646 the :file:`gnat.adc` file).
5648 The form with a string literal specifies which style options are to be
5649 activated.  These are additive, so they apply in addition to any previously
5650 set style check options.  The codes for the options are the same as those
5651 used in the *-gnaty* switch to *gcc* or *gnatmake*.
5652 For example the following two methods can be used to enable
5653 layout checking:
5657   ::
5659     pragma Style_Checks ("l");
5664   ::
5666     gcc -c -gnatyl ...
5669 The form ALL_CHECKS activates all standard checks (its use is equivalent
5670 to the use of the `gnaty` switch with no options.
5671 See the :title:`GNAT User's Guide` for details.)
5673 Note: the behavior is slightly different in GNAT mode (*-gnatg* used).
5674 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5675 options (i.e. equivalent to *-gnatyg*).
5677 The forms with `Off` and `On`
5678 can be used to temporarily disable style checks
5679 as shown in the following example:
5682 .. code-block:: ada
5684   pragma Style_Checks ("k"); -- requires keywords in lower case
5685   pragma Style_Checks (Off); -- turn off style checks
5686   NULL;                      -- this will not generate an error message
5687   pragma Style_Checks (On);  -- turn style checks back on
5688   NULL;                      -- this will generate an error message
5691 Finally the two argument form is allowed only if the first argument is
5692 `On` or `Off`.  The effect is to turn of semantic style checks
5693 for the specified entity, as shown in the following example:
5696 .. code-block:: ada
5698   pragma Style_Checks ("r"); -- require consistency of identifier casing
5699   Arg : Integer;
5700   Rf1 : Integer := ARG;      -- incorrect, wrong case
5701   pragma Style_Checks (Off, Arg);
5702   Rf2 : Integer := ARG;      -- OK, no error
5705 Pragma Subtitle
5706 ===============
5708 Syntax:
5713   pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5716 This pragma is recognized for compatibility with other Ada compilers
5717 but is ignored by GNAT.
5719 Pragma Suppress
5720 ===============
5722 Syntax:
5727   pragma Suppress (Identifier [, [On =>] Name]);
5730 This is a standard pragma, and supports all the check names required in
5731 the RM. It is included here because GNAT recognizes some additional check
5732 names that are implementation defined (as permitted by the RM):
5736   `Alignment_Check` can be used to suppress alignment checks
5737   on addresses used in address clauses. Such checks can also be suppressed
5738   by suppressing range checks, but the specific use of `Alignment_Check`
5739   allows suppression of alignment checks without suppressing other range checks.
5742   `Atomic_Synchronization` can be used to suppress the special memory
5743   synchronization instructions that are normally generated for access to
5744   `Atomic` variables to ensure correct synchronization between tasks
5745   that use such variables for synchronization purposes.
5748   `Duplicated_Tag_Check` Can be used to suppress the check that is generated
5749   for a duplicated tag value when a tagged type is declared.
5752   `Predicate_Check` can be used to control whether predicate checks are
5753   active. It is applicable only to predicates for which the policy is
5754   `Check`. Unlike `Assertion_Policy`, which determines if a given
5755   predicate is ignored or checked for the whole program, the use of
5756   `Suppress` and `Unsuppress` with this check name allows a given
5757   predicate to be turned on and off at specific points in the program.
5760   `Validity_Check` can be used specifically to control validity checks.
5761   If `Suppress` is used to suppress validity checks, then no validity
5762   checks are performed, including those specified by the appropriate compiler
5763   switch or the `Validity_Checks` pragma.
5766   Additional check names previously introduced by use of the `Check_Name`
5767   pragma are also allowed.
5770 Note that pragma Suppress gives the compiler permission to omit
5771 checks, but does not require the compiler to omit checks. The compiler
5772 will generate checks if they are essentially free, even when they are
5773 suppressed. In particular, if the compiler can prove that a certain
5774 check will necessarily fail, it will generate code to do an
5775 unconditional 'raise', even if checks are suppressed. The compiler
5776 warns in this case.
5778 Of course, run-time checks are omitted whenever the compiler can prove
5779 that they will not fail, whether or not checks are suppressed.
5781 Pragma Suppress_All
5782 ===================
5784 Syntax:
5787 .. code-block:: ada
5789   pragma Suppress_All;
5792 This pragma can appear anywhere within a unit.
5793 The effect is to apply `Suppress (All_Checks)` to the unit
5794 in which it appears.  This pragma is implemented for compatibility with DEC
5795 Ada 83 usage where it appears at the end of a unit, and for compatibility
5796 with Rational Ada, where it appears as a program unit pragma.
5797 The use of the standard Ada pragma `Suppress (All_Checks)`
5798 as a normal configuration pragma is the preferred usage in GNAT.
5800 Pragma Suppress_Debug_Info
5801 ==========================
5803 Syntax:
5808   pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
5811 This pragma can be used to suppress generation of debug information
5812 for the specified entity. It is intended primarily for use in debugging
5813 the debugger, and navigating around debugger problems.
5815 Pragma Suppress_Exception_Locations
5816 ===================================
5818 Syntax:
5821 .. code-block:: ada
5823   pragma Suppress_Exception_Locations;
5826 In normal mode, a raise statement for an exception by default generates
5827 an exception message giving the file name and line number for the location
5828 of the raise. This is useful for debugging and logging purposes, but this
5829 entails extra space for the strings for the messages. The configuration
5830 pragma `Suppress_Exception_Locations` can be used to suppress the
5831 generation of these strings, with the result that space is saved, but the
5832 exception message for such raises is null. This configuration pragma may
5833 appear in a global configuration pragma file, or in a specific unit as
5834 usual. It is not required that this pragma be used consistently within
5835 a partition, so it is fine to have some units within a partition compiled
5836 with this pragma and others compiled in normal mode without it.
5838 Pragma Suppress_Initialization
5839 ==============================
5840 .. index:: Suppressing initialization
5842 .. index:: Initialization, suppression of
5844 Syntax:
5849   pragma Suppress_Initialization ([Entity =>] variable_or_subtype_Name);
5852 Here variable_or_subtype_Name is the name introduced by a type declaration
5853 or subtype declaration or the name of a variable introduced by an
5854 object declaration.
5856 In the case of a type or subtype
5857 this pragma suppresses any implicit or explicit initialization
5858 for all variables of the given type or subtype,
5859 including initialization resulting from the use of pragmas
5860 Normalize_Scalars or Initialize_Scalars.
5862 This is considered a representation item, so it cannot be given after
5863 the type is frozen. It applies to all subsequent object declarations,
5864 and also any allocator that creates objects of the type.
5866 If the pragma is given for the first subtype, then it is considered
5867 to apply to the base type and all its subtypes. If the pragma is given
5868 for other than a first subtype, then it applies only to the given subtype.
5869 The pragma may not be given after the type is frozen.
5871 Note that this includes eliminating initialization of discriminants
5872 for discriminated types, and tags for tagged types. In these cases,
5873 you will have to use some non-portable mechanism (e.g. address
5874 overlays or unchecked conversion) to achieve required initialization
5875 of these fields before accessing any object of the corresponding type.
5877 For the variable case, implicit initialization for the named variable
5878 is suppressed, just as though its subtype had been given in a pragma
5879 Suppress_Initialization, as described above.
5881 Pragma Task_Name
5882 ================
5884 Syntax
5887 .. code-block:: ada
5889   pragma Task_Name (string_EXPRESSION);
5892 This pragma appears within a task definition (like pragma
5893 `Priority`) and applies to the task in which it appears.  The
5894 argument must be of type String, and provides a name to be used for
5895 the task instance when the task is created.  Note that this expression
5896 is not required to be static, and in particular, it can contain
5897 references to task discriminants.  This facility can be used to
5898 provide different names for different tasks as they are created,
5899 as illustrated in the example below.
5901 The task name is recorded internally in the run-time structures
5902 and is accessible to tools like the debugger.  In addition the
5903 routine `Ada.Task_Identification.Image` will return this
5904 string, with a unique task address appended.
5907 .. code-block:: ada
5909   --  Example of the use of pragma Task_Name
5911   with Ada.Task_Identification;
5912   use Ada.Task_Identification;
5913   with Text_IO; use Text_IO;
5914   procedure t3 is
5916      type Astring is access String;
5918      task type Task_Typ (Name : access String) is
5919         pragma Task_Name (Name.all);
5920      end Task_Typ;
5922      task body Task_Typ is
5923         Nam : constant String := Image (Current_Task);
5924      begin
5925         Put_Line ("-->" & Nam (1 .. 14) & "<--");
5926      end Task_Typ;
5928      type Ptr_Task is access Task_Typ;
5929      Task_Var : Ptr_Task;
5931   begin
5932      Task_Var :=
5933        new Task_Typ (new String'("This is task 1"));
5934      Task_Var :=
5935        new Task_Typ (new String'("This is task 2"));
5936   end;
5939 Pragma Task_Storage
5940 ===================
5941 Syntax:
5946   pragma Task_Storage (
5947     [Task_Type =>] LOCAL_NAME,
5948     [Top_Guard =>] static_integer_EXPRESSION);
5951 This pragma specifies the length of the guard area for tasks.  The guard
5952 area is an additional storage area allocated to a task.  A value of zero
5953 means that either no guard area is created or a minimal guard area is
5954 created, depending on the target.  This pragma can appear anywhere a
5955 `Storage_Size` attribute definition clause is allowed for a task
5956 type.
5958 Pragma Test_Case
5959 ================
5960 .. index:: Test cases
5963 Syntax:
5968   pragma Test_Case (
5969      [Name     =>] static_string_Expression
5970     ,[Mode     =>] (Nominal | Robustness)
5971    [, Requires =>  Boolean_Expression]
5972    [, Ensures  =>  Boolean_Expression]);
5975 The `Test_Case` pragma allows defining fine-grain specifications
5976 for use by testing tools.
5977 The compiler checks the validity of the `Test_Case` pragma, but its
5978 presence does not lead to any modification of the code generated by the
5979 compiler.
5981 `Test_Case` pragmas may only appear immediately following the
5982 (separate) declaration of a subprogram in a package declaration, inside
5983 a package spec unit. Only other pragmas may intervene (that is appear
5984 between the subprogram declaration and a test case).
5986 The compiler checks that boolean expressions given in `Requires` and
5987 `Ensures` are valid, where the rules for `Requires` are the
5988 same as the rule for an expression in `Precondition` and the rules
5989 for `Ensures` are the same as the rule for an expression in
5990 `Postcondition`. In particular, attributes `'Old` and
5991 `'Result` can only be used within the `Ensures`
5992 expression. The following is an example of use within a package spec:
5995 .. code-block:: ada
5997   package Math_Functions is
5998      ...
5999      function Sqrt (Arg : Float) return Float;
6000      pragma Test_Case (Name     => "Test 1",
6001                        Mode     => Nominal,
6002                        Requires => Arg < 10000,
6003                        Ensures  => Sqrt'Result < 10);
6004      ...
6005   end Math_Functions;
6008 The meaning of a test case is that there is at least one context where
6009 `Requires` holds such that, if the associated subprogram is executed in
6010 that context, then `Ensures` holds when the subprogram returns.
6011 Mode `Nominal` indicates that the input context should also satisfy the
6012 precondition of the subprogram, and the output context should also satisfy its
6013 postcondition. Mode `Robustness` indicates that the precondition and
6014 postcondition of the subprogram should be ignored for this test case.
6016 Pragma Thread_Local_Storage
6017 ===========================
6018 .. index:: Task specific storage
6020 .. index:: TLS (Thread Local Storage)
6022 .. index:: Task_Attributes
6024 Syntax:
6029   pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
6032 This pragma specifies that the specified entity, which must be
6033 a variable declared in a library level package, is to be marked as
6034 "Thread Local Storage" (`TLS`). On systems supporting this (which
6035 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
6036 (and hence each Ada task) to see a distinct copy of the variable.
6038 The variable may not have default initialization, and if there is
6039 an explicit initialization, it must be either `null` for an
6040 access variable, or a static expression for a scalar variable.
6041 This provides a low level mechanism similar to that provided by
6042 the `Ada.Task_Attributes` package, but much more efficient
6043 and is also useful in writing interface code that will interact
6044 with foreign threads.
6046 If this pragma is used on a system where `TLS` is not supported,
6047 then an error message will be generated and the program will be rejected.
6049 Pragma Time_Slice
6050 =================
6052 Syntax:
6055 .. code-block:: ada
6057   pragma Time_Slice (static_duration_EXPRESSION);
6060 For implementations of GNAT on operating systems where it is possible
6061 to supply a time slice value, this pragma may be used for this purpose.
6062 It is ignored if it is used in a system that does not allow this control,
6063 or if it appears in other than the main program unit.
6065 Pragma Title
6066 ============
6068 Syntax:
6073   pragma Title (TITLING_OPTION [, TITLING OPTION]);
6075   TITLING_OPTION ::=
6076     [Title    =>] STRING_LITERAL,
6077   | [Subtitle =>] STRING_LITERAL
6080 Syntax checked but otherwise ignored by GNAT.  This is a listing control
6081 pragma used in DEC Ada 83 implementations to provide a title and/or
6082 subtitle for the program listing.  The program listing generated by GNAT
6083 does not have titles or subtitles.
6085 Unlike other pragmas, the full flexibility of named notation is allowed
6086 for this pragma, i.e., the parameters may be given in any order if named
6087 notation is used, and named and positional notation can be mixed
6088 following the normal rules for procedure calls in Ada.
6090 Pragma Type_Invariant
6091 =====================
6093 Syntax:
6098   pragma Type_Invariant
6099     ([Entity =>] type_LOCAL_NAME,
6100      [Check  =>] EXPRESSION);
6103 The `Type_Invariant` pragma is intended to be an exact
6104 replacement for the language-defined `Type_Invariant`
6105 aspect, and shares its restrictions and semantics. It differs
6106 from the language defined `Invariant` pragma in that it
6107 does not permit a string parameter, and it is
6108 controlled by the assertion identifier `Type_Invariant`
6109 rather than `Invariant`.
6111 Pragma Type_Invariant_Class
6112 ===========================
6114 Syntax:
6119   pragma Type_Invariant_Class
6120     ([Entity =>] type_LOCAL_NAME,
6121      [Check  =>] EXPRESSION);
6124 The `Type_Invariant_Class` pragma is intended to be an exact
6125 replacement for the language-defined `Type_Invariant'Class`
6126 aspect, and shares its restrictions and semantics.
6128 Note: This pragma is called `Type_Invariant_Class` rather than
6129 `Type_Invariant'Class` because the latter would not be strictly
6130 conforming to the allowed syntax for pragmas. The motivation
6131 for providing pragmas equivalent to the aspects is to allow a program
6132 to be written using the pragmas, and then compiled if necessary
6133 using an Ada compiler that does not recognize the pragmas or
6134 aspects, but is prepared to ignore the pragmas. The assertion
6135 policy that controls this pragma is `Type_Invariant'Class`,
6136 not `Type_Invariant_Class`.
6138 Pragma Unchecked_Union
6139 ======================
6140 .. index:: Unions in C
6143 Syntax:
6146 .. code-block:: ada
6148   pragma Unchecked_Union (first_subtype_LOCAL_NAME);
6151 This pragma is used to specify a representation of a record type that is
6152 equivalent to a C union. It was introduced as a GNAT implementation defined
6153 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
6154 pragma, making it language defined, and GNAT fully implements this extended
6155 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
6156 details, consult the Ada 2012 Reference Manual, section B.3.3.
6158 Pragma Unevaluated_Use_Of_Old
6159 =============================
6160 .. index:: Attribute Old
6162 .. index:: Attribute Loop_Entry
6164 .. index:: Unevaluated_Use_Of_Old
6167 Syntax:
6170 .. code-block:: ada
6172   pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
6175 This pragma controls the processing of attributes Old and Loop_Entry.
6176 If either of these attributes is used in a potentially unevaluated
6177 expression  (e.g. the then or else parts of an if expression), then
6178 normally this usage is considered illegal if the prefix of the attribute
6179 is other than an entity name. The language requires this
6180 behavior for Old, and GNAT copies the same rule for Loop_Entry.
6182 The reason for this rule is that otherwise, we can have a situation
6183 where we save the Old value, and this results in an exception, even
6184 though we might not evaluate the attribute. Consider this example:
6187 .. code-block:: ada
6189   package UnevalOld is
6190      K : Character;
6191      procedure U (A : String; C : Boolean)  -- ERROR
6192        with Post => (if C then A(1)'Old = K else True);
6193   end;
6196 If procedure U is called with a string with a lower bound of 2, and
6197 C false, then an exception would be raised trying to evaluate A(1)
6198 on entry even though the value would not be actually used.
6200 Although the rule guarantees against this possibility, it is sometimes
6201 too restrictive. For example if we know that the string has a lower
6202 bound of 1, then we will never raise an exception.
6203 The pragma `Unevaluated_Use_Of_Old` can be
6204 used to modify this behavior. If the argument is `Error` then an
6205 error is given (this is the default RM behavior). If the argument is
6206 `Warn` then the usage is allowed as legal but with a warning
6207 that an exception might be raised. If the argument is `Allow`
6208 then the usage is allowed as legal without generating a warning.
6210 This pragma may appear as a configuration pragma, or in a declarative
6211 part or package specification. In the latter case it applies to
6212 uses up to the end of the corresponding statement sequence or
6213 sequence of package declarations.
6215 Pragma Unimplemented_Unit
6216 =========================
6218 Syntax:
6221 .. code-block:: ada
6223   pragma Unimplemented_Unit;
6226 If this pragma occurs in a unit that is processed by the compiler, GNAT
6227 aborts with the message :samp:`xxx not implemented`, where
6228 `xxx` is the name of the current compilation unit.  This pragma is
6229 intended to allow the compiler to handle unimplemented library units in
6230 a clean manner.
6232 The abort only happens if code is being generated.  Thus you can use
6233 specs of unimplemented packages in syntax or semantic checking mode.
6235 Pragma Universal_Aliasing
6236 =========================
6238 Syntax:
6243   pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
6246 `type_LOCAL_NAME` must refer to a type declaration in the current
6247 declarative part.  The effect is to inhibit strict type-based aliasing
6248 optimization for the given type.  In other words, the effect is as though
6249 access types designating this type were subject to pragma No_Strict_Aliasing.
6250 For a detailed description of the strict aliasing optimization, and the
6251 situations in which it must be suppressed, see the section on
6252 `Optimization and Strict Aliasing` in the :title:`GNAT User's Guide`.
6254 Pragma Universal_Data
6255 =====================
6257 Syntax:
6262   pragma Universal_Data [(library_unit_Name)];
6265 This pragma is supported only for the AAMP target and is ignored for
6266 other targets. The pragma specifies that all library-level objects
6267 (Counter 0 data) associated with the library unit are to be accessed
6268 and updated using universal addressing (24-bit addresses for AAMP5)
6269 rather than the default of 16-bit Data Environment (DENV) addressing.
6270 Use of this pragma will generally result in less efficient code for
6271 references to global data associated with the library unit, but
6272 allows such data to be located anywhere in memory. This pragma is
6273 a library unit pragma, but can also be used as a configuration pragma
6274 (including use in the :file:`gnat.adc` file). The functionality
6275 of this pragma is also available by applying the -univ switch on the
6276 compilations of units where universal addressing of the data is desired.
6278 Pragma Unmodified
6279 =================
6280 .. index:: Warnings, unmodified
6282 Syntax:
6287   pragma Unmodified (LOCAL_NAME {, LOCAL_NAME});
6290 This pragma signals that the assignable entities (variables,
6291 `out` parameters, `in out` parameters) whose names are listed are
6292 deliberately not assigned in the current source unit. This
6293 suppresses warnings about the
6294 entities being referenced but not assigned, and in addition a warning will be
6295 generated if one of these entities is in fact assigned in the
6296 same unit as the pragma (or in the corresponding body, or one
6297 of its subunits).
6299 This is particularly useful for clearly signaling that a particular
6300 parameter is not modified, even though the spec suggests that it might
6303 For the variable case, warnings are never given for unreferenced variables
6304 whose name contains one of the substrings
6305 `DISCARD, DUMMY, IGNORE, JUNK, UNUSED` in any casing. Such names
6306 are typically to be used in cases where such warnings are expected.
6307 Thus it is never necessary to use `pragma Unmodified` for such
6308 variables, though it is harmless to do so.
6310 Pragma Unreferenced
6311 ===================
6312 .. index:: Warnings, unreferenced
6314 Syntax:
6319   pragma Unreferenced (LOCAL_NAME {, LOCAL_NAME});
6320   pragma Unreferenced (library_unit_NAME {, library_unit_NAME});
6323 This pragma signals that the entities whose names are listed are
6324 deliberately not referenced in the current source unit after the
6325 occurrence of the pragma. This
6326 suppresses warnings about the
6327 entities being unreferenced, and in addition a warning will be
6328 generated if one of these entities is in fact subsequently referenced in the
6329 same unit as the pragma (or in the corresponding body, or one
6330 of its subunits).
6332 This is particularly useful for clearly signaling that a particular
6333 parameter is not referenced in some particular subprogram implementation
6334 and that this is deliberate. It can also be useful in the case of
6335 objects declared only for their initialization or finalization side
6336 effects.
6338 If `LOCAL_NAME` identifies more than one matching homonym in the
6339 current scope, then the entity most recently declared is the one to which
6340 the pragma applies. Note that in the case of accept formals, the pragma
6341 Unreferenced may appear immediately after the keyword `do` which
6342 allows the indication of whether or not accept formals are referenced
6343 or not to be given individually for each accept statement.
6345 The left hand side of an assignment does not count as a reference for the
6346 purpose of this pragma. Thus it is fine to assign to an entity for which
6347 pragma Unreferenced is given.
6349 Note that if a warning is desired for all calls to a given subprogram,
6350 regardless of whether they occur in the same unit as the subprogram
6351 declaration, then this pragma should not be used (calls from another
6352 unit would not be flagged); pragma Obsolescent can be used instead
6353 for this purpose, see :ref:`Pragma_Obsolescent`.
6355 The second form of pragma `Unreferenced` is used within a context
6356 clause. In this case the arguments must be unit names of units previously
6357 mentioned in `with` clauses (similar to the usage of pragma
6358 `Elaborate_All`. The effect is to suppress warnings about unreferenced
6359 units and unreferenced entities within these units.
6361 For the variable case, warnings are never given for unreferenced variables
6362 whose name contains one of the substrings
6363 `DISCARD, DUMMY, IGNORE, JUNK, UNUSED` in any casing. Such names
6364 are typically to be used in cases where such warnings are expected.
6365 Thus it is never necessary to use `pragma Unreferenced` for such
6366 variables, though it is harmless to do so.
6368 Pragma Unreferenced_Objects
6369 ===========================
6370 .. index:: Warnings, unreferenced
6372 Syntax:
6377   pragma Unreferenced_Objects (local_subtype_NAME {, local_subtype_NAME});
6380 This pragma signals that for the types or subtypes whose names are
6381 listed, objects which are declared with one of these types or subtypes may
6382 not be referenced, and if no references appear, no warnings are given.
6384 This is particularly useful for objects which are declared solely for their
6385 initialization and finalization effect. Such variables are sometimes referred
6386 to as RAII variables (Resource Acquisition Is Initialization). Using this
6387 pragma on the relevant type (most typically a limited controlled type), the
6388 compiler will automatically suppress unwanted warnings about these variables
6389 not being referenced.
6391 Pragma Unreserve_All_Interrupts
6392 ===============================
6394 Syntax:
6397 .. code-block:: ada
6399   pragma Unreserve_All_Interrupts;
6402 Normally certain interrupts are reserved to the implementation.  Any attempt
6403 to attach an interrupt causes Program_Error to be raised, as described in
6404 RM C.3.2(22).  A typical example is the `SIGINT` interrupt used in
6405 many systems for a :kbd:`Ctrl-C` interrupt.  Normally this interrupt is
6406 reserved to the implementation, so that :kbd:`Ctrl-C` can be used to
6407 interrupt execution.
6409 If the pragma `Unreserve_All_Interrupts` appears anywhere in any unit in
6410 a program, then all such interrupts are unreserved.  This allows the
6411 program to handle these interrupts, but disables their standard
6412 functions.  For example, if this pragma is used, then pressing
6413 :kbd:`Ctrl-C` will not automatically interrupt execution.  However,
6414 a program can then handle the `SIGINT` interrupt as it chooses.
6416 For a full list of the interrupts handled in a specific implementation,
6417 see the source code for the spec of `Ada.Interrupts.Names` in
6418 file :file:`a-intnam.ads`.  This is a target dependent file that contains the
6419 list of interrupts recognized for a given target.  The documentation in
6420 this file also specifies what interrupts are affected by the use of
6421 the `Unreserve_All_Interrupts` pragma.
6423 For a more general facility for controlling what interrupts can be
6424 handled, see pragma `Interrupt_State`, which subsumes the functionality
6425 of the `Unreserve_All_Interrupts` pragma.
6427 Pragma Unsuppress
6428 =================
6430 Syntax:
6435   pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
6438 This pragma undoes the effect of a previous pragma `Suppress`.  If
6439 there is no corresponding pragma `Suppress` in effect, it has no
6440 effect.  The range of the effect is the same as for pragma
6441 `Suppress`.  The meaning of the arguments is identical to that used
6442 in pragma `Suppress`.
6444 One important application is to ensure that checks are on in cases where
6445 code depends on the checks for its correct functioning, so that the code
6446 will compile correctly even if the compiler switches are set to suppress
6447 checks. For example, in a program that depends on external names of tagged
6448 types and wants to ensure that the duplicated tag check occurs even if all
6449 run-time checks are suppressed by a compiler switch, the following
6450 configuration pragma will ensure this test is not suppressed:
6453 .. code-block:: ada
6455   pragma Unsuppress (Duplicated_Tag_Check);
6458 This pragma is standard in Ada 2005. It is available in all earlier versions
6459 of Ada as an implementation-defined pragma.
6461 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
6462 a number of implementation-defined check names. See description of pragma
6463 `Suppress` for full details.
6465 Pragma Use_VADS_Size
6466 ====================
6467 .. index:: Size, VADS compatibility
6469 .. index:: Rational profile
6472 Syntax:
6475 .. code-block:: ada
6477   pragma Use_VADS_Size;
6480 This is a configuration pragma.  In a unit to which it applies, any use
6481 of the 'Size attribute is automatically interpreted as a use of the
6482 'VADS_Size attribute.  Note that this may result in incorrect semantic
6483 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
6484 the handling of existing code which depends on the interpretation of Size
6485 as implemented in the VADS compiler.  See description of the VADS_Size
6486 attribute for further details.
6488 Pragma Validity_Checks
6489 ======================
6491 Syntax:
6494 .. code-block:: ada
6496   pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
6499 This pragma is used in conjunction with compiler switches to control the
6500 built-in validity checking provided by GNAT.  The compiler switches, if set
6501 provide an initial setting for the switches, and this pragma may be used
6502 to modify these settings, or the settings may be provided entirely by
6503 the use of the pragma.  This pragma can be used anywhere that a pragma
6504 is legal, including use as a configuration pragma (including use in
6505 the :file:`gnat.adc` file).
6507 The form with a string literal specifies which validity options are to be
6508 activated.  The validity checks are first set to include only the default
6509 reference manual settings, and then a string of letters in the string
6510 specifies the exact set of options required.  The form of this string
6511 is exactly as described for the *-gnatVx* compiler switch (see the
6512 GNAT User's Guide for details).  For example the following two
6513 methods can be used to enable validity checking for mode `in` and
6514 `in out` subprogram parameters:
6518   .. code-block:: ada
6520     pragma Validity_Checks ("im");
6525   .. code-block:: sh
6527     $ gcc -c -gnatVim ...
6530 The form ALL_CHECKS activates all standard checks (its use is equivalent
6531 to the use of the `gnatva` switch.
6533 The forms with `Off` and `On`
6534 can be used to temporarily disable validity checks
6535 as shown in the following example:
6538 .. code-block:: ada
6540   pragma Validity_Checks ("c"); -- validity checks for copies
6541   pragma Validity_Checks (Off); -- turn off validity checks
6542   A := B;                       -- B will not be validity checked
6543   pragma Validity_Checks (On);  -- turn validity checks back on
6544   A := C;                       -- C will be validity checked
6547 Pragma Volatile
6548 ===============
6550 Syntax:
6553 .. code-block:: ada
6555   pragma Volatile (LOCAL_NAME);
6558 This pragma is defined by the Ada Reference Manual, and the GNAT
6559 implementation is fully conformant with this definition.  The reason it
6560 is mentioned in this section is that a pragma of the same name was supplied
6561 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
6562 implementation of pragma Volatile is upwards compatible with the
6563 implementation in DEC Ada 83.
6565 Pragma Warning_As_Error
6566 =======================
6568 Syntax:
6571 .. code-block:: ada
6573   pragma Warning_As_Error (static_string_EXPRESSION);
6576 This configuration pragma allows the programmer to specify a set
6577 of warnings that will be treated as errors. Any warning which
6578 matches the pattern given by the pragma argument will be treated
6579 as an error. This gives much more precise control that -gnatwe
6580 which treats all warnings as errors.
6582 The pattern may contain asterisks, which match zero or more characters in
6583 the message. For example, you can use
6584 `pragma Warning_As_Error ("bits of*unused")` to treat the warning
6585 message `warning: 960 bits of "a" unused` as an error. No other regular
6586 expression notations are permitted. All characters other than asterisk in
6587 these three specific cases are treated as literal characters in the match.
6588 The match is case insensitive, for example XYZ matches xyz.
6590 Note that the pattern matches if it occurs anywhere within the warning
6591 message string (it is not necessary to put an asterisk at the start and
6592 the end of the message, since this is implied).
6594 Another possibility for the static_string_EXPRESSION which works whether
6595 or not error tags are enabled (*-gnatw.d*) is to use the
6596 *-gnatw* tag string, enclosed in brackets,
6597 as shown in the example below, to treat a class of warnings as errors.
6599 The above use of patterns to match the message applies only to warning
6600 messages generated by the front end. This pragma can also be applied to
6601 warnings provided by the back end and mentioned in :ref:`Pragma_Warnings`.
6602 By using a single full *-Wxxx* switch in the pragma, such warnings
6603 can also be treated as errors.
6605 The pragma can appear either in a global configuration pragma file
6606 (e.g. :file:`gnat.adc`), or at the start of a file. Given a global
6607 configuration pragma file containing:
6610 .. code-block:: ada
6612   pragma Warning_As_Error ("[-gnatwj]");
6615 which will treat all obsolescent feature warnings as errors, the
6616 following program compiles as shown (compile options here are
6617 *-gnatwa.d -gnatl -gnatj55*).
6622        1. pragma Warning_As_Error ("*never assigned*");
6623        2. function Warnerr return String is
6624        3.    X : Integer;
6625              |
6626           >>> error: variable "X" is never read and
6627               never assigned [-gnatwv] [warning-as-error]
6629        4.    Y : Integer;
6630              |
6631           >>> warning: variable "Y" is assigned but
6632               never read [-gnatwu]
6634        5. begin
6635        6.    Y := 0;
6636        7.    return %ABC%;
6637                     |
6638           >>> error: use of "%" is an obsolescent
6639               feature (RM J.2(4)), use """ instead
6640               [-gnatwj] [warning-as-error]
6642        8. end;
6644    8 lines: No errors, 3 warnings (2 treated as errors)
6647 Note that this pragma does not affect the set of warnings issued in
6648 any way, it merely changes the effect of a matching warning if one
6649 is produced as a result of other warnings options. As shown in this
6650 example, if the pragma results in a warning being treated as an error,
6651 the tag is changed from "warning:" to "error:" and the string
6652 "[warning-as-error]" is appended to the end of the message.
6654 .. _Pragma_Warnings:
6656 Pragma Warnings
6657 ===============
6659 Syntax:
6662 .. code-block:: ada
6664   pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]);
6666   DETAILS ::= On | Off
6667   DETAILS ::= On | Off, local_NAME
6668   DETAILS ::= static_string_EXPRESSION
6669   DETAILS ::= On | Off, static_string_EXPRESSION
6671   TOOL_NAME ::= GNAT | GNATProve
6673   REASON ::= Reason => STRING_LITERAL {& STRING_LITERAL}
6675 Note: in Ada 83 mode, a string literal may be used in place of a static string
6676 expression (which does not exist in Ada 83).
6678 Note if the second argument of `DETAILS` is a `local_NAME` then the
6679 second form is always understood. If the intention is to use
6680 the fourth form, then you can write `NAME & ""` to force the
6681 intepretation as a `static_string_EXPRESSION`.
6683 Note: if the first argument is a valid `TOOL_NAME`, it will be interpreted
6684 that way. The use of the `TOOL_NAME` argument is relevant only to users
6685 of SPARK and GNATprove, see last part of this section for details.
6687 Normally warnings are enabled, with the output being controlled by
6688 the command line switch.  Warnings (`Off`) turns off generation of
6689 warnings until a Warnings (`On`) is encountered or the end of the
6690 current unit.  If generation of warnings is turned off using this
6691 pragma, then some or all of the warning messages are suppressed,
6692 regardless of the setting of the command line switches.
6694 The `Reason` parameter may optionally appear as the last argument
6695 in any of the forms of this pragma. It is intended purely for the
6696 purposes of documenting the reason for the `Warnings` pragma.
6697 The compiler will check that the argument is a static string but
6698 otherwise ignore this argument. Other tools may provide specialized
6699 processing for this string.
6701 The form with a single argument (or two arguments if Reason present),
6702 where the first argument is `ON` or `OFF`
6703 may be used as a configuration pragma.
6705 If the `LOCAL_NAME` parameter is present, warnings are suppressed for
6706 the specified entity.  This suppression is effective from the point where
6707 it occurs till the end of the extended scope of the variable (similar to
6708 the scope of `Suppress`). This form cannot be used as a configuration
6709 pragma.
6711 In the case where the first argument is other than `ON` or
6712 `OFF`,
6713 the third form with a single static_string_EXPRESSION argument (and possible
6714 reason) provides more precise
6715 control over which warnings are active. The string is a list of letters
6716 specifying which warnings are to be activated and which deactivated. The
6717 code for these letters is the same as the string used in the command
6718 line switch controlling warnings. For a brief summary, use the gnatmake
6719 command with no arguments, which will generate usage information containing
6720 the list of warnings switches supported. For
6721 full details see the section on `Warning Message Control` in the
6722 :title:`GNAT User's Guide`.
6723 This form can also be used as a configuration pragma.
6725 The warnings controlled by the *-gnatw* switch are generated by the
6726 front end of the compiler. The GCC back end can provide additional warnings
6727 and they are controlled by the *-W* switch. Such warnings can be
6728 identified by the appearance of a string of the form `[-Wxxx]` in the
6729 message which designates the *-Wxxx* switch that controls the message.
6730 The form with a single static_string_EXPRESSION argument also works for these
6731 warnings, but the string must be a single full *-Wxxx* switch in this
6732 case. The above reference lists a few examples of these additional warnings.
6734 The specified warnings will be in effect until the end of the program
6735 or another pragma Warnings is encountered. The effect of the pragma is
6736 cumulative. Initially the set of warnings is the standard default set
6737 as possibly modified by compiler switches. Then each pragma Warning
6738 modifies this set of warnings as specified. This form of the pragma may
6739 also be used as a configuration pragma.
6741 The fourth form, with an `On|Off` parameter and a string, is used to
6742 control individual messages, based on their text. The string argument
6743 is a pattern that is used to match against the text of individual
6744 warning messages (not including the initial "warning: " tag).
6746 The pattern may contain asterisks, which match zero or more characters in
6747 the message. For example, you can use
6748 `pragma Warnings (Off, "bits of*unused")` to suppress the warning
6749 message `warning: 960 bits of "a" unused`. No other regular
6750 expression notations are permitted. All characters other than asterisk in
6751 these three specific cases are treated as literal characters in the match.
6752 The match is case insensitive, for example XYZ matches xyz.
6754 Note that the pattern matches if it occurs anywhere within the warning
6755 message string (it is not necessary to put an asterisk at the start and
6756 the end of the message, since this is implied).
6758 The above use of patterns to match the message applies only to warning
6759 messages generated by the front end. This form of the pragma with a string
6760 argument can also be used to control warnings provided by the back end and
6761 mentioned above. By using a single full *-Wxxx* switch in the pragma,
6762 such warnings can be turned on and off.
6764 There are two ways to use the pragma in this form. The OFF form can be used
6765 as a configuration pragma. The effect is to suppress all warnings (if any)
6766 that match the pattern string throughout the compilation (or match the
6767 -W switch in the back end case).
6769 The second usage is to suppress a warning locally, and in this case, two
6770 pragmas must appear in sequence:
6773 .. code-block:: ada
6775   pragma Warnings (Off, Pattern);
6776   ... code where given warning is to be suppressed
6777   pragma Warnings (On, Pattern);
6780 In this usage, the pattern string must match in the Off and On
6781 pragmas, and (if *-gnatw.w* is given) at least one matching
6782 warning must be suppressed.
6784 Note: to write a string that will match any warning, use the string
6785 `"***"`. It will not work to use a single asterisk or two
6786 asterisks since this looks like an operator name. This form with three
6787 asterisks is similar in effect to specifying `pragma Warnings (Off)` except (if *-gnatw.w* is given) that a matching
6788 `pragma Warnings (On, "***")` will be required. This can be
6789 helpful in avoiding forgetting to turn warnings back on.
6791 Note: the debug flag -gnatd.i (`/NOWARNINGS_PRAGMAS` in VMS) can be
6792 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
6793 be useful in checking whether obsolete pragmas in existing programs are hiding
6794 real problems.
6796 Note: pragma Warnings does not affect the processing of style messages. See
6797 separate entry for pragma Style_Checks for control of style messages.
6799 Users of the formal verification tool GNATprove for the SPARK subset of Ada may
6800 use the version of the pragma with a `TOOL_NAME` parameter.
6802 If present, `TOOL_NAME` is the name of a tool, currently either `GNAT` for the
6803 compiler or `GNATprove` for the formal verification tool. A given tool only
6804 takes into account pragma Warnings that do not specify a tool name, or that
6805 specify the matching tool name. This makes it possible to disable warnings
6806 selectively for each tool, and as a consequence to detect useless pragma
6807 Warnings with switch `-gnatw.w`.
6809 Pragma Weak_External
6810 ====================
6812 Syntax:
6815 .. code-block:: ada
6817   pragma Weak_External ([Entity =>] LOCAL_NAME);
6820 `LOCAL_NAME` must refer to an object that is declared at the library
6821 level. This pragma specifies that the given entity should be marked as a
6822 weak symbol for the linker. It is equivalent to `__attribute__((weak))`
6823 in GNU C and causes `LOCAL_NAME` to be emitted as a weak symbol instead
6824 of a regular symbol, that is to say a symbol that does not have to be
6825 resolved by the linker if used in conjunction with a pragma Import.
6827 When a weak symbol is not resolved by the linker, its address is set to
6828 zero. This is useful in writing interfaces to external modules that may
6829 or may not be linked in the final executable, for example depending on
6830 configuration settings.
6832 If a program references at run time an entity to which this pragma has been
6833 applied, and the corresponding symbol was not resolved at link time, then
6834 the execution of the program is erroneous. It is not erroneous to take the
6835 Address of such an entity, for example to guard potential references,
6836 as shown in the example below.
6838 Some file formats do not support weak symbols so not all target machines
6839 support this pragma.
6842 .. code-block:: ada
6844   --  Example of the use of pragma Weak_External
6846   package External_Module is
6847     key : Integer;
6848     pragma Import (C, key);
6849     pragma Weak_External (key);
6850     function Present return boolean;
6851   end External_Module;
6853   with System; use System;
6854   package body External_Module is
6855     function Present return boolean is
6856     begin
6857       return key'Address /= System.Null_Address;
6858     end Present;
6859   end External_Module;
6862 Pragma Wide_Character_Encoding
6863 ==============================
6865 Syntax:
6868 .. code-block:: ada
6870   pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
6873 This pragma specifies the wide character encoding to be used in program
6874 source text appearing subsequently. It is a configuration pragma, but may
6875 also be used at any point that a pragma is allowed, and it is permissible
6876 to have more than one such pragma in a file, allowing multiple encodings
6877 to appear within the same file.
6879 The argument can be an identifier or a character literal. In the identifier
6880 case, it is one of `HEX`, `UPPER`, `SHIFT_JIS`,
6881 `EUC`, `UTF8`, or `BRACKETS`. In the character literal
6882 case it is correspondingly one of the characters :kbd:`h`, :kbd:`u`,
6883 :kbd:`s`, :kbd:`e`, :kbd:`8`, or :kbd:`b`.
6885 Note that when the pragma is used within a file, it affects only the
6886 encoding within that file, and does not affect withed units, specs,
6887 or subunits.