* gnat_rm.texi, gnat_ugn.texi, doc: Documentation updates and clean ups
[official-gcc.git] / gcc / ada / doc / gnat_rm / implementation_defined_pragmas.rst
blob058db24357557af3e94d8f6318b76c81c0c1d538
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 Ignore_Pragma
2200 ====================
2202 Syntax:
2205 .. code-block:: ada
2207   pragma Ignore_Pragma (pragma_IDENTIFIER);
2209 This is a configuration pragma
2210 that takes a single argument that is a simple identifier. Any subsequent
2211 use of a pragma whose pragma identifier matches this argument will be
2212 silently ignored. This may be useful when legacy code or code intended
2213 for compilation with some other compiler contains pragmas that match the
2214 name, but not the exact implementation, of a `GNAT` pragma. The use of this
2215 pragma allows such pragmas to be ignored, which may be useful in `CodePeer`
2216 mode, or during porting of legacy code.
2218 Pragma Implementation_Defined
2219 =============================
2221 Syntax:
2224 .. code-block:: ada
2226   pragma Implementation_Defined (local_NAME);
2229 This pragma marks a previously declared entioty as implementation-defined.
2230 For an overloaded entity, applies to the most recent homonym.
2233 .. code-block:: ada
2235   pragma Implementation_Defined;
2238 The form with no arguments appears anywhere within a scope, most
2239 typically a package spec, and indicates that all entities that are
2240 defined within the package spec are Implementation_Defined.
2242 This pragma is used within the GNAT runtime library to identify
2243 implementation-defined entities introduced in language-defined units,
2244 for the purpose of implementing the No_Implementation_Identifiers
2245 restriction.
2247 Pragma Implemented
2248 ==================
2250 Syntax:
2255   pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2257   implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2260 This is an Ada 2012 representation pragma which applies to protected, task
2261 and synchronized interface primitives. The use of pragma Implemented provides
2262 a way to impose a static requirement on the overriding operation by adhering
2263 to one of the three implementation kinds: entry, protected procedure or any of
2264 the above. This pragma is available in all earlier versions of Ada as an
2265 implementation-defined pragma.
2268 .. code-block:: ada
2270   type Synch_Iface is synchronized interface;
2271   procedure Prim_Op (Obj : in out Iface) is abstract;
2272   pragma Implemented (Prim_Op, By_Protected_Procedure);
2274   protected type Prot_1 is new Synch_Iface with
2275      procedure Prim_Op;  --  Legal
2276   end Prot_1;
2278   protected type Prot_2 is new Synch_Iface with
2279      entry Prim_Op;      --  Illegal
2280   end Prot_2;
2282   task type Task_Typ is new Synch_Iface with
2283      entry Prim_Op;      --  Illegal
2284   end Task_Typ;
2287 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2288 Implemented determines the runtime behavior of the requeue. Implementation kind
2289 By_Entry guarantees that the action of requeueing will proceed from an entry to
2290 another entry. Implementation kind By_Protected_Procedure transforms the
2291 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2292 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2293 the target's overriding subprogram kind.
2295 Pragma Implicit_Packing
2296 =======================
2297 .. index:: Rational Profile
2299 Syntax:
2302 .. code-block:: ada
2304   pragma Implicit_Packing;
2307 This is a configuration pragma that requests implicit packing for packed
2308 arrays for which a size clause is given but no explicit pragma Pack or
2309 specification of Component_Size is present. It also applies to records
2310 where no record representation clause is present. Consider this example:
2313 .. code-block:: ada
2315   type R is array (0 .. 7) of Boolean;
2316   for R'Size use 8;
2319 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2320 does not change the layout of a composite object. So the Size clause in the
2321 above example is normally rejected, since the default layout of the array uses
2322 8-bit components, and thus the array requires a minimum of 64 bits.
2324 If this declaration is compiled in a region of code covered by an occurrence
2325 of the configuration pragma Implicit_Packing, then the Size clause in this
2326 and similar examples will cause implicit packing and thus be accepted. For
2327 this implicit packing to occur, the type in question must be an array of small
2328 components whose size is known at compile time, and the Size clause must
2329 specify the exact size that corresponds to the number of elements in the array
2330 multiplied by the size in bits of the component type (both single and
2331 multi-dimensioned arrays can be controlled with this pragma).
2333 .. index:: Array packing
2335 Similarly, the following example shows the use in the record case
2338 .. code-block:: ada
2340   type r is record
2341      a, b, c, d, e, f, g, h : boolean;
2342      chr                    : character;
2343   end record;
2344   for r'size use 16;
2347 Without a pragma Pack, each Boolean field requires 8 bits, so the
2348 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2349 sufficient. The use of pragma Implicit_Packing allows this record
2350 declaration to compile without an explicit pragma Pack.
2352 Pragma Import_Function
2353 ======================
2355 Syntax:
2360   pragma Import_Function (
2361        [Internal                 =>] LOCAL_NAME,
2362     [, [External                 =>] EXTERNAL_SYMBOL]
2363     [, [Parameter_Types          =>] PARAMETER_TYPES]
2364     [, [Result_Type              =>] SUBTYPE_MARK]
2365     [, [Mechanism                =>] MECHANISM]
2366     [, [Result_Mechanism         =>] MECHANISM_NAME]);
2368   EXTERNAL_SYMBOL ::=
2369     IDENTIFIER
2370   | static_string_EXPRESSION
2372   PARAMETER_TYPES ::=
2373     null
2374   | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2376   TYPE_DESIGNATOR ::=
2377     subtype_NAME
2378   | subtype_Name ' Access
2380   MECHANISM ::=
2381     MECHANISM_NAME
2382   | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2384   MECHANISM_ASSOCIATION ::=
2385     [formal_parameter_NAME =>] MECHANISM_NAME
2387   MECHANISM_NAME ::=
2388     Value
2389   | Reference
2392 This pragma is used in conjunction with a pragma `Import` to
2393 specify additional information for an imported function.  The pragma
2394 `Import` (or equivalent pragma `Interface`) must precede the
2395 `Import_Function` pragma and both must appear in the same
2396 declarative part as the function specification.
2398 The `Internal` argument must uniquely designate
2399 the function to which the
2400 pragma applies.  If more than one function name exists of this name in
2401 the declarative part you must use the `Parameter_Types` and
2402 `Result_Type` parameters to achieve the required unique
2403 designation.  Subtype marks in these parameters must exactly match the
2404 subtypes in the corresponding function specification, using positional
2405 notation to match parameters with subtype marks.
2406 The form with an `'Access` attribute can be used to match an
2407 anonymous access parameter.
2409 You may optionally use the `Mechanism` and `Result_Mechanism`
2410 parameters to specify passing mechanisms for the
2411 parameters and result.  If you specify a single mechanism name, it
2412 applies to all parameters.  Otherwise you may specify a mechanism on a
2413 parameter by parameter basis using either positional or named
2414 notation.  If the mechanism is not specified, the default mechanism
2415 is used.
2417 Pragma Import_Object
2418 ====================
2420 Syntax:
2425   pragma Import_Object
2426        [Internal =>] LOCAL_NAME
2427     [, [External =>] EXTERNAL_SYMBOL]
2428     [, [Size     =>] EXTERNAL_SYMBOL]);
2430   EXTERNAL_SYMBOL ::=
2431     IDENTIFIER
2432   | static_string_EXPRESSION
2435 This pragma designates an object as imported, and apart from the
2436 extended rules for external symbols, is identical in effect to the use of
2437 the normal `Import` pragma applied to an object.  Unlike the
2438 subprogram case, you need not use a separate `Import` pragma,
2439 although you may do so (and probably should do so from a portability
2440 point of view).  `size` is syntax checked, but otherwise ignored by
2441 GNAT.
2443 Pragma Import_Procedure
2444 =======================
2446 Syntax:
2451   pragma Import_Procedure (
2452        [Internal                 =>] LOCAL_NAME
2453     [, [External                 =>] EXTERNAL_SYMBOL]
2454     [, [Parameter_Types          =>] PARAMETER_TYPES]
2455     [, [Mechanism                =>] MECHANISM]);
2457   EXTERNAL_SYMBOL ::=
2458     IDENTIFIER
2459   | static_string_EXPRESSION
2461   PARAMETER_TYPES ::=
2462     null
2463   | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2465   TYPE_DESIGNATOR ::=
2466     subtype_NAME
2467   | subtype_Name ' Access
2469   MECHANISM ::=
2470     MECHANISM_NAME
2471   | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2473   MECHANISM_ASSOCIATION ::=
2474     [formal_parameter_NAME =>] MECHANISM_NAME
2476   MECHANISM_NAME ::= Value | Reference
2479 This pragma is identical to `Import_Function` except that it
2480 applies to a procedure rather than a function and the parameters
2481 `Result_Type` and `Result_Mechanism` are not permitted.
2483 Pragma Import_Valued_Procedure
2484 ==============================
2486 Syntax:
2491   pragma Import_Valued_Procedure (
2492        [Internal                 =>] LOCAL_NAME
2493     [, [External                 =>] EXTERNAL_SYMBOL]
2494     [, [Parameter_Types          =>] PARAMETER_TYPES]
2495     [, [Mechanism                =>] MECHANISM]);
2497   EXTERNAL_SYMBOL ::=
2498     IDENTIFIER
2499   | static_string_EXPRESSION
2501   PARAMETER_TYPES ::=
2502     null
2503   | TYPE_DESIGNATOR {, TYPE_DESIGNATOR}
2505   TYPE_DESIGNATOR ::=
2506     subtype_NAME
2507   | subtype_Name ' Access
2509   MECHANISM ::=
2510     MECHANISM_NAME
2511   | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION})
2513   MECHANISM_ASSOCIATION ::=
2514     [formal_parameter_NAME =>] MECHANISM_NAME
2516   MECHANISM_NAME ::= Value | Reference
2519 This pragma is identical to `Import_Procedure` except that the
2520 first parameter of `LOCAL_NAME`, which must be present, must be of
2521 mode `OUT`, and externally the subprogram is treated as a function
2522 with this parameter as the result of the function.  The purpose of this
2523 capability is to allow the use of `OUT` and `IN OUT`
2524 parameters in interfacing to external functions (which are not permitted
2525 in Ada functions).  You may optionally use the `Mechanism`
2526 parameters to specify passing mechanisms for the parameters.
2527 If you specify a single mechanism name, it applies to all parameters.
2528 Otherwise you may specify a mechanism on a parameter by parameter
2529 basis using either positional or named notation.  If the mechanism is not
2530 specified, the default mechanism is used.
2532 Note that it is important to use this pragma in conjunction with a separate
2533 pragma Import that specifies the desired convention, since otherwise the
2534 default convention is Ada, which is almost certainly not what is required.
2536 Pragma Independent
2537 ==================
2539 Syntax:
2542 .. code-block:: ada
2544   pragma Independent (Local_NAME);
2547 This pragma is standard in Ada 2012 mode (which also provides an aspect
2548 of the same name). It is also available as an implementation-defined
2549 pragma in all earlier versions. It specifies that the
2550 designated object or all objects of the designated type must be
2551 independently addressable. This means that separate tasks can safely
2552 manipulate such objects. For example, if two components of a record are
2553 independent, then two separate tasks may access these two components.
2554 This may place
2555 constraints on the representation of the object (for instance prohibiting
2556 tight packing).
2558 Pragma Independent_Components
2559 =============================
2561 Syntax:
2564 .. code-block:: ada
2566   pragma Independent_Components (Local_NAME);
2569 This pragma is standard in Ada 2012 mode (which also provides an aspect
2570 of the same name). It is also available as an implementation-defined
2571 pragma in all earlier versions. It specifies that the components of the
2572 designated object, or the components of each object of the designated
2573 type, must be
2574 independently addressable. This means that separate tasks can safely
2575 manipulate separate components in the composite object. This may place
2576 constraints on the representation of the object (for instance prohibiting
2577 tight packing).
2579 Pragma Initial_Condition
2580 ========================
2582 For the description of this pragma, see SPARK 2014 Reference Manual,
2583 section 7.1.6.
2585 Pragma Initialize_Scalars
2586 =========================
2587 .. index:: debugging with Initialize_Scalars
2589 Syntax:
2592 .. code-block:: ada
2594   pragma Initialize_Scalars;
2597 This pragma is similar to `Normalize_Scalars` conceptually but has
2598 two important differences.  First, there is no requirement for the pragma
2599 to be used uniformly in all units of a partition, in particular, it is fine
2600 to use this just for some or all of the application units of a partition,
2601 without needing to recompile the run-time library.
2603 In the case where some units are compiled with the pragma, and some without,
2604 then a declaration of a variable where the type is defined in package
2605 Standard or is locally declared will always be subject to initialization,
2606 as will any declaration of a scalar variable.  For composite variables,
2607 whether the variable is initialized may also depend on whether the package
2608 in which the type of the variable is declared is compiled with the pragma.
2610 The other important difference is that you can control the value used
2611 for initializing scalar objects.  At bind time, you can select several
2612 options for initialization. You can
2613 initialize with invalid values (similar to Normalize_Scalars, though for
2614 Initialize_Scalars it is not always possible to determine the invalid
2615 values in complex cases like signed component fields with non-standard
2616 sizes). You can also initialize with high or
2617 low values, or with a specified bit pattern.  See the GNAT
2618 User's Guide for binder options for specifying these cases.
2620 This means that you can compile a program, and then without having to
2621 recompile the program, you can run it with different values being used
2622 for initializing otherwise uninitialized values, to test if your program
2623 behavior depends on the choice.  Of course the behavior should not change,
2624 and if it does, then most likely you have an incorrect reference to an
2625 uninitialized value.
2627 It is even possible to change the value at execution time eliminating even
2628 the need to rebind with a different switch using an environment variable.
2629 See the GNAT User's Guide for details.
2631 Note that pragma `Initialize_Scalars` is particularly useful in
2632 conjunction with the enhanced validity checking that is now provided
2633 in GNAT, which checks for invalid values under more conditions.
2634 Using this feature (see description of the *-gnatV* flag in the
2635 GNAT User's Guide) in conjunction with
2636 pragma `Initialize_Scalars`
2637 provides a powerful new tool to assist in the detection of problems
2638 caused by uninitialized variables.
2640 Note: the use of `Initialize_Scalars` has a fairly extensive
2641 effect on the generated code. This may cause your code to be
2642 substantially larger. It may also cause an increase in the amount
2643 of stack required, so it is probably a good idea to turn on stack
2644 checking (see description of stack checking in the GNAT
2645 User's Guide) when using this pragma.
2647 Pragma Initializes
2648 ==================
2650 For the description of this pragma, see SPARK 2014 Reference Manual,
2651 section 7.1.5.
2653 Pragma Inline_Always
2654 ====================
2656 Syntax:
2661   pragma Inline_Always (NAME [, NAME]);
2664 Similar to pragma `Inline` except that inlining is not subject to
2665 the use of option *-gnatn* or *-gnatN* and the inlining
2666 happens regardless of whether these options are used.
2668 Pragma Inline_Generic
2669 =====================
2671 Syntax:
2676   pragma Inline_Generic (GNAME {, GNAME});
2678   GNAME ::= generic_unit_NAME | generic_instance_NAME
2681 This pragma is provided for compatibility with Dec Ada 83. It has
2682 no effect in `GNAT` (which always inlines generics), other
2683 than to check that the given names are all names of generic units or
2684 generic instances.
2686 Pragma Interface
2687 ================
2689 Syntax:
2694   pragma Interface (
2695        [Convention    =>] convention_identifier,
2696        [Entity        =>] local_NAME
2697     [, [External_Name =>] static_string_expression]
2698     [, [Link_Name     =>] static_string_expression]);
2701 This pragma is identical in syntax and semantics to
2702 the standard Ada pragma `Import`.  It is provided for compatibility
2703 with Ada 83.  The definition is upwards compatible both with pragma
2704 `Interface` as defined in the Ada 83 Reference Manual, and also
2705 with some extended implementations of this pragma in certain Ada 83
2706 implementations.  The only difference between pragma `Interface`
2707 and pragma `Import` is that there is special circuitry to allow
2708 both pragmas to appear for the same subprogram entity (normally it
2709 is illegal to have multiple `Import` pragmas. This is useful in
2710 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2711 Ada 83 compilers.
2713 Pragma Interface_Name
2714 =====================
2716 Syntax:
2721   pragma Interface_Name (
2722        [Entity        =>] LOCAL_NAME
2723     [, [External_Name =>] static_string_EXPRESSION]
2724     [, [Link_Name     =>] static_string_EXPRESSION]);
2727 This pragma provides an alternative way of specifying the interface name
2728 for an interfaced subprogram, and is provided for compatibility with Ada
2729 83 compilers that use the pragma for this purpose.  You must provide at
2730 least one of `External_Name` or `Link_Name`.
2732 Pragma Interrupt_Handler
2733 ========================
2735 Syntax:
2738 .. code-block:: ada
2740   pragma Interrupt_Handler (procedure_LOCAL_NAME);
2743 This program unit pragma is supported for parameterless protected procedures
2744 as described in Annex C of the Ada Reference Manual. On the AAMP target
2745 the pragma can also be specified for nonprotected parameterless procedures
2746 that are declared at the library level (which includes procedures
2747 declared at the top level of a library package). In the case of AAMP,
2748 when this pragma is applied to a nonprotected procedure, the instruction
2749 `IERET` is generated for returns from the procedure, enabling
2750 maskable interrupts, in place of the normal return instruction.
2752 Pragma Interrupt_State
2753 ======================
2755 Syntax:
2760   pragma Interrupt_State
2761    ([Name  =>] value,
2762     [State =>] SYSTEM | RUNTIME | USER);
2765 Normally certain interrupts are reserved to the implementation.  Any attempt
2766 to attach an interrupt causes Program_Error to be raised, as described in
2767 RM C.3.2(22).  A typical example is the `SIGINT` interrupt used in
2768 many systems for an :kbd:`Ctrl-C` interrupt.  Normally this interrupt is
2769 reserved to the implementation, so that :kbd:`Ctrl-C` can be used to
2770 interrupt execution.  Additionally, signals such as `SIGSEGV`,
2771 `SIGABRT`, `SIGFPE` and `SIGILL` are often mapped to specific
2772 Ada exceptions, or used to implement run-time functions such as the
2773 `abort` statement and stack overflow checking.
2775 Pragma `Interrupt_State` provides a general mechanism for overriding
2776 such uses of interrupts.  It subsumes the functionality of pragma
2777 `Unreserve_All_Interrupts`.  Pragma `Interrupt_State` is not
2778 available on Windows or VMS.  On all other platforms than VxWorks,
2779 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2780 and may be used to mark interrupts required by the board support package
2781 as reserved.
2783 Interrupts can be in one of three states:
2785 * System
2787   The interrupt is reserved (no Ada handler can be installed), and the
2788   Ada run-time may not install a handler. As a result you are guaranteed
2789   standard system default action if this interrupt is raised.
2791 * Runtime
2793   The interrupt is reserved (no Ada handler can be installed). The run time
2794   is allowed to install a handler for internal control purposes, but is
2795   not required to do so.
2797 * User
2799   The interrupt is unreserved.  The user may install a handler to provide
2800   some other action.
2802 These states are the allowed values of the `State` parameter of the
2803 pragma.  The `Name` parameter is a value of the type
2804 `Ada.Interrupts.Interrupt_ID`.  Typically, it is a name declared in
2805 `Ada.Interrupts.Names`.
2807 This is a configuration pragma, and the binder will check that there
2808 are no inconsistencies between different units in a partition in how a
2809 given interrupt is specified. It may appear anywhere a pragma is legal.
2811 The effect is to move the interrupt to the specified state.
2813 By declaring interrupts to be SYSTEM, you guarantee the standard system
2814 action, such as a core dump.
2816 By declaring interrupts to be USER, you guarantee that you can install
2817 a handler.
2819 Note that certain signals on many operating systems cannot be caught and
2820 handled by applications.  In such cases, the pragma is ignored.  See the
2821 operating system documentation, or the value of the array `Reserved`
2822 declared in the spec of package `System.OS_Interface`.
2824 Overriding the default state of signals used by the Ada runtime may interfere
2825 with an application's runtime behavior in the cases of the synchronous signals,
2826 and in the case of the signal used to implement the `abort` statement.
2828 Pragma Invariant
2829 ================
2831 Syntax:
2836   pragma Invariant
2837     ([Entity =>]    private_type_LOCAL_NAME,
2838      [Check  =>]    EXPRESSION
2839      [,[Message =>] String_Expression]);
2842 This pragma provides exactly the same capabilities as the Type_Invariant aspect
2843 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
2844 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
2845 requires the use of the aspect syntax, which is not available except in 2012
2846 mode, it is not possible to use the Type_Invariant aspect in earlier versions
2847 of Ada. However the Invariant pragma may be used in any version of Ada. Also
2848 note that the aspect Invariant is a synonym in GNAT for the aspect
2849 Type_Invariant, but there is no pragma Type_Invariant.
2851 The pragma must appear within the visible part of the package specification,
2852 after the type to which its Entity argument appears. As with the Invariant
2853 aspect, the Check expression is not analyzed until the end of the visible
2854 part of the package, so it may contain forward references. The Message
2855 argument, if present, provides the exception message used if the invariant
2856 is violated. If no Message parameter is provided, a default message that
2857 identifies the line on which the pragma appears is used.
2859 It is permissible to have multiple Invariants for the same type entity, in
2860 which case they are and'ed together. It is permissible to use this pragma
2861 in Ada 2012 mode, but you cannot have both an invariant aspect and an
2862 invariant pragma for the same entity.
2864 For further details on the use of this pragma, see the Ada 2012 documentation
2865 of the Type_Invariant aspect.
2867 Pragma Java_Constructor
2868 =======================
2870 Syntax:
2875   pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
2878 This pragma is used to assert that the specified Ada function should be
2879 mapped to the Java constructor for some Ada tagged record type.
2881 See section 7.3.2 of the
2882 `GNAT User's Guide: Supplement for the JVM Platform.`
2883 for related information.
2885 Pragma Java_Interface
2886 =====================
2888 Syntax:
2893   pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
2896 This pragma is used to assert that the specified Ada abstract tagged type
2897 is to be mapped to a Java interface name.
2899 See sections 7.1 and 7.2 of the
2900 `GNAT User's Guide: Supplement for the JVM Platform.`
2901 for related information.
2903 Pragma Keep_Names
2904 =================
2906 Syntax:
2911   pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2914 The `LOCAL_NAME` argument
2915 must refer to an enumeration first subtype
2916 in the current declarative part. The effect is to retain the enumeration
2917 literal names for use by `Image` and `Value` even if a global
2918 `Discard_Names` pragma applies. This is useful when you want to
2919 generally suppress enumeration literal names and for example you therefore
2920 use a `Discard_Names` pragma in the :file:`gnat.adc` file, but you
2921 want to retain the names for specific enumeration types.
2923 Pragma License
2924 ==============
2925 .. index:: License checking
2927 Syntax:
2930 .. code-block:: ada
2932   pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2935 This pragma is provided to allow automated checking for appropriate license
2936 conditions with respect to the standard and modified GPL.  A pragma
2937 `License`, which is a configuration pragma that typically appears at
2938 the start of a source file or in a separate :file:`gnat.adc` file, specifies
2939 the licensing conditions of a unit as follows:
2941 * Unrestricted
2942   This is used for a unit that can be freely used with no license restrictions.
2943   Examples of such units are public domain units, and units from the Ada
2944   Reference Manual.
2946 * GPL
2947   This is used for a unit that is licensed under the unmodified GPL, and which
2948   therefore cannot be `with`'ed by a restricted unit.
2950 * Modified_GPL
2951   This is used for a unit licensed under the GNAT modified GPL that includes
2952   a special exception paragraph that specifically permits the inclusion of
2953   the unit in programs without requiring the entire program to be released
2954   under the GPL.
2956 * Restricted
2957   This is used for a unit that is restricted in that it is not permitted to
2958   depend on units that are licensed under the GPL.  Typical examples are
2959   proprietary code that is to be released under more restrictive license
2960   conditions.  Note that restricted units are permitted to `with` units
2961   which are licensed under the modified GPL (this is the whole point of the
2962   modified GPL).
2965 Normally a unit with no `License` pragma is considered to have an
2966 unknown license, and no checking is done.  However, standard GNAT headers
2967 are recognized, and license information is derived from them as follows.
2969 A GNAT license header starts with a line containing 78 hyphens.  The following
2970 comment text is searched for the appearance of any of the following strings.
2972 If the string 'GNU General Public License' is found, then the unit is assumed
2973 to have GPL license, unless the string 'As a special exception' follows, in
2974 which case the license is assumed to be modified GPL.
2976 If one of the strings
2977 'This specification is adapted from the Ada Semantic Interface' or
2978 'This specification is derived from the Ada Reference Manual' is found
2979 then the unit is assumed to be unrestricted.
2981 These default actions means that a program with a restricted license pragma
2982 will automatically get warnings if a GPL unit is inappropriately
2983 `with`'ed.  For example, the program:
2985 .. code-block:: ada
2987   with Sem_Ch3;
2988   with GNAT.Sockets;
2989   procedure Secret_Stuff is
2990     ...
2991   end Secret_Stuff
2994 if compiled with pragma `License` (`Restricted`) in a
2995 :file:`gnat.adc` file will generate the warning::
2997   1.  with Sem_Ch3;
2998           |
2999      >>> license of withed unit "Sem_Ch3" is incompatible
3001   2.  with GNAT.Sockets;
3002   3.  procedure Secret_Stuff is
3005 Here we get a warning on `Sem_Ch3` since it is part of the GNAT
3006 compiler and is licensed under the
3007 GPL, but no warning for `GNAT.Sockets` which is part of the GNAT
3008 run time, and is therefore licensed under the modified GPL.
3010 Pragma Link_With
3011 ================
3013 Syntax:
3018   pragma Link_With (static_string_EXPRESSION {,static_string_EXPRESSION});
3021 This pragma is provided for compatibility with certain Ada 83 compilers.
3022 It has exactly the same effect as pragma `Linker_Options` except
3023 that spaces occurring within one of the string expressions are treated
3024 as separators. For example, in the following case:
3026 .. code-block:: ada
3028   pragma Link_With ("-labc -ldef");
3031 results in passing the strings `-labc` and `-ldef` as two
3032 separate arguments to the linker. In addition pragma Link_With allows
3033 multiple arguments, with the same effect as successive pragmas.
3035 Pragma Linker_Alias
3036 ===================
3038 Syntax:
3043   pragma Linker_Alias (
3044     [Entity =>] LOCAL_NAME,
3045     [Target =>] static_string_EXPRESSION);
3048 `LOCAL_NAME` must refer to an object that is declared at the library
3049 level. This pragma establishes the given entity as a linker alias for the
3050 given target. It is equivalent to `__attribute__((alias))` in GNU C
3051 and causes `LOCAL_NAME` to be emitted as an alias for the symbol
3052 `static_string_EXPRESSION` in the object file, that is to say no space
3053 is reserved for `LOCAL_NAME` by the assembler and it will be resolved
3054 to the same address as `static_string_EXPRESSION` by the linker.
3056 The actual linker name for the target must be used (e.g., the fully
3057 encoded name with qualification in Ada, or the mangled name in C++),
3058 or it must be declared using the C convention with `pragma Import`
3059 or `pragma Export`.
3061 Not all target machines support this pragma. On some of them it is accepted
3062 only if `pragma Weak_External` has been applied to `LOCAL_NAME`.
3065 .. code-block:: ada
3067   --  Example of the use of pragma Linker_Alias
3069   package p is
3070     i : Integer := 1;
3071     pragma Export (C, i);
3073     new_name_for_i : Integer;
3074     pragma Linker_Alias (new_name_for_i, "i");
3075   end p;
3078 Pragma Linker_Constructor
3079 =========================
3081 Syntax:
3084 .. code-block:: ada
3086   pragma Linker_Constructor (procedure_LOCAL_NAME);
3089 `procedure_LOCAL_NAME` must refer to a parameterless procedure that
3090 is declared at the library level. A procedure to which this pragma is
3091 applied will be treated as an initialization routine by the linker.
3092 It is equivalent to `__attribute__((constructor))` in GNU C and
3093 causes `procedure_LOCAL_NAME` to be invoked before the entry point
3094 of the executable is called (or immediately after the shared library is
3095 loaded if the procedure is linked in a shared library), in particular
3096 before the Ada run-time environment is set up.
3098 Because of these specific contexts, the set of operations such a procedure
3099 can perform is very limited and the type of objects it can manipulate is
3100 essentially restricted to the elementary types. In particular, it must only
3101 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3103 This pragma is used by GNAT to implement auto-initialization of shared Stand
3104 Alone Libraries, which provides a related capability without the restrictions
3105 listed above. Where possible, the use of Stand Alone Libraries is preferable
3106 to the use of this pragma.
3108 Pragma Linker_Destructor
3109 ========================
3111 Syntax:
3114 .. code-block:: ada
3116   pragma Linker_Destructor (procedure_LOCAL_NAME);
3119 `procedure_LOCAL_NAME` must refer to a parameterless procedure that
3120 is declared at the library level. A procedure to which this pragma is
3121 applied will be treated as a finalization routine by the linker.
3122 It is equivalent to `__attribute__((destructor))` in GNU C and
3123 causes `procedure_LOCAL_NAME` to be invoked after the entry point
3124 of the executable has exited (or immediately before the shared library
3125 is unloaded if the procedure is linked in a shared library), in particular
3126 after the Ada run-time environment is shut down.
3128 See `pragma Linker_Constructor` for the set of restrictions that apply
3129 because of these specific contexts.
3131 Pragma Linker_Section
3132 =====================
3134 Syntax:
3139   pragma Linker_Section (
3140     [Entity  =>] LOCAL_NAME,
3141     [Section =>] static_string_EXPRESSION);
3144 `LOCAL_NAME` must refer to an object, type, or subprogram that is
3145 declared at the library level. This pragma specifies the name of the
3146 linker section for the given entity. It is equivalent to
3147 `__attribute__((section))` in GNU C and causes `LOCAL_NAME` to
3148 be placed in the `static_string_EXPRESSION` section of the
3149 executable (assuming the linker doesn't rename the section).
3150 GNAT also provides an implementation defined aspect of the same name.
3152 In the case of specifying this aspect for a type, the effect is to
3153 specify the corresponding for all library level objects of the type which
3154 do not have an explicit linker section set. Note that this only applies to
3155 whole objects, not to components of composite objects.
3157 In the case of a subprogram, the linker section applies to all previously
3158 declared matching overloaded subprograms in the current declarative part
3159 which do not already have a linker section assigned. The linker section
3160 aspect is useful in this case for specifying different linker sections
3161 for different elements of such an overloaded set.
3163 Note that an empty string specifies that no linker section is specified.
3164 This is not quite the same as omitting the pragma or aspect, since it
3165 can be used to specify that one element of an overloaded set of subprograms
3166 has the default linker section, or that one object of a type for which a
3167 linker section is specified should has the default linker section.
3169 The compiler normally places library-level entities in standard sections
3170 depending on the class: procedures and functions generally go in the
3171 `.text` section, initialized variables in the `.data` section
3172 and uninitialized variables in the `.bss` section.
3174 Other, special sections may exist on given target machines to map special
3175 hardware, for example I/O ports or flash memory. This pragma is a means to
3176 defer the final layout of the executable to the linker, thus fully working
3177 at the symbolic level with the compiler.
3179 Some file formats do not support arbitrary sections so not all target
3180 machines support this pragma. The use of this pragma may cause a program
3181 execution to be erroneous if it is used to place an entity into an
3182 inappropriate section (e.g., a modified variable into the `.text`
3183 section). See also `pragma Persistent_BSS`.
3186 .. code-block:: ada
3188   --  Example of the use of pragma Linker_Section
3190   package IO_Card is
3191     Port_A : Integer;
3192     pragma Volatile (Port_A);
3193     pragma Linker_Section (Port_A, ".bss.port_a");
3195     Port_B : Integer;
3196     pragma Volatile (Port_B);
3197     pragma Linker_Section (Port_B, ".bss.port_b");
3199     type Port_Type is new Integer with Linker_Section => ".bss";
3200     PA : Port_Type with Linker_Section => ".bss.PA";
3201     PB : Port_Type; --  ends up in linker section ".bss"
3203     procedure Q with Linker_Section => "Qsection";
3204   end IO_Card;
3207 Pragma Lock_Free
3208 ================
3210 Syntax:
3211 This pragma may be specified for protected types or objects. It specifies that
3212 the implementation of protected operations must be implemented without locks.
3213 Compilation fails if the compiler cannot generate lock-free code for the
3214 operations.
3216 Pragma Loop_Invariant
3217 =====================
3219 Syntax:
3222 .. code-block:: ada
3224   pragma Loop_Invariant ( boolean_EXPRESSION );
3227 The effect of this pragma is similar to that of pragma `Assert`,
3228 except that in an `Assertion_Policy` pragma, the identifier
3229 `Loop_Invariant` is used to control whether it is ignored or checked
3230 (or disabled).
3232 `Loop_Invariant` can only appear as one of the items in the sequence
3233 of statements of a loop body, or nested inside block statements that
3234 appear in the sequence of statements of a loop body.
3235 The intention is that it be used to
3236 represent a "loop invariant" assertion, i.e. something that is true each
3237 time through the loop, and which can be used to show that the loop is
3238 achieving its purpose.
3240 Multiple `Loop_Invariant` and `Loop_Variant` pragmas that
3241 apply to the same loop should be grouped in the same sequence of
3242 statements.
3244 To aid in writing such invariants, the special attribute `Loop_Entry`
3245 may be used to refer to the value of an expression on entry to the loop. This
3246 attribute can only be used within the expression of a `Loop_Invariant`
3247 pragma. For full details, see documentation of attribute `Loop_Entry`.
3249 Pragma Loop_Optimize
3250 ====================
3252 Syntax:
3257   pragma Loop_Optimize (OPTIMIZATION_HINT {, OPTIMIZATION_HINT});
3259   OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
3262 This pragma must appear immediately within a loop statement.  It allows the
3263 programmer to specify optimization hints for the enclosing loop.  The hints
3264 are not mutually exclusive and can be freely mixed, but not all combinations
3265 will yield a sensible outcome.
3267 There are five supported optimization hints for a loop:
3269 * Ivdep
3271   The programmer asserts that there are no loop-carried dependencies
3272   which would prevent consecutive iterations of the loop from being
3273   executed simultaneously.
3275 * No_Unroll
3277   The loop must not be unrolled.  This is a strong hint: the compiler will not
3278   unroll a loop marked with this hint.
3280 * Unroll
3282   The loop should be unrolled.  This is a weak hint: the compiler will try to
3283   apply unrolling to this loop preferably to other optimizations, notably
3284   vectorization, but there is no guarantee that the loop will be unrolled.
3286 * No_Vector
3288   The loop must not be vectorized.  This is a strong hint: the compiler will not
3289   vectorize a loop marked with this hint.
3291 * Vector
3293   The loop should be vectorized.  This is a weak hint: the compiler will try to
3294   apply vectorization to this loop preferably to other optimizations, notably
3295   unrolling, but there is no guarantee that the loop will be vectorized.
3298 These hints do not remove the need to pass the appropriate switches to the
3299 compiler in order to enable the relevant optimizations, that is to say
3300 *-funroll-loops* for unrolling and *-ftree-vectorize* for
3301 vectorization.
3303 Pragma Loop_Variant
3304 ===================
3306 Syntax:
3311   pragma Loop_Variant ( LOOP_VARIANT_ITEM {, LOOP_VARIANT_ITEM } );
3312   LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
3313   CHANGE_DIRECTION ::= Increases | Decreases
3316 `Loop_Variant` can only appear as one of the items in the sequence
3317 of statements of a loop body, or nested inside block statements that
3318 appear in the sequence of statements of a loop body.
3319 It allows the specification of quantities which must always
3320 decrease or increase in successive iterations of the loop. In its simplest
3321 form, just one expression is specified, whose value must increase or decrease
3322 on each iteration of the loop.
3324 In a more complex form, multiple arguments can be given which are intepreted
3325 in a nesting lexicographic manner. For example:
3327 .. code-block:: ada
3329   pragma Loop_Variant (Increases => X, Decreases => Y);
3332 specifies that each time through the loop either X increases, or X stays
3333 the same and Y decreases. A `Loop_Variant` pragma ensures that the
3334 loop is making progress. It can be useful in helping to show informally
3335 or prove formally that the loop always terminates.
3337 `Loop_Variant` is an assertion whose effect can be controlled using
3338 an `Assertion_Policy` with a check name of `Loop_Variant`. The
3339 policy can be `Check` to enable the loop variant check, `Ignore`
3340 to ignore the check (in which case the pragma has no effect on the program),
3341 or `Disable` in which case the pragma is not even checked for correct
3342 syntax.
3344 Multiple `Loop_Invariant` and `Loop_Variant` pragmas that
3345 apply to the same loop should be grouped in the same sequence of
3346 statements.
3348 The `Loop_Entry` attribute may be used within the expressions of the
3349 `Loop_Variant` pragma to refer to values on entry to the loop.
3351 Pragma Machine_Attribute
3352 ========================
3354 Syntax:
3359   pragma Machine_Attribute (
3360        [Entity         =>] LOCAL_NAME,
3361        [Attribute_Name =>] static_string_EXPRESSION
3362     [, [Info           =>] static_EXPRESSION] );
3365 Machine-dependent attributes can be specified for types and/or
3366 declarations.  This pragma is semantically equivalent to
3367 `__attribute__((`attribute_name`))` (if `info` is not
3368 specified) or `__attribute__((`attribute_name`(`info`)))
3369 in GNU C, where ``attribute_name`` is recognized by the
3370 compiler middle-end or the `TARGET_ATTRIBUTE_TABLE` machine
3371 specific macro.  A string literal for the optional parameter `info`
3372 is transformed into an identifier, which may make this pragma unusable
3373 for some attributes.
3374 For further information see :title:`GNU Compiler Collection (GCC) Internals`.
3376 Pragma Main
3377 ===========
3379 Syntax::
3381   pragma Main
3382    (MAIN_OPTION [, MAIN_OPTION]);
3384   MAIN_OPTION ::=
3385     [Stack_Size              =>] static_integer_EXPRESSION
3386   | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3387   | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3390 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3391 no effect in GNAT, other than being syntax checked.
3393 Pragma Main_Storage
3394 ===================
3396 Syntax::
3398   pragma Main_Storage
3399     (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3401   MAIN_STORAGE_OPTION ::=
3402     [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3403   | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3406 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3407 no effect in GNAT, other than being syntax checked.
3409 Pragma No_Body
3410 ==============
3412 Syntax:
3415 .. code-block:: ada
3417   pragma No_Body;
3420 There are a number of cases in which a package spec does not require a body,
3421 and in fact a body is not permitted. GNAT will not permit the spec to be
3422 compiled if there is a body around. The pragma No_Body allows you to provide
3423 a body file, even in a case where no body is allowed. The body file must
3424 contain only comments and a single No_Body pragma. This is recognized by
3425 the compiler as indicating that no body is logically present.
3427 This is particularly useful during maintenance when a package is modified in
3428 such a way that a body needed before is no longer needed. The provision of a
3429 dummy body with a No_Body pragma ensures that there is no interference from
3430 earlier versions of the package body.
3432 Pragma No_Elaboration_Code_All
3433 ==============================
3435 Syntax:
3440   pragma No_Elaboration_Code_All [(program_unit_NAME)];
3443 This is a program unit pragma (there is also an equivalent aspect of the
3444 same name) that establishes the restriction `No_Elaboration_Code` for
3445 the current unit and any extended main source units (body and subunits.
3446 It also has has the effect of enforcing a transitive application of this
3447 aspect, so that if any unit is implicitly or explicitly WITH'ed by the
3448 current unit, it must also have the No_Elaboration_Code_All aspect set.
3449 It may be applied to package or subprogram specs or their generic versions.
3451 Pragma No_Inline
3452 ================
3454 Syntax:
3459   pragma No_Inline (NAME {, NAME});
3462 This pragma suppresses inlining for the callable entity or the instances of
3463 the generic subprogram designated by `NAME`, including inlining that
3464 results from the use of pragma `Inline`.  This pragma is always active,
3465 in particular it is not subject to the use of option *-gnatn* or
3466 *-gnatN*.  It is illegal to specify both pragma `No_Inline` and
3467 pragma `Inline_Always` for the same `NAME`.
3469 Pragma No_Return
3470 ================
3472 Syntax:
3477   pragma No_Return (procedure_LOCAL_NAME {, procedure_LOCAL_NAME});
3480 Each `procedure_LOCAL_NAME` argument must refer to one or more procedure
3481 declarations in the current declarative part.  A procedure to which this
3482 pragma is applied may not contain any explicit `return` statements.
3483 In addition, if the procedure contains any implicit returns from falling
3484 off the end of a statement sequence, then execution of that implicit
3485 return will cause Program_Error to be raised.
3487 One use of this pragma is to identify procedures whose only purpose is to raise
3488 an exception. Another use of this pragma is to suppress incorrect warnings
3489 about missing returns in functions, where the last statement of a function
3490 statement sequence is a call to such a procedure.
3492 Note that in Ada 2005 mode, this pragma is part of the language. It is
3493 available in all earlier versions of Ada as an implementation-defined
3494 pragma.
3496 Pragma No_Run_Time
3497 ==================
3499 Syntax:
3502 .. code-block:: ada
3504   pragma No_Run_Time;
3507 This is an obsolete configuration pragma that historically was used to
3508 set up a runtime library with no object code. It is now used only for
3509 internal testing. The pragma has been superseded by the reconfigurable
3510 runtime capability of `GNAT`.
3512 Pragma No_Strict_Aliasing
3513 =========================
3515 Syntax:
3520   pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3523 `type_LOCAL_NAME` must refer to an access type
3524 declaration in the current declarative part.  The effect is to inhibit
3525 strict aliasing optimization for the given type.  The form with no
3526 arguments is a configuration pragma which applies to all access types
3527 declared in units to which the pragma applies. For a detailed
3528 description of the strict aliasing optimization, and the situations
3529 in which it must be suppressed, see the section on Optimization and Strict Aliasing
3530 in the :title:`GNAT User's Guide`.
3532 This pragma currently has no effects on access to unconstrained array types.
3534 Pragma No_Tagged_Streams
3535 ========================
3537 Syntax:
3542   pragma No_Tagged_Streams;
3543   pragma No_Tagged_Streams [([Entity =>] tagged_type_LOCAL_NAME)];
3546 Normally when a tagged type is introduced using a full type declaration,
3547 part of the processing includes generating stream access routines to be
3548 used by stream attributes referencing the type (or one of its subtypes
3549 or derived types). This can involve the generation of significant amounts
3550 of code which is wasted space if stream routines are not needed for the
3551 type in question.
3553 The `No_Tagged_Streams` pragma causes the generation of these stream
3554 routines to be skipped, and any attempt to use stream operations on
3555 types subject to this pragma will be statically rejected as illegal.
3557 There are two forms of the pragma. The form with no arguments must appear
3558 in a declarative sequence or in the declarations of a package spec. This
3559 pragma affects all subsequent root tagged types declared in the declaration
3560 sequence, and specifies that no stream routines be generated. The form with
3561 an argument (for which there is also a corresponding aspect) specifies a
3562 single root tagged type for which stream routines are not to be generated.
3564 Once the pragma has been given for a particular root tagged type, all subtypes
3565 and derived types of this type inherit the pragma automatically, so the effect
3566 applies to a complete hierarchy (this is necessary to deal with the class-wide
3567 dispatching versions of the stream routines).
3569 Pragma Normalize_Scalars
3570 ========================
3572 Syntax:
3575 .. code-block:: ada
3577   pragma Normalize_Scalars;
3580 This is a language defined pragma which is fully implemented in GNAT.  The
3581 effect is to cause all scalar objects that are not otherwise initialized
3582 to be initialized.  The initial values are implementation dependent and
3583 are as follows:
3587 *Standard.Character*
3588   Objects whose root type is Standard.Character are initialized to
3589   Character'Last unless the subtype range excludes NUL (in which case
3590   NUL is used). This choice will always generate an invalid value if
3591   one exists.
3594 *Standard.Wide_Character*
3595   Objects whose root type is Standard.Wide_Character are initialized to
3596   Wide_Character'Last unless the subtype range excludes NUL (in which case
3597   NUL is used). This choice will always generate an invalid value if
3598   one exists.
3601 *Standard.Wide_Wide_Character*
3602   Objects whose root type is Standard.Wide_Wide_Character are initialized to
3603   the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3604   which case NUL is used). This choice will always generate an invalid value if
3605   one exists.
3608 *Integer types*
3609   Objects of an integer type are treated differently depending on whether
3610   negative values are present in the subtype. If no negative values are
3611   present, then all one bits is used as the initial value except in the
3612   special case where zero is excluded from the subtype, in which case
3613   all zero bits are used. This choice will always generate an invalid
3614   value if one exists.
3616   For subtypes with negative values present, the largest negative number
3617   is used, except in the unusual case where this largest negative number
3618   is in the subtype, and the largest positive number is not, in which case
3619   the largest positive value is used. This choice will always generate
3620   an invalid value if one exists.
3623 *Floating-Point Types*
3624   Objects of all floating-point types are initialized to all 1-bits. For
3625   standard IEEE format, this corresponds to a NaN (not a number) which is
3626   indeed an invalid value.
3629 *Fixed-Point Types*
3630   Objects of all fixed-point types are treated as described above for integers,
3631   with the rules applying to the underlying integer value used to represent
3632   the fixed-point value.
3635 *Modular types*
3636   Objects of a modular type are initialized to all one bits, except in
3637   the special case where zero is excluded from the subtype, in which
3638   case all zero bits are used. This choice will always generate an
3639   invalid value if one exists.
3642 *Enumeration types*
3643   Objects of an enumeration type are initialized to all one-bits, i.e., to
3644   the value `2 ** typ'Size - 1` unless the subtype excludes the literal
3645   whose Pos value is zero, in which case a code of zero is used. This choice
3646   will always generate an invalid value if one exists.
3648 .. _Pragma_Obsolescent:
3650 Pragma Obsolescent
3651 ==================
3653 Syntax:
3658   pragma Obsolescent;
3660   pragma Obsolescent (
3661     [Message =>] static_string_EXPRESSION
3662   [,[Version =>] Ada_05]]);
3664   pragma Obsolescent (
3665     [Entity  =>] NAME
3666   [,[Message =>] static_string_EXPRESSION
3667   [,[Version =>] Ada_05]] );
3670 This pragma can occur immediately following a declaration of an entity,
3671 including the case of a record component. If no Entity argument is present,
3672 then this declaration is the one to which the pragma applies. If an Entity
3673 parameter is present, it must either match the name of the entity in this
3674 declaration, or alternatively, the pragma can immediately follow an enumeration
3675 type declaration, where the Entity argument names one of the enumeration
3676 literals.
3678 This pragma is used to indicate that the named entity
3679 is considered obsolescent and should not be used. Typically this is
3680 used when an API must be modified by eventually removing or modifying
3681 existing subprograms or other entities. The pragma can be used at an
3682 intermediate stage when the entity is still present, but will be
3683 removed later.
3685 The effect of this pragma is to output a warning message on a reference to
3686 an entity thus marked that the subprogram is obsolescent if the appropriate
3687 warning option in the compiler is activated. If the Message parameter is
3688 present, then a second warning message is given containing this text. In
3689 addition, a reference to the entity is considered to be a violation of pragma
3690 Restrictions (No_Obsolescent_Features).
3692 This pragma can also be used as a program unit pragma for a package,
3693 in which case the entity name is the name of the package, and the
3694 pragma indicates that the entire package is considered
3695 obsolescent. In this case a client `with`'ing such a package
3696 violates the restriction, and the `with` statement is
3697 flagged with warnings if the warning option is set.
3699 If the Version parameter is present (which must be exactly
3700 the identifier Ada_05, no other argument is allowed), then the
3701 indication of obsolescence applies only when compiling in Ada 2005
3702 mode. This is primarily intended for dealing with the situations
3703 in the predefined library where subprograms or packages
3704 have become defined as obsolescent in Ada 2005
3705 (e.g., in Ada.Characters.Handling), but may be used anywhere.
3707 The following examples show typical uses of this pragma:
3710 .. code-block:: ada
3712   package p is
3713      pragma Obsolescent (p, Message => "use pp instead of p");
3714   end p;
3716   package q is
3717      procedure q2;
3718      pragma Obsolescent ("use q2new instead");
3720      type R is new integer;
3721      pragma Obsolescent
3722        (Entity  => R,
3723         Message => "use RR in Ada 2005",
3724         Version => Ada_05);
3726      type M is record
3727         F1 : Integer;
3728         F2 : Integer;
3729         pragma Obsolescent;
3730         F3 : Integer;
3731      end record;
3733      type E is (a, bc, 'd', quack);
3734      pragma Obsolescent (Entity => bc)
3735      pragma Obsolescent (Entity => 'd')
3737      function "+"
3738        (a, b : character) return character;
3739      pragma Obsolescent (Entity => "+");
3740   end;
3743 Note that, as for all pragmas, if you use a pragma argument identifier,
3744 then all subsequent parameters must also use a pragma argument identifier.
3745 So if you specify "Entity =>" for the Entity argument, and a Message
3746 argument is present, it must be preceded by "Message =>".
3748 Pragma Optimize_Alignment
3749 =========================
3750 .. index:: Alignment, default settings
3752 Syntax:
3755 .. code-block:: ada
3757   pragma Optimize_Alignment (TIME | SPACE | OFF);
3760 This is a configuration pragma which affects the choice of default alignments
3761 for types and objects where no alignment is explicitly specified. There is a
3762 time/space trade-off in the selection of these values. Large alignments result
3763 in more efficient code, at the expense of larger data space, since sizes have
3764 to be increased to match these alignments. Smaller alignments save space, but
3765 the access code is slower. The normal choice of default alignments for types
3766 and individual alignment promotions for objects (which is what you get if you
3767 do not use this pragma, or if you use an argument of OFF), tries to balance
3768 these two requirements.
3770 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3771 First any packed record is given an alignment of 1. Second, if a size is given
3772 for the type, then the alignment is chosen to avoid increasing this size. For
3773 example, consider:
3776 .. code-block:: ada
3778      type R is record
3779         X : Integer;
3780         Y : Character;
3781      end record;
3783      for R'Size use 5*8;
3786 In the default mode, this type gets an alignment of 4, so that access to the
3787 Integer field X are efficient. But this means that objects of the type end up
3788 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3789 allowed to be bigger than the size of the type, but it can waste space if for
3790 example fields of type R appear in an enclosing record. If the above type is
3791 compiled in `Optimize_Alignment (Space)` mode, the alignment is set to 1.
3793 However, there is one case in which SPACE is ignored. If a variable length
3794 record (that is a discriminated record with a component which is an array
3795 whose length depends on a discriminant), has a pragma Pack, then it is not
3796 in general possible to set the alignment of such a record to one, so the
3797 pragma is ignored in this case (with a warning).
3799 Specifying SPACE also disables alignment promotions for standalone objects,
3800 which occur when the compiler increases the alignment of a specific object
3801 without changing the alignment of its type.
3803 Specifying TIME causes larger default alignments to be chosen in the case of
3804 small types with sizes that are not a power of 2. For example, consider:
3807 .. code-block:: ada
3809      type R is record
3810         A : Character;
3811         B : Character;
3812         C : Boolean;
3813      end record;
3815      pragma Pack (R);
3816      for R'Size use 17;
3819 The default alignment for this record is normally 1, but if this type is
3820 compiled in `Optimize_Alignment (Time)` mode, then the alignment is set
3821 to 4, which wastes space for objects of the type, since they are now 4 bytes
3822 long, but results in more efficient access when the whole record is referenced.
3824 As noted above, this is a configuration pragma, and there is a requirement
3825 that all units in a partition be compiled with a consistent setting of the
3826 optimization setting. This would normally be achieved by use of a configuration
3827 pragma file containing the appropriate setting. The exception to this rule is
3828 that units with an explicit configuration pragma in the same file as the source
3829 unit are excluded from the consistency check, as are all predefined units. The
3830 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3831 pragma appears at the start of the file.
3833 Pragma Ordered
3834 ==============
3836 Syntax:
3839 .. code-block:: ada
3841   pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3844 Most enumeration types are from a conceptual point of view unordered.
3845 For example, consider:
3848 .. code-block:: ada
3850   type Color is (Red, Blue, Green, Yellow);
3853 By Ada semantics `Blue > Red` and `Green > Blue`,
3854 but really these relations make no sense; the enumeration type merely
3855 specifies a set of possible colors, and the order is unimportant.
3857 For unordered enumeration types, it is generally a good idea if
3858 clients avoid comparisons (other than equality or inequality) and
3859 explicit ranges. (A *client* is a unit where the type is referenced,
3860 other than the unit where the type is declared, its body, and its subunits.)
3861 For example, if code buried in some client says:
3864 .. code-block:: ada
3866   if Current_Color < Yellow then ...
3867   if Current_Color in Blue .. Green then ...
3870 then the client code is relying on the order, which is undesirable.
3871 It makes the code hard to read and creates maintenance difficulties if
3872 entries have to be added to the enumeration type. Instead,
3873 the code in the client should list the possibilities, or an
3874 appropriate subtype should be declared in the unit that declares
3875 the original enumeration type. E.g., the following subtype could
3876 be declared along with the type `Color`:
3879 .. code-block:: ada
3881   subtype RBG is Color range Red .. Green;
3884 and then the client could write:
3887 .. code-block:: ada
3889   if Current_Color in RBG then ...
3890   if Current_Color = Blue or Current_Color = Green then ...
3893 However, some enumeration types are legitimately ordered from a conceptual
3894 point of view. For example, if you declare:
3897 .. code-block:: ada
3899   type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3902 then the ordering imposed by the language is reasonable, and
3903 clients can depend on it, writing for example:
3906 .. code-block:: ada
3908   if D in Mon .. Fri then ...
3909   if D < Wed then ...
3912 The pragma *Ordered* is provided to mark enumeration types that
3913 are conceptually ordered, alerting the reader that clients may depend
3914 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3915 rather than one to mark them as unordered, since in our experience,
3916 the great majority of enumeration types are conceptually unordered.
3918 The types `Boolean`, `Character`, `Wide_Character`,
3919 and `Wide_Wide_Character`
3920 are considered to be ordered types, so each is declared with a
3921 pragma `Ordered` in package `Standard`.
3923 Normally pragma `Ordered` serves only as documentation and a guide for
3924 coding standards, but GNAT provides a warning switch *-gnatw.u* that
3925 requests warnings for inappropriate uses (comparisons and explicit
3926 subranges) for unordered types. If this switch is used, then any
3927 enumeration type not marked with pragma `Ordered` will be considered
3928 as unordered, and will generate warnings for inappropriate uses.
3930 Note that generic types are not considered ordered or unordered (since the
3931 template can be instantiated for both cases), so we never generate warnings
3932 for the case of generic enumerated types.
3934 For additional information please refer to the description of the
3935 *-gnatw.u* switch in the GNAT User's Guide.
3937 Pragma Overflow_Mode
3938 ====================
3940 Syntax:
3945   pragma Overflow_Mode
3946    (  [General    =>] MODE
3947     [,[Assertions =>] MODE]);
3949   MODE ::= STRICT | MINIMIZED | ELIMINATED
3952 This pragma sets the current overflow mode to the given setting. For details
3953 of the meaning of these modes, please refer to the
3954 'Overflow Check Handling in GNAT' appendix in the
3955 GNAT User's Guide. If only the `General` parameter is present,
3956 the given mode applies to all expressions. If both parameters are present,
3957 the `General` mode applies to expressions outside assertions, and
3958 the `Eliminated` mode applies to expressions within assertions.
3960 The case of the `MODE` parameter is ignored,
3961 so `MINIMIZED`, `Minimized` and
3962 `minimized` all have the same effect.
3964 The `Overflow_Mode` pragma has the same scoping and placement
3965 rules as pragma `Suppress`, so it can occur either as a
3966 configuration pragma, specifying a default for the whole
3967 program, or in a declarative scope, where it applies to the
3968 remaining declarations and statements in that scope.
3970 The pragma `Suppress (Overflow_Check)` suppresses
3971 overflow checking, but does not affect the overflow mode.
3973 The pragma `Unsuppress (Overflow_Check)` unsuppresses (enables)
3974 overflow checking, but does not affect the overflow mode.
3976 Pragma Overriding_Renamings
3977 ===========================
3978 .. index:: Rational profile
3980 .. index:: Rational compatibility
3982 Syntax:
3985 .. code-block:: ada
3987   pragma Overriding_Renamings;
3990 This is a GNAT configuration pragma to simplify porting
3991 legacy code accepted by the Rational
3992 Ada compiler. In the presence of this pragma, a renaming declaration that
3993 renames an inherited operation declared in the same scope is legal if selected
3994 notation is used as in:
3997 .. code-block:: ada
3999   pragma Overriding_Renamings;
4000   ...
4001   package R is
4002     function F (..);
4003     ...
4004     function F (..) renames R.F;
4005   end R;
4008 even though
4009 RM 8.3 (15) stipulates that an overridden operation is not visible within the
4010 declaration of the overriding operation.
4012 Pragma Partition_Elaboration_Policy
4013 ===================================
4015 Syntax:
4020   pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4022   POLICY_IDENTIFIER ::= Concurrent | Sequential
4025 This pragma is standard in Ada 2005, but is available in all earlier
4026 versions of Ada as an implementation-defined pragma.
4027 See Ada 2012 Reference Manual for details.
4029 Pragma Part_Of
4030 ==============
4032 For the description of this pragma, see SPARK 2014 Reference Manual,
4033 section 7.2.6.
4035 Pragma Passive
4036 ==============
4038 Syntax:
4043   pragma Passive [(Semaphore | No)];
4046 Syntax checked, but otherwise ignored by GNAT.  This is recognized for
4047 compatibility with DEC Ada 83 implementations, where it is used within a
4048 task definition to request that a task be made passive.  If the argument
4049 `Semaphore` is present, or the argument is omitted, then DEC Ada 83
4050 treats the pragma as an assertion that the containing task is passive
4051 and that optimization of context switch with this task is permitted and
4052 desired.  If the argument `No` is present, the task must not be
4053 optimized.  GNAT does not attempt to optimize any tasks in this manner
4054 (since protected objects are available in place of passive tasks).
4056 For more information on the subject of passive tasks, see the section
4057 'Passive Task Optimization' in the GNAT Users Guide.
4059 Pragma Persistent_BSS
4060 =====================
4062 Syntax:
4067   pragma Persistent_BSS [(LOCAL_NAME)]
4070 This pragma allows selected objects to be placed in the `.persistent_bss`
4071 section. On some targets the linker and loader provide for special
4072 treatment of this section, allowing a program to be reloaded without
4073 affecting the contents of this data (hence the name persistent).
4075 There are two forms of usage. If an argument is given, it must be the
4076 local name of a library level object, with no explicit initialization
4077 and whose type is potentially persistent. If no argument is given, then
4078 the pragma is a configuration pragma, and applies to all library level
4079 objects with no explicit initialization of potentially persistent types.
4081 A potentially persistent type is a scalar type, or an untagged,
4082 non-discriminated record, all of whose components have no explicit
4083 initialization and are themselves of a potentially persistent type,
4084 or an array, all of whose constraints are static, and whose component
4085 type is potentially persistent.
4087 If this pragma is used on a target where this feature is not supported,
4088 then the pragma will be ignored. See also `pragma Linker_Section`.
4090 Pragma Polling
4091 ==============
4093 Syntax:
4096 .. code-block:: ada
4098   pragma Polling (ON | OFF);
4101 This pragma controls the generation of polling code.  This is normally off.
4102 If `pragma Polling (ON)` is used then periodic calls are generated to
4103 the routine `Ada.Exceptions.Poll`.  This routine is a separate unit in the
4104 runtime library, and can be found in file :file:`a-excpol.adb`.
4106 Pragma `Polling` can appear as a configuration pragma (for example it
4107 can be placed in the :file:`gnat.adc` file) to enable polling globally, or it
4108 can be used in the statement or declaration sequence to control polling
4109 more locally.
4111 A call to the polling routine is generated at the start of every loop and
4112 at the start of every subprogram call.  This guarantees that the `Poll`
4113 routine is called frequently, and places an upper bound (determined by
4114 the complexity of the code) on the period between two `Poll` calls.
4116 The primary purpose of the polling interface is to enable asynchronous
4117 aborts on targets that cannot otherwise support it (for example Windows
4118 NT), but it may be used for any other purpose requiring periodic polling.
4119 The standard version is null, and can be replaced by a user program.  This
4120 will require re-compilation of the `Ada.Exceptions` package that can
4121 be found in files :file:`a-except.ads` and :file:`a-except.adb`.
4123 A standard alternative unit (in file :file:`4wexcpol.adb` in the standard GNAT
4124 distribution) is used to enable the asynchronous abort capability on
4125 targets that do not normally support the capability.  The version of
4126 `Poll` in this file makes a call to the appropriate runtime routine
4127 to test for an abort condition.
4129 Note that polling can also be enabled by use of the *-gnatP* switch.
4130 See the section on switches for gcc in the :title:`GNAT User's Guide`.
4132 Pragma Post
4133 ===========
4134 .. index:: Post
4136 .. index:: Checks, postconditions
4139 Syntax:
4142 .. code-block:: ada
4144   pragma Post (Boolean_Expression);
4147 The `Post` pragma is intended to be an exact replacement for
4148 the language-defined
4149 `Post` aspect, and shares its restrictions and semantics.
4150 It must appear either immediately following the corresponding
4151 subprogram declaration (only other pragmas may intervene), or
4152 if there is no separate subprogram declaration, then it can
4153 appear at the start of the declarations in a subprogram body
4154 (preceded only by other pragmas).
4156 Pragma Postcondition
4157 ====================
4158 .. index:: Postcondition
4160 .. index:: Checks, postconditions
4163 Syntax:
4168   pragma Postcondition (
4169      [Check   =>] Boolean_Expression
4170    [,[Message =>] String_Expression]);
4173 The `Postcondition` pragma allows specification of automatic
4174 postcondition checks for subprograms. These checks are similar to
4175 assertions, but are automatically inserted just prior to the return
4176 statements of the subprogram with which they are associated (including
4177 implicit returns at the end of procedure bodies and associated
4178 exception handlers).
4180 In addition, the boolean expression which is the condition which
4181 must be true may contain references to function'Result in the case
4182 of a function to refer to the returned value.
4184 `Postcondition` pragmas may appear either immediately following the
4185 (separate) declaration of a subprogram, or at the start of the
4186 declarations of a subprogram body. Only other pragmas may intervene
4187 (that is appear between the subprogram declaration and its
4188 postconditions, or appear before the postcondition in the
4189 declaration sequence in a subprogram body). In the case of a
4190 postcondition appearing after a subprogram declaration, the
4191 formal arguments of the subprogram are visible, and can be
4192 referenced in the postcondition expressions.
4194 The postconditions are collected and automatically tested just
4195 before any return (implicit or explicit) in the subprogram body.
4196 A postcondition is only recognized if postconditions are active
4197 at the time the pragma is encountered. The compiler switch *gnata*
4198 turns on all postconditions by default, and pragma `Check_Policy`
4199 with an identifier of `Postcondition` can also be used to
4200 control whether postconditions are active.
4202 The general approach is that postconditions are placed in the spec
4203 if they represent functional aspects which make sense to the client.
4204 For example we might have:
4207 .. code-block:: ada
4209      function Direction return Integer;
4210      pragma Postcondition
4211       (Direction'Result = +1
4212          or else
4213        Direction'Result = -1);
4216 which serves to document that the result must be +1 or -1, and
4217 will test that this is the case at run time if postcondition
4218 checking is active.
4220 Postconditions within the subprogram body can be used to
4221 check that some internal aspect of the implementation,
4222 not visible to the client, is operating as expected.
4223 For instance if a square root routine keeps an internal
4224 counter of the number of times it is called, then we
4225 might have the following postcondition:
4228 .. code-block:: ada
4230      Sqrt_Calls : Natural := 0;
4232      function Sqrt (Arg : Float) return Float is
4233        pragma Postcondition
4234          (Sqrt_Calls = Sqrt_Calls'Old + 1);
4235        ...
4236      end Sqrt
4239 As this example, shows, the use of the `Old` attribute
4240 is often useful in postconditions to refer to the state on
4241 entry to the subprogram.
4243 Note that postconditions are only checked on normal returns
4244 from the subprogram. If an abnormal return results from
4245 raising an exception, then the postconditions are not checked.
4247 If a postcondition fails, then the exception
4248 `System.Assertions.Assert_Failure` is raised. If
4249 a message argument was supplied, then the given string
4250 will be used as the exception message. If no message
4251 argument was supplied, then the default message has
4252 the form "Postcondition failed at file_name:line". The
4253 exception is raised in the context of the subprogram
4254 body, so it is possible to catch postcondition failures
4255 within the subprogram body itself.
4257 Within a package spec, normal visibility rules
4258 in Ada would prevent forward references within a
4259 postcondition pragma to functions defined later in
4260 the same package. This would introduce undesirable
4261 ordering constraints. To avoid this problem, all
4262 postcondition pragmas are analyzed at the end of
4263 the package spec, allowing forward references.
4265 The following example shows that this even allows
4266 mutually recursive postconditions as in:
4269 .. code-block:: ada
4271   package Parity_Functions is
4272      function Odd  (X : Natural) return Boolean;
4273      pragma Postcondition
4274        (Odd'Result =
4275           (x = 1
4276             or else
4277           (x /= 0 and then Even (X - 1))));
4279      function Even (X : Natural) return Boolean;
4280      pragma Postcondition
4281        (Even'Result =
4282           (x = 0
4283             or else
4284           (x /= 1 and then Odd (X - 1))));
4286   end Parity_Functions;
4289 There are no restrictions on the complexity or form of
4290 conditions used within `Postcondition` pragmas.
4291 The following example shows that it is even possible
4292 to verify performance behavior.
4295 .. code-block:: ada
4297   package Sort is
4299      Performance : constant Float;
4300      --  Performance constant set by implementation
4301      --  to match target architecture behavior.
4303      procedure Treesort (Arg : String);
4304      --  Sorts characters of argument using N*logN sort
4305      pragma Postcondition
4306        (Float (Clock - Clock'Old) <=
4307           Float (Arg'Length) *
4308           log (Float (Arg'Length)) *
4309           Performance);
4310   end Sort;
4313 Note: postcondition pragmas associated with subprograms that are
4314 marked as Inline_Always, or those marked as Inline with front-end
4315 inlining (-gnatN option set) are accepted and legality-checked
4316 by the compiler, but are ignored at run-time even if postcondition
4317 checking is enabled.
4319 Note that pragma `Postcondition` differs from the language-defined
4320 `Post` aspect (and corresponding `Post` pragma) in allowing
4321 multiple occurrences, allowing occurences in the body even if there
4322 is a separate spec, and allowing a second string parameter, and the
4323 use of the pragma identifier `Check`. Historically, pragma
4324 `Postcondition` was implemented prior to the development of
4325 Ada 2012, and has been retained in its original form for
4326 compatibility purposes.
4328 Pragma Post_Class
4329 =================
4330 .. index:: Post
4332 .. index:: Checks, postconditions
4335 Syntax:
4338 .. code-block:: ada
4340   pragma Post_Class (Boolean_Expression);
4343 The `Post_Class` pragma is intended to be an exact replacement for
4344 the language-defined
4345 `Post'Class` aspect, and shares its restrictions and semantics.
4346 It must appear either immediately following the corresponding
4347 subprogram declaration (only other pragmas may intervene), or
4348 if there is no separate subprogram declaration, then it can
4349 appear at the start of the declarations in a subprogram body
4350 (preceded only by other pragmas).
4352 Note: This pragma is called `Post_Class` rather than
4353 `Post'Class` because the latter would not be strictly
4354 conforming to the allowed syntax for pragmas. The motivation
4355 for provinding pragmas equivalent to the aspects is to allow a program
4356 to be written using the pragmas, and then compiled if necessary
4357 using an Ada compiler that does not recognize the pragmas or
4358 aspects, but is prepared to ignore the pragmas. The assertion
4359 policy that controls this pragma is `Post'Class`, not
4360 `Post_Class`.
4362 Pragma Pre
4363 ==========
4364 .. index:: Pre
4366 .. index:: Checks, preconditions
4369 Syntax:
4372 .. code-block:: ada
4374   pragma Pre (Boolean_Expression);
4377 The `Pre` pragma is intended to be an exact replacement for
4378 the language-defined
4379 `Pre` aspect, and shares its restrictions and semantics.
4380 It must appear either immediately following the corresponding
4381 subprogram declaration (only other pragmas may intervene), or
4382 if there is no separate subprogram declaration, then it can
4383 appear at the start of the declarations in a subprogram body
4384 (preceded only by other pragmas).
4386 Pragma Precondition
4387 ===================
4388 .. index:: Preconditions
4390 .. index:: Checks, preconditions
4393 Syntax:
4398   pragma Precondition (
4399      [Check   =>] Boolean_Expression
4400    [,[Message =>] String_Expression]);
4403 The `Precondition` pragma is similar to `Postcondition`
4404 except that the corresponding checks take place immediately upon
4405 entry to the subprogram, and if a precondition fails, the exception
4406 is raised in the context of the caller, and the attribute 'Result
4407 cannot be used within the precondition expression.
4409 Otherwise, the placement and visibility rules are identical to those
4410 described for postconditions. The following is an example of use
4411 within a package spec:
4414 .. code-block:: ada
4416   package Math_Functions is
4417      ...
4418      function Sqrt (Arg : Float) return Float;
4419      pragma Precondition (Arg >= 0.0)
4420      ...
4421   end Math_Functions;
4424 `Precondition` pragmas may appear either immediately following the
4425 (separate) declaration of a subprogram, or at the start of the
4426 declarations of a subprogram body. Only other pragmas may intervene
4427 (that is appear between the subprogram declaration and its
4428 postconditions, or appear before the postcondition in the
4429 declaration sequence in a subprogram body).
4431 Note: precondition pragmas associated with subprograms that are
4432 marked as Inline_Always, or those marked as Inline with front-end
4433 inlining (-gnatN option set) are accepted and legality-checked
4434 by the compiler, but are ignored at run-time even if precondition
4435 checking is enabled.
4437 Note that pragma `Precondition` differs from the language-defined
4438 `Pre` aspect (and corresponding `Pre` pragma) in allowing
4439 multiple occurrences, allowing occurences in the body even if there
4440 is a separate spec, and allowing a second string parameter, and the
4441 use of the pragma identifier `Check`. Historically, pragma
4442 `Precondition` was implemented prior to the development of
4443 Ada 2012, and has been retained in its original form for
4444 compatibility purposes.
4446 Pragma Predicate
4447 ================
4449 Syntax:
4454   pragma Predicate
4455     ([Entity =>] type_LOCAL_NAME,
4456      [Check  =>] EXPRESSION);
4459 This pragma (available in all versions of Ada in GNAT) encompasses both
4460 the `Static_Predicate` and `Dynamic_Predicate` aspects in
4461 Ada 2012. A predicate is regarded as static if it has an allowed form
4462 for `Static_Predicate` and is otherwise treated as a
4463 `Dynamic_Predicate`. Otherwise, predicates specified by this
4464 pragma behave exactly as described in the Ada 2012 reference manual.
4465 For example, if we have
4468 .. code-block:: ada
4470   type R is range 1 .. 10;
4471   subtype S is R;
4472   pragma Predicate (Entity => S, Check => S not in 4 .. 6);
4473   subtype Q is R
4474   pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
4477 the effect is identical to the following Ada 2012 code:
4480 .. code-block:: ada
4482   type R is range 1 .. 10;
4483   subtype S is R with
4484     Static_Predicate => S not in 4 .. 6;
4485   subtype Q is R with
4486     Dynamic_Predicate => F(Q) or G(Q);
4489 Note that there is are no pragmas `Dynamic_Predicate`
4490 or `Static_Predicate`. That is
4491 because these pragmas would affect legality and semantics of
4492 the program and thus do not have a neutral effect if ignored.
4493 The motivation behind providing pragmas equivalent to
4494 corresponding aspects is to allow a program to be written
4495 using the pragmas, and then compiled with a compiler that
4496 will ignore the pragmas. That doesn't work in the case of
4497 static and dynamic predicates, since if the corresponding
4498 pragmas are ignored, then the behavior of the program is
4499 fundamentally changed (for example a membership test
4500 `A in B` would not take into account a predicate
4501 defined for subtype B). When following this approach, the
4502 use of predicates should be avoided.
4504 Pragma Preelaborable_Initialization
4505 ===================================
4507 Syntax:
4510 .. code-block:: ada
4512   pragma Preelaborable_Initialization (DIRECT_NAME);
4515 This pragma is standard in Ada 2005, but is available in all earlier
4516 versions of Ada as an implementation-defined pragma.
4517 See Ada 2012 Reference Manual for details.
4519 Pragma Prefix_Exception_Messages
4520 ================================
4521 .. index:: Prefix_Exception_Messages
4523 .. index:: exception
4525 .. index:: Exception_Message
4528 Syntax:
4531 .. code-block:: ada
4533   pragma Prefix_Exception_Messages;
4536 This is an implementation-defined configuration pragma that affects the
4537 behavior of raise statements with a message given as a static string
4538 constant (typically a string literal). In such cases, the string will
4539 be automatically prefixed by the name of the enclosing entity (giving
4540 the package and subprogram containing the raise statement). This helps
4541 to identify where messages are coming from, and this mode is automatic
4542 for the run-time library.
4544 The pragma has no effect if the message is computed with an expression other
4545 than a static string constant, since the assumption in this case is that
4546 the program computes exactly the string it wants. If you still want the
4547 prefixing in this case, you can always call
4548 `GNAT.Source_Info.Enclosing_Entity` and prepend the string manually.
4550 Pragma Pre_Class
4551 ================
4552 .. index:: Pre_Class
4554 .. index:: Checks, preconditions
4557 Syntax:
4560 .. code-block:: ada
4562   pragma Pre_Class (Boolean_Expression);
4565 The `Pre_Class` pragma is intended to be an exact replacement for
4566 the language-defined
4567 `Pre'Class` aspect, and shares its restrictions and semantics.
4568 It must appear either immediately following the corresponding
4569 subprogram declaration (only other pragmas may intervene), or
4570 if there is no separate subprogram declaration, then it can
4571 appear at the start of the declarations in a subprogram body
4572 (preceded only by other pragmas).
4574 Note: This pragma is called `Pre_Class` rather than
4575 `Pre'Class` because the latter would not be strictly
4576 conforming to the allowed syntax for pragmas. The motivation
4577 for providing pragmas equivalent to the aspects is to allow a program
4578 to be written using the pragmas, and then compiled if necessary
4579 using an Ada compiler that does not recognize the pragmas or
4580 aspects, but is prepared to ignore the pragmas. The assertion
4581 policy that controls this pragma is `Pre'Class`, not
4582 `Pre_Class`.
4584 Pragma Priority_Specific_Dispatching
4585 ====================================
4587 Syntax:
4592   pragma Priority_Specific_Dispatching (
4593      POLICY_IDENTIFIER,
4594      first_priority_EXPRESSION,
4595      last_priority_EXPRESSION)
4597   POLICY_IDENTIFIER ::=
4598      EDF_Across_Priorities            |
4599      FIFO_Within_Priorities           |
4600      Non_Preemptive_Within_Priorities |
4601      Round_Robin_Within_Priorities
4604 This pragma is standard in Ada 2005, but is available in all earlier
4605 versions of Ada as an implementation-defined pragma.
4606 See Ada 2012 Reference Manual for details.
4608 Pragma Profile
4609 ==============
4611 Syntax:
4614 .. code-block:: ada
4616   pragma Profile (Ravenscar | Restricted | Rational);
4619 This pragma is standard in Ada 2005, but is available in all earlier
4620 versions of Ada as an implementation-defined pragma. This is a
4621 configuration pragma that establishes a set of configuration pragmas
4622 that depend on the argument. `Ravenscar` is standard in Ada 2005.
4623 The other two possibilities (`Restricted` or `Rational`)
4624 are implementation-defined. The set of configuration pragmas
4625 is defined in the following sections.
4628 * Pragma Profile (Ravenscar)
4630   The `Ravenscar` profile is standard in Ada 2005,
4631   but is available in all earlier
4632   versions of Ada as an implementation-defined pragma. This profile
4633   establishes the following set of configuration pragmas:
4635   * ``Task_Dispatching_Policy (FIFO_Within_Priorities)``
4637     [RM D.2.2] Tasks are dispatched following a preemptive
4638     priority-ordered scheduling policy.
4641   * ``Locking_Policy (Ceiling_Locking)``
4643     [RM D.3] While tasks and interrupts execute a protected action, they inherit
4644     the ceiling priority of the corresponding protected object.
4647   * ``Detect_Blocking``
4649     This pragma forces the detection of potentially blocking operations within a
4650     protected operation, and to raise Program_Error if that happens.
4652   plus the following set of restrictions:
4654   * ``Max_Entry_Queue_Length => 1``
4656     No task can be queued on a protected entry.
4658   * ``Max_Protected_Entries => 1``
4660   * ``Max_Task_Entries => 0``
4662     No rendezvous statements are allowed.
4664   * ``No_Abort_Statements``
4666   * ``No_Dynamic_Attachment``
4668   * ``No_Dynamic_Priorities``
4670   * ``No_Implicit_Heap_Allocations``
4672   * ``No_Local_Protected_Objects``
4674   * ``No_Local_Timing_Events``
4676   * ``No_Protected_Type_Allocators``
4678   * ``No_Relative_Delay``
4680   * ``No_Requeue_Statements``
4682   * ``No_Select_Statements``
4684   * ``No_Specific_Termination_Handlers``
4686   * ``No_Task_Allocators``
4688   * ``No_Task_Hierarchy``
4690   * ``No_Task_Termination``
4692   * ``Simple_Barriers``
4694   The Ravenscar profile also includes the following restrictions that specify
4695   that there are no semantic dependences on the corresponding predefined
4696   packages:
4698   * ``No_Dependence => Ada.Asynchronous_Task_Control``
4700   * ``No_Dependence => Ada.Calendar``
4702   * ``No_Dependence => Ada.Execution_Time.Group_Budget``
4704   * ``No_Dependence => Ada.Execution_Time.Timers``
4706   * ``No_Dependence => Ada.Task_Attributes``
4708   * ``No_Dependence => System.Multiprocessors.Dispatching_Domains``
4710   This set of configuration pragmas and restrictions correspond to the
4711   definition of the 'Ravenscar Profile' for limited tasking, devised and
4712   published by the :title:`International Real-Time Ada Workshop, 1997`.
4713   A description is also available at
4714   `http://www-users.cs.york.ac.uk/~burns/ravenscar.ps <http://www-users.cs.york.ac.uk/~burns/ravenscar.ps>`_.
4716   The original definition of the profile was revised at subsequent IRTAW
4717   meetings. It has been included in the ISO
4718   :title:`Guide for the Use of the Ada Programming Language in High Integrity Systems`,
4719   and was made part of the Ada 2005 standard.
4720   The formal definition given by
4721   the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4722   AI-305) available at
4723   `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
4724   `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>`_.
4726   The above set is a superset of the restrictions provided by pragma
4727   ``Profile (Restricted)``, it includes six additional restrictions
4728   (``Simple_Barriers``, ``No_Select_Statements``,
4729   ``No_Calendar``, ``No_Implicit_Heap_Allocations``,
4730   ``No_Relative_Delay`` and ``No_Task_Termination``).  This means
4731   that pragma ``Profile (Ravenscar)``, like the pragma
4732   ``Profile (Restricted)``,
4733   automatically causes the use of a simplified,
4734   more efficient version of the tasking run-time library.
4736 * Pragma Profile (Restricted)
4738   This profile corresponds to the GNAT restricted run time. It
4739   establishes the following set of restrictions:
4741   * ``No_Abort_Statements``
4742   * ``No_Entry_Queue``
4743   * ``No_Task_Hierarchy``
4744   * ``No_Task_Allocators``
4745   * ``No_Dynamic_Priorities``
4746   * ``No_Terminate_Alternatives``
4747   * ``No_Dynamic_Attachment``
4748   * ``No_Protected_Type_Allocators``
4749   * ``No_Local_Protected_Objects``
4750   * ``No_Requeue_Statements``
4751   * ``No_Task_Attributes_Package``
4752   * ``Max_Asynchronous_Select_Nesting =  0``
4753   * ``Max_Task_Entries =  0``
4754   * ``Max_Protected_Entries = 1``
4755   * ``Max_Select_Alternatives = 0``
4757   This set of restrictions causes the automatic selection of a simplified
4758   version of the run time that provides improved performance for the
4759   limited set of tasking functionality permitted by this set of restrictions.
4761 * Pragma Profile (Rational)
4763   The Rational profile is intended to facilitate porting legacy code that
4764   compiles with the Rational APEX compiler, even when the code includes non-
4765   conforming Ada constructs.  The profile enables the following three pragmas:
4767   * ``pragma Implicit_Packing``
4768   * ``pragma Overriding_Renamings``
4769   * ``pragma Use_VADS_Size``
4772 Pragma Profile_Warnings
4773 =======================
4775 Syntax:
4778 .. code-block:: ada
4780   pragma Profile_Warnings (Ravenscar | Restricted | Rational);
4783 This is an implementation-defined pragma that is similar in
4784 effect to `pragma Profile` except that instead of
4785 generating `Restrictions` pragmas, it generates
4786 `Restriction_Warnings` pragmas. The result is that
4787 violations of the profile generate warning messages instead
4788 of error messages.
4790 Pragma Propagate_Exceptions
4791 ===========================
4792 .. index:: Interfacing to C++
4795 Syntax:
4798 .. code-block:: ada
4800   pragma Propagate_Exceptions;
4803 This pragma is now obsolete and, other than generating a warning if warnings
4804 on obsolescent features are enabled, is ignored.
4805 It is retained for compatibility
4806 purposes. It used to be used in connection with optimization of
4807 a now-obsolete mechanism for implementation of exceptions.
4809 Pragma Provide_Shift_Operators
4810 ==============================
4811 .. index:: Shift operators
4814 Syntax:
4817 .. code-block:: ada
4819   pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
4822 This pragma can be applied to a first subtype local name that specifies
4823 either an unsigned or signed type. It has the effect of providing the
4824 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
4825 Rotate_Left and Rotate_Right) for the given type. It is similar to
4826 including the function declarations for these five operators, together
4827 with the pragma Import (Intrinsic, ...) statements.
4829 Pragma Psect_Object
4830 ===================
4832 Syntax:
4837   pragma Psect_Object (
4838        [Internal =>] LOCAL_NAME,
4839     [, [External =>] EXTERNAL_SYMBOL]
4840     [, [Size     =>] EXTERNAL_SYMBOL]);
4842   EXTERNAL_SYMBOL ::=
4843     IDENTIFIER
4844   | static_string_EXPRESSION
4847 This pragma is identical in effect to pragma `Common_Object`.
4849 Pragma Pure_Function
4850 ====================
4852 Syntax:
4857   pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4860 This pragma appears in the same declarative part as a function
4861 declaration (or a set of function declarations if more than one
4862 overloaded declaration exists, in which case the pragma applies
4863 to all entities).  It specifies that the function `Entity` is
4864 to be considered pure for the purposes of code generation.  This means
4865 that the compiler can assume that there are no side effects, and
4866 in particular that two calls with identical arguments produce the
4867 same result.  It also means that the function can be used in an
4868 address clause.
4870 Note that, quite deliberately, there are no static checks to try
4871 to ensure that this promise is met, so `Pure_Function` can be used
4872 with functions that are conceptually pure, even if they do modify
4873 global variables.  For example, a square root function that is
4874 instrumented to count the number of times it is called is still
4875 conceptually pure, and can still be optimized, even though it
4876 modifies a global variable (the count).  Memo functions are another
4877 example (where a table of previous calls is kept and consulted to
4878 avoid re-computation).
4880 Note also that the normal rules excluding optimization of subprograms
4881 in pure units (when parameter types are descended from System.Address,
4882 or when the full view of a parameter type is limited), do not apply
4883 for the Pure_Function case. If you explicitly specify Pure_Function,
4884 the compiler may optimize away calls with identical arguments, and
4885 if that results in unexpected behavior, the proper action is not to
4886 use the pragma for subprograms that are not (conceptually) pure.
4888 Note: Most functions in a `Pure` package are automatically pure, and
4889 there is no need to use pragma `Pure_Function` for such functions.  One
4890 exception is any function that has at least one formal of type
4891 `System.Address` or a type derived from it.  Such functions are not
4892 considered pure by default, since the compiler assumes that the
4893 `Address` parameter may be functioning as a pointer and that the
4894 referenced data may change even if the address value does not.
4895 Similarly, imported functions are not considered to be pure by default,
4896 since there is no way of checking that they are in fact pure.  The use
4897 of pragma `Pure_Function` for such a function will override these default
4898 assumption, and cause the compiler to treat a designated subprogram as pure
4899 in these cases.
4901 Note: If pragma `Pure_Function` is applied to a renamed function, it
4902 applies to the underlying renamed function.  This can be used to
4903 disambiguate cases of overloading where some but not all functions
4904 in a set of overloaded functions are to be designated as pure.
4906 If pragma `Pure_Function` is applied to a library level function, the
4907 function is also considered pure from an optimization point of view, but the
4908 unit is not a Pure unit in the categorization sense. So for example, a function
4909 thus marked is free to `with` non-pure units.
4911 Pragma Rational
4912 ===============
4914 Syntax:
4917 .. code-block:: ada
4919   pragma Rational;
4922 This pragma is considered obsolescent, but is retained for
4923 compatibility purposes. It is equivalent to:
4926 .. code-block:: ada
4928   pragma Profile (Rational);
4931 Pragma Ravenscar
4932 ================
4934 Syntax:
4937 .. code-block:: ada
4939   pragma Ravenscar;
4942 This pragma is considered obsolescent, but is retained for
4943 compatibility purposes. It is equivalent to:
4946 .. code-block:: ada
4948   pragma Profile (Ravenscar);
4951 which is the preferred method of setting the `Ravenscar` profile.
4953 Pragma Refined_Depends
4954 ======================
4956 For the description of this pragma, see SPARK 2014 Reference Manual,
4957 section 6.1.5.
4959 Pragma Refined_Global
4960 =====================
4962 For the description of this pragma, see SPARK 2014 Reference Manual,
4963 section 6.1.4.
4965 Pragma Refined_Post
4966 ===================
4968 For the description of this pragma, see SPARK 2014 Reference Manual,
4969 section 7.2.7.
4971 Pragma Refined_State
4972 ====================
4974 For the description of this pragma, see SPARK 2014 Reference Manual,
4975 section 7.2.2.
4977 Pragma Relative_Deadline
4978 ========================
4980 Syntax:
4983 .. code-block:: ada
4985   pragma Relative_Deadline (time_span_EXPRESSION);
4988 This pragma is standard in Ada 2005, but is available in all earlier
4989 versions of Ada as an implementation-defined pragma.
4990 See Ada 2012 Reference Manual for details.
4992 Pragma Remote_Access_Type
4993 =========================
4995 Syntax:
5000   pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5003 This pragma appears in the formal part of a generic declaration.
5004 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5005 the use of a remote access to class-wide type as actual for a formal
5006 access type.
5008 When this pragma applies to a formal access type `Entity`, that
5009 type is treated as a remote access to class-wide type in the generic.
5010 It must be a formal general access type, and its designated type must
5011 be the class-wide type of a formal tagged limited private type from the
5012 same generic declaration.
5014 In the generic unit, the formal type is subject to all restrictions
5015 pertaining to remote access to class-wide types. At instantiation, the
5016 actual type must be a remote access to class-wide type.
5018 Pragma Restricted_Run_Time
5019 ==========================
5021 Syntax:
5024 .. code-block:: ada
5026   pragma Restricted_Run_Time;
5029 This pragma is considered obsolescent, but is retained for
5030 compatibility purposes. It is equivalent to:
5033 .. code-block:: ada
5035   pragma Profile (Restricted);
5038 which is the preferred method of setting the restricted run time
5039 profile.
5041 Pragma Restriction_Warnings
5042 ===========================
5044 Syntax:
5049   pragma Restriction_Warnings
5050     (restriction_IDENTIFIER {, restriction_IDENTIFIER});
5053 This pragma allows a series of restriction identifiers to be
5054 specified (the list of allowed identifiers is the same as for
5055 pragma `Restrictions`). For each of these identifiers
5056 the compiler checks for violations of the restriction, but
5057 generates a warning message rather than an error message
5058 if the restriction is violated.
5060 One use of this is in situations where you want to know
5061 about violations of a restriction, but you want to ignore some of
5062 these violations. Consider this example, where you want to set
5063 Ada_95 mode and enable style checks, but you want to know about
5064 any other use of implementation pragmas:
5067 .. code-block:: ada
5069   pragma Restriction_Warnings (No_Implementation_Pragmas);
5070   pragma Warnings (Off, "violation of No_Implementation_Pragmas");
5071   pragma Ada_95;
5072   pragma Style_Checks ("2bfhkM160");
5073   pragma Warnings (On, "violation of No_Implementation_Pragmas");
5076 By including the above lines in a configuration pragmas file,
5077 the Ada_95 and Style_Checks pragmas are accepted without
5078 generating a warning, but any other use of implementation
5079 defined pragmas will cause a warning to be generated.
5081 Pragma Reviewable
5082 =================
5084 Syntax:
5087 .. code-block:: ada
5089   pragma Reviewable;
5092 This pragma is an RM-defined standard pragma, but has no effect on the
5093 program being compiled, or on the code generated for the program.
5095 To obtain the required output specified in RM H.3.1, the compiler must be
5096 run with various special switches as follows:
5098 * *Where compiler-generated run-time checks remain*
5100   The switch *-gnatGL*
5101   may be used to list the expanded code in pseudo-Ada form.
5102   Runtime checks show up in the listing either as explicit
5103   checks or operators marked with {} to indicate a check is present.
5106 * *An identification of known exceptions at compile time*
5108   If the program is compiled with *-gnatwa*,
5109   the compiler warning messages will indicate all cases where the compiler
5110   detects that an exception is certain to occur at run time.
5113 * *Possible reads of uninitialized variables*
5115   The compiler warns of many such cases, but its output is incomplete.
5117 .. only:: PRO or GPL
5119   The CodePeer analysis tool
5120   may be used to obtain a comprehensive list of all
5121   possible points at which uninitialized data may be read.
5123 .. only:: FSF
5125   A supplemental static analysis tool
5126   may be used to obtain a comprehensive list of all
5127   possible points at which uninitialized data may be read.
5130 * *Where run-time support routines are implicitly invoked*
5132   In the output from *-gnatGL*,
5133   run-time calls are explicitly listed as calls to the relevant
5134   run-time routine.
5137 * *Object code listing*
5139   This may be obtained either by using the *-S* switch,
5140   or the objdump utility.
5143 * *Constructs known to be erroneous at compile time*
5145   These are identified by warnings issued by the compiler (use *-gnatwa*).
5148 * *Stack usage information*
5150   Static stack usage data (maximum per-subprogram) can be obtained via the
5151   *-fstack-usage* switch to the compiler.
5152   Dynamic stack usage data (per task) can be obtained via the *-u* switch
5153   to gnatbind
5155 .. only:: PRO or GPL
5157   The gnatstack utility
5158   can be used to provide additional information on stack usage.
5161 * *Object code listing of entire partition*
5163   This can be obtained by compiling the partition with *-S*,
5164   or by applying objdump
5165   to all the object files that are part of the partition.
5168 * *A description of the run-time model*
5170   The full sources of the run-time are available, and the documentation of
5171   these routines describes how these run-time routines interface to the
5172   underlying operating system facilities.
5175 * *Control and data-flow information*
5177 .. only:: PRO or GPL
5179   The CodePeer tool
5180   may be used to obtain complete control and data-flow information, as well as
5181   comprehensive messages identifying possible problems based on this
5182   information.
5184 .. only:: FSF
5186   A supplemental static analysis tool
5187   may be used to obtain complete control and data-flow information, as well as
5188   comprehensive messages identifying possible problems based on this
5189   information.
5192 Pragma Share_Generic
5193 ====================
5195 Syntax:
5200   pragma Share_Generic (GNAME {, GNAME});
5202   GNAME ::= generic_unit_NAME | generic_instance_NAME
5205 This pragma is provided for compatibility with Dec Ada 83. It has
5206 no effect in `GNAT` (which does not implement shared generics), other
5207 than to check that the given names are all names of generic units or
5208 generic instances.
5210 Pragma Shared
5211 =============
5213 This pragma is provided for compatibility with Ada 83. The syntax and
5214 semantics are identical to pragma Atomic.
5216 Pragma Short_Circuit_And_Or
5217 ===========================
5219 Syntax:
5222 .. code-block:: ada
5224   pragma Short_Circuit_And_Or;
5227 This configuration pragma causes any occurrence of the AND operator applied to
5228 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5229 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5230 may be useful in the context of certification protocols requiring the use of
5231 short-circuited logical operators. If this configuration pragma occurs locally
5232 within the file being compiled, it applies only to the file being compiled.
5233 There is no requirement that all units in a partition use this option.
5235 Pragma Short_Descriptors
5236 ========================
5238 Syntax:
5241 .. code-block:: ada
5243   pragma Short_Descriptors
5246 This pragma is provided for compatibility with other Ada implementations. It
5247 is recognized but ignored by all current versions of GNAT.
5249 Pragma Simple_Storage_Pool_Type
5250 ===============================
5251 .. index:: Storage pool, simple
5253 .. index:: Simple storage pool
5255 Syntax:
5258 .. code-block:: ada
5260   pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5263 A type can be established as a 'simple storage pool type' by applying
5264 the representation pragma `Simple_Storage_Pool_Type` to the type.
5265 A type named in the pragma must be a library-level immutably limited record
5266 type or limited tagged type declared immediately within a package declaration.
5267 The type can also be a limited private type whose full type is allowed as
5268 a simple storage pool type.
5270 For a simple storage pool type `SSP`, nonabstract primitive subprograms
5271 `Allocate`, `Deallocate`, and `Storage_Size` can be declared that
5272 are subtype conformant with the following subprogram declarations:
5275 .. code-block:: ada
5277   procedure Allocate
5278     (Pool                     : in out SSP;
5279      Storage_Address          : out System.Address;
5280      Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5281      Alignment                : System.Storage_Elements.Storage_Count);
5283   procedure Deallocate
5284     (Pool : in out SSP;
5285      Storage_Address          : System.Address;
5286      Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5287      Alignment                : System.Storage_Elements.Storage_Count);
5289   function Storage_Size (Pool : SSP)
5290     return System.Storage_Elements.Storage_Count;
5293 Procedure `Allocate` must be declared, whereas `Deallocate` and
5294 `Storage_Size` are optional. If `Deallocate` is not declared, then
5295 applying an unchecked deallocation has no effect other than to set its actual
5296 parameter to null. If `Storage_Size` is not declared, then the
5297 `Storage_Size` attribute applied to an access type associated with
5298 a pool object of type SSP returns zero. Additional operations can be declared
5299 for a simple storage pool type (such as for supporting a mark/release
5300 storage-management discipline).
5302 An object of a simple storage pool type can be associated with an access
5303 type by specifying the attribute
5304 :ref:`Simple_Storage_Pool <Attribute_Simple_Storage_Pool>`. For example:
5307 .. code-block:: ada
5309   My_Pool : My_Simple_Storage_Pool_Type;
5311   type Acc is access My_Data_Type;
5313   for Acc'Simple_Storage_Pool use My_Pool;
5317 See attribute :ref:`Simple_Storage_Pool <Attribute_Simple_Storage_Pool>`
5318 for further details.
5320 ..  _Pragma_Source_File_Name:
5322 Pragma Source_File_Name
5323 =======================
5325 Syntax:
5330   pragma Source_File_Name (
5331     [Unit_Name   =>] unit_NAME,
5332     Spec_File_Name =>  STRING_LITERAL,
5333     [Index => INTEGER_LITERAL]);
5335   pragma Source_File_Name (
5336     [Unit_Name   =>] unit_NAME,
5337     Body_File_Name =>  STRING_LITERAL,
5338     [Index => INTEGER_LITERAL]);
5341 Use this to override the normal naming convention.  It is a configuration
5342 pragma, and so has the usual applicability of configuration pragmas
5343 (i.e., it applies to either an entire partition, or to all units in a
5344 compilation, or to a single unit, depending on how it is used.
5345 `unit_name` is mapped to `file_name_literal`.  The identifier for
5346 the second argument is required, and indicates whether this is the file
5347 name for the spec or for the body.
5349 The optional Index argument should be used when a file contains multiple
5350 units, and when you do not want to use `gnatchop` to separate then
5351 into multiple files (which is the recommended procedure to limit the
5352 number of recompilations that are needed when some sources change).
5353 For instance, if the source file :file:`source.ada` contains
5356 .. code-block:: ada
5358   package B is
5359   ...
5360   end B;
5362   with B;
5363   procedure A is
5364   begin
5365      ..
5366   end A;
5369 you could use the following configuration pragmas:
5372 .. code-block:: ada
5374   pragma Source_File_Name
5375     (B, Spec_File_Name => "source.ada", Index => 1);
5376   pragma Source_File_Name
5377     (A, Body_File_Name => "source.ada", Index => 2);
5380 Note that the `gnatname` utility can also be used to generate those
5381 configuration pragmas.
5383 Another form of the `Source_File_Name` pragma allows
5384 the specification of patterns defining alternative file naming schemes
5385 to apply to all files.
5390   pragma Source_File_Name
5391     (  [Spec_File_Name  =>] STRING_LITERAL
5392      [,[Casing          =>] CASING_SPEC]
5393      [,[Dot_Replacement =>] STRING_LITERAL]);
5395   pragma Source_File_Name
5396     (  [Body_File_Name  =>] STRING_LITERAL
5397      [,[Casing          =>] CASING_SPEC]
5398      [,[Dot_Replacement =>] STRING_LITERAL]);
5400   pragma Source_File_Name
5401     (  [Subunit_File_Name =>] STRING_LITERAL
5402      [,[Casing            =>] CASING_SPEC]
5403      [,[Dot_Replacement   =>] STRING_LITERAL]);
5405   CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
5408 The first argument is a pattern that contains a single asterisk indicating
5409 the point at which the unit name is to be inserted in the pattern string
5410 to form the file name.  The second argument is optional.  If present it
5411 specifies the casing of the unit name in the resulting file name string.
5412 The default is lower case.  Finally the third argument allows for systematic
5413 replacement of any dots in the unit name by the specified string literal.
5415 Note that Source_File_Name pragmas should not be used if you are using
5416 project files. The reason for this rule is that the project manager is not
5417 aware of these pragmas, and so other tools that use the projet file would not
5418 be aware of the intended naming conventions. If you are using project files,
5419 file naming is controlled by Source_File_Name_Project pragmas, which are
5420 usually supplied automatically by the project manager. A pragma
5421 Source_File_Name cannot appear after a :ref:`Pragma_Source_File_Name_Project`.
5423 For more details on the use of the `Source_File_Name` pragma, see the
5424 sections on `Using Other File Names` and `Alternative File Naming Schemes'
5425 in the :title:`GNAT User's Guide`.
5427 ..  _Pragma_Source_File_Name_Project:
5429 Pragma Source_File_Name_Project
5430 ===============================
5432 This pragma has the same syntax and semantics as pragma Source_File_Name.
5433 It is only allowed as a stand alone configuration pragma.
5434 It cannot appear after a :ref:`Pragma_Source_File_Name`, and
5435 most importantly, once pragma Source_File_Name_Project appears,
5436 no further Source_File_Name pragmas are allowed.
5438 The intention is that Source_File_Name_Project pragmas are always
5439 generated by the Project Manager in a manner consistent with the naming
5440 specified in a project file, and when naming is controlled in this manner,
5441 it is not permissible to attempt to modify this naming scheme using
5442 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5443 known to the project manager).
5445 Pragma Source_Reference
5446 =======================
5448 Syntax:
5451 .. code-block:: ada
5453   pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5456 This pragma must appear as the first line of a source file.
5457 `integer_literal` is the logical line number of the line following
5458 the pragma line (for use in error messages and debugging
5459 information).  `string_literal` is a static string constant that
5460 specifies the file name to be used in error messages and debugging
5461 information.  This is most notably used for the output of `gnatchop`
5462 with the *-r* switch, to make sure that the original unchopped
5463 source file is the one referred to.
5465 The second argument must be a string literal, it cannot be a static
5466 string expression other than a string literal.  This is because its value
5467 is needed for error messages issued by all phases of the compiler.
5469 Pragma SPARK_Mode
5470 =================
5472 Syntax:
5477   pragma SPARK_Mode [(On | Off)] ;
5480 In general a program can have some parts that are in SPARK 2014 (and
5481 follow all the rules in the SPARK Reference Manual), and some parts
5482 that are full Ada 2012.
5484 The SPARK_Mode pragma is used to identify which parts are in SPARK
5485 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
5486 be used in the following places:
5490   As a configuration pragma, in which case it sets the default mode for
5491   all units compiled with this pragma.
5494   Immediately following a library-level subprogram spec
5497   Immediately within a library-level package body
5500   Immediately following the `private` keyword of a library-level
5501   package spec
5504   Immediately following the `begin` keyword of a library-level
5505   package body
5508   Immediately within a library-level subprogram body
5511 Normally a subprogram or package spec/body inherits the current mode
5512 that is active at the point it is declared. But this can be overridden
5513 by pragma within the spec or body as above.
5515 The basic consistency rule is that you can't turn SPARK_Mode back
5516 `On`, once you have explicitly (with a pragma) turned if
5517 `Off`. So the following rules apply:
5519 If a subprogram spec has SPARK_Mode `Off`, then the body must
5520 also have SPARK_Mode `Off`.
5522 For a package, we have four parts:
5525   the package public declarations
5527   the package private part
5529   the body of the package
5531   the elaboration code after `begin`
5533 For a package, the rule is that if you explicitly turn SPARK_Mode
5534 `Off` for any part, then all the following parts must have
5535 SPARK_Mode `Off`. Note that this may require repeating a pragma
5536 SPARK_Mode (`Off`) in the body. For example, if we have a
5537 configuration pragma SPARK_Mode (`On`) that turns the mode on by
5538 default everywhere, and one particular package spec has pragma
5539 SPARK_Mode (`Off`), then that pragma will need to be repeated in
5540 the package body.
5542 Pragma Static_Elaboration_Desired
5543 =================================
5545 Syntax:
5548 .. code-block:: ada
5550   pragma Static_Elaboration_Desired;
5553 This pragma is used to indicate that the compiler should attempt to initialize
5554 statically the objects declared in the library unit to which the pragma applies,
5555 when these objects are initialized (explicitly or implicitly) by an aggregate.
5556 In the absence of this pragma, aggregates in object declarations are expanded
5557 into assignments and loops, even when the aggregate components are static
5558 constants. When the aggregate is present the compiler builds a static expression
5559 that requires no run-time code, so that the initialized object can be placed in
5560 read-only data space. If the components are not static, or the aggregate has
5561 more that 100 components, the compiler emits a warning that the pragma cannot
5562 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
5563 construction of larger aggregates with static components that include an others
5564 choice.)
5566 Pragma Stream_Convert
5567 =====================
5569 Syntax:
5574   pragma Stream_Convert (
5575     [Entity =>] type_LOCAL_NAME,
5576     [Read   =>] function_NAME,
5577     [Write  =>] function_NAME);
5580 This pragma provides an efficient way of providing user-defined stream
5581 attributes.  Not only is it simpler to use than specifying the attributes
5582 directly, but more importantly, it allows the specification to be made in such
5583 a way that the predefined unit Ada.Streams is not loaded unless it is actually
5584 needed (i.e. unless the stream attributes are actually used); the use of
5585 the Stream_Convert pragma adds no overhead at all, unless the stream
5586 attributes are actually used on the designated type.
5588 The first argument specifies the type for which stream functions are
5589 provided.  The second parameter provides a function used to read values
5590 of this type.  It must name a function whose argument type may be any
5591 subtype, and whose returned type must be the type given as the first
5592 argument to the pragma.
5594 The meaning of the `Read` parameter is that if a stream attribute directly
5595 or indirectly specifies reading of the type given as the first parameter,
5596 then a value of the type given as the argument to the Read function is
5597 read from the stream, and then the Read function is used to convert this
5598 to the required target type.
5600 Similarly the `Write` parameter specifies how to treat write attributes
5601 that directly or indirectly apply to the type given as the first parameter.
5602 It must have an input parameter of the type specified by the first parameter,
5603 and the return type must be the same as the input type of the Read function.
5604 The effect is to first call the Write function to convert to the given stream
5605 type, and then write the result type to the stream.
5607 The Read and Write functions must not be overloaded subprograms.  If necessary
5608 renamings can be supplied to meet this requirement.
5609 The usage of this attribute is best illustrated by a simple example, taken
5610 from the GNAT implementation of package Ada.Strings.Unbounded:
5613 .. code-block:: ada
5615   function To_Unbounded (S : String) return Unbounded_String
5616     renames To_Unbounded_String;
5618   pragma Stream_Convert
5619     (Unbounded_String, To_Unbounded, To_String);
5622 The specifications of the referenced functions, as given in the Ada
5623 Reference Manual are:
5626 .. code-block:: ada
5628   function To_Unbounded_String (Source : String)
5629     return Unbounded_String;
5631   function To_String (Source : Unbounded_String)
5632     return String;
5635 The effect is that if the value of an unbounded string is written to a stream,
5636 then the representation of the item in the stream is in the same format that
5637 would be used for `Standard.String'Output`, and this same representation
5638 is expected when a value of this type is read from the stream. Note that the
5639 value written always includes the bounds, even for Unbounded_String'Write,
5640 since Unbounded_String is not an array type.
5642 Note that the `Stream_Convert` pragma is not effective in the case of
5643 a derived type of a non-limited tagged type. If such a type is specified then
5644 the pragma is silently ignored, and the default implementation of the stream
5645 attributes is used instead.
5647 Pragma Style_Checks
5648 ===================
5650 Syntax:
5655   pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5656                        On | Off [, LOCAL_NAME]);
5659 This pragma is used in conjunction with compiler switches to control the
5660 built in style checking provided by GNAT.  The compiler switches, if set,
5661 provide an initial setting for the switches, and this pragma may be used
5662 to modify these settings, or the settings may be provided entirely by
5663 the use of the pragma.  This pragma can be used anywhere that a pragma
5664 is legal, including use as a configuration pragma (including use in
5665 the :file:`gnat.adc` file).
5667 The form with a string literal specifies which style options are to be
5668 activated.  These are additive, so they apply in addition to any previously
5669 set style check options.  The codes for the options are the same as those
5670 used in the *-gnaty* switch to *gcc* or *gnatmake*.
5671 For example the following two methods can be used to enable
5672 layout checking:
5676   ::
5678     pragma Style_Checks ("l");
5683   ::
5685     gcc -c -gnatyl ...
5688 The form ALL_CHECKS activates all standard checks (its use is equivalent
5689 to the use of the `gnaty` switch with no options.
5690 See the :title:`GNAT User's Guide` for details.)
5692 Note: the behavior is slightly different in GNAT mode (*-gnatg* used).
5693 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5694 options (i.e. equivalent to *-gnatyg*).
5696 The forms with `Off` and `On`
5697 can be used to temporarily disable style checks
5698 as shown in the following example:
5701 .. code-block:: ada
5703   pragma Style_Checks ("k"); -- requires keywords in lower case
5704   pragma Style_Checks (Off); -- turn off style checks
5705   NULL;                      -- this will not generate an error message
5706   pragma Style_Checks (On);  -- turn style checks back on
5707   NULL;                      -- this will generate an error message
5710 Finally the two argument form is allowed only if the first argument is
5711 `On` or `Off`.  The effect is to turn of semantic style checks
5712 for the specified entity, as shown in the following example:
5715 .. code-block:: ada
5717   pragma Style_Checks ("r"); -- require consistency of identifier casing
5718   Arg : Integer;
5719   Rf1 : Integer := ARG;      -- incorrect, wrong case
5720   pragma Style_Checks (Off, Arg);
5721   Rf2 : Integer := ARG;      -- OK, no error
5724 Pragma Subtitle
5725 ===============
5727 Syntax:
5732   pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5735 This pragma is recognized for compatibility with other Ada compilers
5736 but is ignored by GNAT.
5738 Pragma Suppress
5739 ===============
5741 Syntax:
5746   pragma Suppress (Identifier [, [On =>] Name]);
5749 This is a standard pragma, and supports all the check names required in
5750 the RM. It is included here because GNAT recognizes some additional check
5751 names that are implementation defined (as permitted by the RM):
5755   `Alignment_Check` can be used to suppress alignment checks
5756   on addresses used in address clauses. Such checks can also be suppressed
5757   by suppressing range checks, but the specific use of `Alignment_Check`
5758   allows suppression of alignment checks without suppressing other range checks.
5759   Note that `Alignment_Check` is suppressed by default on machines (such as
5760   the x86) with non-strict alignment.
5763   `Atomic_Synchronization` can be used to suppress the special memory
5764   synchronization instructions that are normally generated for access to
5765   `Atomic` variables to ensure correct synchronization between tasks
5766   that use such variables for synchronization purposes.
5769   `Duplicated_Tag_Check` Can be used to suppress the check that is generated
5770   for a duplicated tag value when a tagged type is declared.
5773   `Predicate_Check` can be used to control whether predicate checks are
5774   active. It is applicable only to predicates for which the policy is
5775   `Check`. Unlike `Assertion_Policy`, which determines if a given
5776   predicate is ignored or checked for the whole program, the use of
5777   `Suppress` and `Unsuppress` with this check name allows a given
5778   predicate to be turned on and off at specific points in the program.
5781   `Validity_Check` can be used specifically to control validity checks.
5782   If `Suppress` is used to suppress validity checks, then no validity
5783   checks are performed, including those specified by the appropriate compiler
5784   switch or the `Validity_Checks` pragma.
5787   Additional check names previously introduced by use of the `Check_Name`
5788   pragma are also allowed.
5791 Note that pragma Suppress gives the compiler permission to omit
5792 checks, but does not require the compiler to omit checks. The compiler
5793 will generate checks if they are essentially free, even when they are
5794 suppressed. In particular, if the compiler can prove that a certain
5795 check will necessarily fail, it will generate code to do an
5796 unconditional 'raise', even if checks are suppressed. The compiler
5797 warns in this case.
5799 Of course, run-time checks are omitted whenever the compiler can prove
5800 that they will not fail, whether or not checks are suppressed.
5802 Pragma Suppress_All
5803 ===================
5805 Syntax:
5808 .. code-block:: ada
5810   pragma Suppress_All;
5813 This pragma can appear anywhere within a unit.
5814 The effect is to apply `Suppress (All_Checks)` to the unit
5815 in which it appears.  This pragma is implemented for compatibility with DEC
5816 Ada 83 usage where it appears at the end of a unit, and for compatibility
5817 with Rational Ada, where it appears as a program unit pragma.
5818 The use of the standard Ada pragma `Suppress (All_Checks)`
5819 as a normal configuration pragma is the preferred usage in GNAT.
5821 Pragma Suppress_Debug_Info
5822 ==========================
5824 Syntax:
5829   pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
5832 This pragma can be used to suppress generation of debug information
5833 for the specified entity. It is intended primarily for use in debugging
5834 the debugger, and navigating around debugger problems.
5836 Pragma Suppress_Exception_Locations
5837 ===================================
5839 Syntax:
5842 .. code-block:: ada
5844   pragma Suppress_Exception_Locations;
5847 In normal mode, a raise statement for an exception by default generates
5848 an exception message giving the file name and line number for the location
5849 of the raise. This is useful for debugging and logging purposes, but this
5850 entails extra space for the strings for the messages. The configuration
5851 pragma `Suppress_Exception_Locations` can be used to suppress the
5852 generation of these strings, with the result that space is saved, but the
5853 exception message for such raises is null. This configuration pragma may
5854 appear in a global configuration pragma file, or in a specific unit as
5855 usual. It is not required that this pragma be used consistently within
5856 a partition, so it is fine to have some units within a partition compiled
5857 with this pragma and others compiled in normal mode without it.
5859 Pragma Suppress_Initialization
5860 ==============================
5861 .. index:: Suppressing initialization
5863 .. index:: Initialization, suppression of
5865 Syntax:
5870   pragma Suppress_Initialization ([Entity =>] variable_or_subtype_Name);
5873 Here variable_or_subtype_Name is the name introduced by a type declaration
5874 or subtype declaration or the name of a variable introduced by an
5875 object declaration.
5877 In the case of a type or subtype
5878 this pragma suppresses any implicit or explicit initialization
5879 for all variables of the given type or subtype,
5880 including initialization resulting from the use of pragmas
5881 Normalize_Scalars or Initialize_Scalars.
5883 This is considered a representation item, so it cannot be given after
5884 the type is frozen. It applies to all subsequent object declarations,
5885 and also any allocator that creates objects of the type.
5887 If the pragma is given for the first subtype, then it is considered
5888 to apply to the base type and all its subtypes. If the pragma is given
5889 for other than a first subtype, then it applies only to the given subtype.
5890 The pragma may not be given after the type is frozen.
5892 Note that this includes eliminating initialization of discriminants
5893 for discriminated types, and tags for tagged types. In these cases,
5894 you will have to use some non-portable mechanism (e.g. address
5895 overlays or unchecked conversion) to achieve required initialization
5896 of these fields before accessing any object of the corresponding type.
5898 For the variable case, implicit initialization for the named variable
5899 is suppressed, just as though its subtype had been given in a pragma
5900 Suppress_Initialization, as described above.
5902 Pragma Task_Name
5903 ================
5905 Syntax
5908 .. code-block:: ada
5910   pragma Task_Name (string_EXPRESSION);
5913 This pragma appears within a task definition (like pragma
5914 `Priority`) and applies to the task in which it appears.  The
5915 argument must be of type String, and provides a name to be used for
5916 the task instance when the task is created.  Note that this expression
5917 is not required to be static, and in particular, it can contain
5918 references to task discriminants.  This facility can be used to
5919 provide different names for different tasks as they are created,
5920 as illustrated in the example below.
5922 The task name is recorded internally in the run-time structures
5923 and is accessible to tools like the debugger.  In addition the
5924 routine `Ada.Task_Identification.Image` will return this
5925 string, with a unique task address appended.
5928 .. code-block:: ada
5930   --  Example of the use of pragma Task_Name
5932   with Ada.Task_Identification;
5933   use Ada.Task_Identification;
5934   with Text_IO; use Text_IO;
5935   procedure t3 is
5937      type Astring is access String;
5939      task type Task_Typ (Name : access String) is
5940         pragma Task_Name (Name.all);
5941      end Task_Typ;
5943      task body Task_Typ is
5944         Nam : constant String := Image (Current_Task);
5945      begin
5946         Put_Line ("-->" & Nam (1 .. 14) & "<--");
5947      end Task_Typ;
5949      type Ptr_Task is access Task_Typ;
5950      Task_Var : Ptr_Task;
5952   begin
5953      Task_Var :=
5954        new Task_Typ (new String'("This is task 1"));
5955      Task_Var :=
5956        new Task_Typ (new String'("This is task 2"));
5957   end;
5960 Pragma Task_Storage
5961 ===================
5962 Syntax:
5967   pragma Task_Storage (
5968     [Task_Type =>] LOCAL_NAME,
5969     [Top_Guard =>] static_integer_EXPRESSION);
5972 This pragma specifies the length of the guard area for tasks.  The guard
5973 area is an additional storage area allocated to a task.  A value of zero
5974 means that either no guard area is created or a minimal guard area is
5975 created, depending on the target.  This pragma can appear anywhere a
5976 `Storage_Size` attribute definition clause is allowed for a task
5977 type.
5979 Pragma Test_Case
5980 ================
5981 .. index:: Test cases
5984 Syntax:
5989   pragma Test_Case (
5990      [Name     =>] static_string_Expression
5991     ,[Mode     =>] (Nominal | Robustness)
5992    [, Requires =>  Boolean_Expression]
5993    [, Ensures  =>  Boolean_Expression]);
5996 The `Test_Case` pragma allows defining fine-grain specifications
5997 for use by testing tools.
5998 The compiler checks the validity of the `Test_Case` pragma, but its
5999 presence does not lead to any modification of the code generated by the
6000 compiler.
6002 `Test_Case` pragmas may only appear immediately following the
6003 (separate) declaration of a subprogram in a package declaration, inside
6004 a package spec unit. Only other pragmas may intervene (that is appear
6005 between the subprogram declaration and a test case).
6007 The compiler checks that boolean expressions given in `Requires` and
6008 `Ensures` are valid, where the rules for `Requires` are the
6009 same as the rule for an expression in `Precondition` and the rules
6010 for `Ensures` are the same as the rule for an expression in
6011 `Postcondition`. In particular, attributes `'Old` and
6012 `'Result` can only be used within the `Ensures`
6013 expression. The following is an example of use within a package spec:
6016 .. code-block:: ada
6018   package Math_Functions is
6019      ...
6020      function Sqrt (Arg : Float) return Float;
6021      pragma Test_Case (Name     => "Test 1",
6022                        Mode     => Nominal,
6023                        Requires => Arg < 10000,
6024                        Ensures  => Sqrt'Result < 10);
6025      ...
6026   end Math_Functions;
6029 The meaning of a test case is that there is at least one context where
6030 `Requires` holds such that, if the associated subprogram is executed in
6031 that context, then `Ensures` holds when the subprogram returns.
6032 Mode `Nominal` indicates that the input context should also satisfy the
6033 precondition of the subprogram, and the output context should also satisfy its
6034 postcondition. Mode `Robustness` indicates that the precondition and
6035 postcondition of the subprogram should be ignored for this test case.
6037 Pragma Thread_Local_Storage
6038 ===========================
6039 .. index:: Task specific storage
6041 .. index:: TLS (Thread Local Storage)
6043 .. index:: Task_Attributes
6045 Syntax:
6050   pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
6053 This pragma specifies that the specified entity, which must be
6054 a variable declared in a library level package, is to be marked as
6055 "Thread Local Storage" (`TLS`). On systems supporting this (which
6056 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
6057 (and hence each Ada task) to see a distinct copy of the variable.
6059 The variable may not have default initialization, and if there is
6060 an explicit initialization, it must be either `null` for an
6061 access variable, or a static expression for a scalar variable.
6062 This provides a low level mechanism similar to that provided by
6063 the `Ada.Task_Attributes` package, but much more efficient
6064 and is also useful in writing interface code that will interact
6065 with foreign threads.
6067 If this pragma is used on a system where `TLS` is not supported,
6068 then an error message will be generated and the program will be rejected.
6070 Pragma Time_Slice
6071 =================
6073 Syntax:
6076 .. code-block:: ada
6078   pragma Time_Slice (static_duration_EXPRESSION);
6081 For implementations of GNAT on operating systems where it is possible
6082 to supply a time slice value, this pragma may be used for this purpose.
6083 It is ignored if it is used in a system that does not allow this control,
6084 or if it appears in other than the main program unit.
6086 Pragma Title
6087 ============
6089 Syntax:
6094   pragma Title (TITLING_OPTION [, TITLING OPTION]);
6096   TITLING_OPTION ::=
6097     [Title    =>] STRING_LITERAL,
6098   | [Subtitle =>] STRING_LITERAL
6101 Syntax checked but otherwise ignored by GNAT.  This is a listing control
6102 pragma used in DEC Ada 83 implementations to provide a title and/or
6103 subtitle for the program listing.  The program listing generated by GNAT
6104 does not have titles or subtitles.
6106 Unlike other pragmas, the full flexibility of named notation is allowed
6107 for this pragma, i.e., the parameters may be given in any order if named
6108 notation is used, and named and positional notation can be mixed
6109 following the normal rules for procedure calls in Ada.
6111 Pragma Type_Invariant
6112 =====================
6114 Syntax:
6119   pragma Type_Invariant
6120     ([Entity =>] type_LOCAL_NAME,
6121      [Check  =>] EXPRESSION);
6124 The `Type_Invariant` pragma is intended to be an exact
6125 replacement for the language-defined `Type_Invariant`
6126 aspect, and shares its restrictions and semantics. It differs
6127 from the language defined `Invariant` pragma in that it
6128 does not permit a string parameter, and it is
6129 controlled by the assertion identifier `Type_Invariant`
6130 rather than `Invariant`.
6132 Pragma Type_Invariant_Class
6133 ===========================
6135 Syntax:
6140   pragma Type_Invariant_Class
6141     ([Entity =>] type_LOCAL_NAME,
6142      [Check  =>] EXPRESSION);
6145 The `Type_Invariant_Class` pragma is intended to be an exact
6146 replacement for the language-defined `Type_Invariant'Class`
6147 aspect, and shares its restrictions and semantics.
6149 Note: This pragma is called `Type_Invariant_Class` rather than
6150 `Type_Invariant'Class` because the latter would not be strictly
6151 conforming to the allowed syntax for pragmas. The motivation
6152 for providing pragmas equivalent to the aspects is to allow a program
6153 to be written using the pragmas, and then compiled if necessary
6154 using an Ada compiler that does not recognize the pragmas or
6155 aspects, but is prepared to ignore the pragmas. The assertion
6156 policy that controls this pragma is `Type_Invariant'Class`,
6157 not `Type_Invariant_Class`.
6159 Pragma Unchecked_Union
6160 ======================
6161 .. index:: Unions in C
6164 Syntax:
6167 .. code-block:: ada
6169   pragma Unchecked_Union (first_subtype_LOCAL_NAME);
6172 This pragma is used to specify a representation of a record type that is
6173 equivalent to a C union. It was introduced as a GNAT implementation defined
6174 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
6175 pragma, making it language defined, and GNAT fully implements this extended
6176 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
6177 details, consult the Ada 2012 Reference Manual, section B.3.3.
6179 Pragma Unevaluated_Use_Of_Old
6180 =============================
6181 .. index:: Attribute Old
6183 .. index:: Attribute Loop_Entry
6185 .. index:: Unevaluated_Use_Of_Old
6188 Syntax:
6191 .. code-block:: ada
6193   pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
6196 This pragma controls the processing of attributes Old and Loop_Entry.
6197 If either of these attributes is used in a potentially unevaluated
6198 expression  (e.g. the then or else parts of an if expression), then
6199 normally this usage is considered illegal if the prefix of the attribute
6200 is other than an entity name. The language requires this
6201 behavior for Old, and GNAT copies the same rule for Loop_Entry.
6203 The reason for this rule is that otherwise, we can have a situation
6204 where we save the Old value, and this results in an exception, even
6205 though we might not evaluate the attribute. Consider this example:
6208 .. code-block:: ada
6210   package UnevalOld is
6211      K : Character;
6212      procedure U (A : String; C : Boolean)  -- ERROR
6213        with Post => (if C then A(1)'Old = K else True);
6214   end;
6217 If procedure U is called with a string with a lower bound of 2, and
6218 C false, then an exception would be raised trying to evaluate A(1)
6219 on entry even though the value would not be actually used.
6221 Although the rule guarantees against this possibility, it is sometimes
6222 too restrictive. For example if we know that the string has a lower
6223 bound of 1, then we will never raise an exception.
6224 The pragma `Unevaluated_Use_Of_Old` can be
6225 used to modify this behavior. If the argument is `Error` then an
6226 error is given (this is the default RM behavior). If the argument is
6227 `Warn` then the usage is allowed as legal but with a warning
6228 that an exception might be raised. If the argument is `Allow`
6229 then the usage is allowed as legal without generating a warning.
6231 This pragma may appear as a configuration pragma, or in a declarative
6232 part or package specification. In the latter case it applies to
6233 uses up to the end of the corresponding statement sequence or
6234 sequence of package declarations.
6236 Pragma Unimplemented_Unit
6237 =========================
6239 Syntax:
6242 .. code-block:: ada
6244   pragma Unimplemented_Unit;
6247 If this pragma occurs in a unit that is processed by the compiler, GNAT
6248 aborts with the message :samp:`xxx not implemented`, where
6249 `xxx` is the name of the current compilation unit.  This pragma is
6250 intended to allow the compiler to handle unimplemented library units in
6251 a clean manner.
6253 The abort only happens if code is being generated.  Thus you can use
6254 specs of unimplemented packages in syntax or semantic checking mode.
6256 Pragma Universal_Aliasing
6257 =========================
6259 Syntax:
6264   pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
6267 `type_LOCAL_NAME` must refer to a type declaration in the current
6268 declarative part.  The effect is to inhibit strict type-based aliasing
6269 optimization for the given type.  In other words, the effect is as though
6270 access types designating this type were subject to pragma No_Strict_Aliasing.
6271 For a detailed description of the strict aliasing optimization, and the
6272 situations in which it must be suppressed, see the section on
6273 `Optimization and Strict Aliasing` in the :title:`GNAT User's Guide`.
6275 Pragma Universal_Data
6276 =====================
6278 Syntax:
6283   pragma Universal_Data [(library_unit_Name)];
6286 This pragma is supported only for the AAMP target and is ignored for
6287 other targets. The pragma specifies that all library-level objects
6288 (Counter 0 data) associated with the library unit are to be accessed
6289 and updated using universal addressing (24-bit addresses for AAMP5)
6290 rather than the default of 16-bit Data Environment (DENV) addressing.
6291 Use of this pragma will generally result in less efficient code for
6292 references to global data associated with the library unit, but
6293 allows such data to be located anywhere in memory. This pragma is
6294 a library unit pragma, but can also be used as a configuration pragma
6295 (including use in the :file:`gnat.adc` file). The functionality
6296 of this pragma is also available by applying the -univ switch on the
6297 compilations of units where universal addressing of the data is desired.
6299 Pragma Unmodified
6300 =================
6301 .. index:: Warnings, unmodified
6303 Syntax:
6308   pragma Unmodified (LOCAL_NAME {, LOCAL_NAME});
6311 This pragma signals that the assignable entities (variables,
6312 `out` parameters, `in out` parameters) whose names are listed are
6313 deliberately not assigned in the current source unit. This
6314 suppresses warnings about the
6315 entities being referenced but not assigned, and in addition a warning will be
6316 generated if one of these entities is in fact assigned in the
6317 same unit as the pragma (or in the corresponding body, or one
6318 of its subunits).
6320 This is particularly useful for clearly signaling that a particular
6321 parameter is not modified, even though the spec suggests that it might
6324 For the variable case, warnings are never given for unreferenced variables
6325 whose name contains one of the substrings
6326 `DISCARD, DUMMY, IGNORE, JUNK, UNUSED` in any casing. Such names
6327 are typically to be used in cases where such warnings are expected.
6328 Thus it is never necessary to use `pragma Unmodified` for such
6329 variables, though it is harmless to do so.
6331 Pragma Unreferenced
6332 ===================
6333 .. index:: Warnings, unreferenced
6335 Syntax:
6340   pragma Unreferenced (LOCAL_NAME {, LOCAL_NAME});
6341   pragma Unreferenced (library_unit_NAME {, library_unit_NAME});
6344 This pragma signals that the entities whose names are listed are
6345 deliberately not referenced in the current source unit after the
6346 occurrence of the pragma. This
6347 suppresses warnings about the
6348 entities being unreferenced, and in addition a warning will be
6349 generated if one of these entities is in fact subsequently referenced in the
6350 same unit as the pragma (or in the corresponding body, or one
6351 of its subunits).
6353 This is particularly useful for clearly signaling that a particular
6354 parameter is not referenced in some particular subprogram implementation
6355 and that this is deliberate. It can also be useful in the case of
6356 objects declared only for their initialization or finalization side
6357 effects.
6359 If `LOCAL_NAME` identifies more than one matching homonym in the
6360 current scope, then the entity most recently declared is the one to which
6361 the pragma applies. Note that in the case of accept formals, the pragma
6362 Unreferenced may appear immediately after the keyword `do` which
6363 allows the indication of whether or not accept formals are referenced
6364 or not to be given individually for each accept statement.
6366 The left hand side of an assignment does not count as a reference for the
6367 purpose of this pragma. Thus it is fine to assign to an entity for which
6368 pragma Unreferenced is given.
6370 Note that if a warning is desired for all calls to a given subprogram,
6371 regardless of whether they occur in the same unit as the subprogram
6372 declaration, then this pragma should not be used (calls from another
6373 unit would not be flagged); pragma Obsolescent can be used instead
6374 for this purpose, see :ref:`Pragma_Obsolescent`.
6376 The second form of pragma `Unreferenced` is used within a context
6377 clause. In this case the arguments must be unit names of units previously
6378 mentioned in `with` clauses (similar to the usage of pragma
6379 `Elaborate_All`. The effect is to suppress warnings about unreferenced
6380 units and unreferenced entities within these units.
6382 For the variable case, warnings are never given for unreferenced variables
6383 whose name contains one of the substrings
6384 `DISCARD, DUMMY, IGNORE, JUNK, UNUSED` in any casing. Such names
6385 are typically to be used in cases where such warnings are expected.
6386 Thus it is never necessary to use `pragma Unreferenced` for such
6387 variables, though it is harmless to do so.
6389 Pragma Unreferenced_Objects
6390 ===========================
6391 .. index:: Warnings, unreferenced
6393 Syntax:
6398   pragma Unreferenced_Objects (local_subtype_NAME {, local_subtype_NAME});
6401 This pragma signals that for the types or subtypes whose names are
6402 listed, objects which are declared with one of these types or subtypes may
6403 not be referenced, and if no references appear, no warnings are given.
6405 This is particularly useful for objects which are declared solely for their
6406 initialization and finalization effect. Such variables are sometimes referred
6407 to as RAII variables (Resource Acquisition Is Initialization). Using this
6408 pragma on the relevant type (most typically a limited controlled type), the
6409 compiler will automatically suppress unwanted warnings about these variables
6410 not being referenced.
6412 Pragma Unreserve_All_Interrupts
6413 ===============================
6415 Syntax:
6418 .. code-block:: ada
6420   pragma Unreserve_All_Interrupts;
6423 Normally certain interrupts are reserved to the implementation.  Any attempt
6424 to attach an interrupt causes Program_Error to be raised, as described in
6425 RM C.3.2(22).  A typical example is the `SIGINT` interrupt used in
6426 many systems for a :kbd:`Ctrl-C` interrupt.  Normally this interrupt is
6427 reserved to the implementation, so that :kbd:`Ctrl-C` can be used to
6428 interrupt execution.
6430 If the pragma `Unreserve_All_Interrupts` appears anywhere in any unit in
6431 a program, then all such interrupts are unreserved.  This allows the
6432 program to handle these interrupts, but disables their standard
6433 functions.  For example, if this pragma is used, then pressing
6434 :kbd:`Ctrl-C` will not automatically interrupt execution.  However,
6435 a program can then handle the `SIGINT` interrupt as it chooses.
6437 For a full list of the interrupts handled in a specific implementation,
6438 see the source code for the spec of `Ada.Interrupts.Names` in
6439 file :file:`a-intnam.ads`.  This is a target dependent file that contains the
6440 list of interrupts recognized for a given target.  The documentation in
6441 this file also specifies what interrupts are affected by the use of
6442 the `Unreserve_All_Interrupts` pragma.
6444 For a more general facility for controlling what interrupts can be
6445 handled, see pragma `Interrupt_State`, which subsumes the functionality
6446 of the `Unreserve_All_Interrupts` pragma.
6448 Pragma Unsuppress
6449 =================
6451 Syntax:
6456   pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
6459 This pragma undoes the effect of a previous pragma `Suppress`.  If
6460 there is no corresponding pragma `Suppress` in effect, it has no
6461 effect.  The range of the effect is the same as for pragma
6462 `Suppress`.  The meaning of the arguments is identical to that used
6463 in pragma `Suppress`.
6465 One important application is to ensure that checks are on in cases where
6466 code depends on the checks for its correct functioning, so that the code
6467 will compile correctly even if the compiler switches are set to suppress
6468 checks. For example, in a program that depends on external names of tagged
6469 types and wants to ensure that the duplicated tag check occurs even if all
6470 run-time checks are suppressed by a compiler switch, the following
6471 configuration pragma will ensure this test is not suppressed:
6474 .. code-block:: ada
6476   pragma Unsuppress (Duplicated_Tag_Check);
6479 This pragma is standard in Ada 2005. It is available in all earlier versions
6480 of Ada as an implementation-defined pragma.
6482 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
6483 a number of implementation-defined check names. See description of pragma
6484 `Suppress` for full details.
6486 Pragma Use_VADS_Size
6487 ====================
6488 .. index:: Size, VADS compatibility
6490 .. index:: Rational profile
6493 Syntax:
6496 .. code-block:: ada
6498   pragma Use_VADS_Size;
6501 This is a configuration pragma.  In a unit to which it applies, any use
6502 of the 'Size attribute is automatically interpreted as a use of the
6503 'VADS_Size attribute.  Note that this may result in incorrect semantic
6504 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
6505 the handling of existing code which depends on the interpretation of Size
6506 as implemented in the VADS compiler.  See description of the VADS_Size
6507 attribute for further details.
6509 Pragma Validity_Checks
6510 ======================
6512 Syntax:
6515 .. code-block:: ada
6517   pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
6520 This pragma is used in conjunction with compiler switches to control the
6521 built-in validity checking provided by GNAT.  The compiler switches, if set
6522 provide an initial setting for the switches, and this pragma may be used
6523 to modify these settings, or the settings may be provided entirely by
6524 the use of the pragma.  This pragma can be used anywhere that a pragma
6525 is legal, including use as a configuration pragma (including use in
6526 the :file:`gnat.adc` file).
6528 The form with a string literal specifies which validity options are to be
6529 activated.  The validity checks are first set to include only the default
6530 reference manual settings, and then a string of letters in the string
6531 specifies the exact set of options required.  The form of this string
6532 is exactly as described for the *-gnatVx* compiler switch (see the
6533 GNAT User's Guide for details).  For example the following two
6534 methods can be used to enable validity checking for mode `in` and
6535 `in out` subprogram parameters:
6539   .. code-block:: ada
6541     pragma Validity_Checks ("im");
6546   .. code-block:: sh
6548     $ gcc -c -gnatVim ...
6551 The form ALL_CHECKS activates all standard checks (its use is equivalent
6552 to the use of the `gnatva` switch.
6554 The forms with `Off` and `On`
6555 can be used to temporarily disable validity checks
6556 as shown in the following example:
6559 .. code-block:: ada
6561   pragma Validity_Checks ("c"); -- validity checks for copies
6562   pragma Validity_Checks (Off); -- turn off validity checks
6563   A := B;                       -- B will not be validity checked
6564   pragma Validity_Checks (On);  -- turn validity checks back on
6565   A := C;                       -- C will be validity checked
6568 Pragma Volatile
6569 ===============
6571 Syntax:
6574 .. code-block:: ada
6576   pragma Volatile (LOCAL_NAME);
6579 This pragma is defined by the Ada Reference Manual, and the GNAT
6580 implementation is fully conformant with this definition.  The reason it
6581 is mentioned in this section is that a pragma of the same name was supplied
6582 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
6583 implementation of pragma Volatile is upwards compatible with the
6584 implementation in DEC Ada 83.
6586 Pragma Volatile_Full_Access
6587 ===========================
6589 Syntax:
6592 .. code-block:: ada
6594   pragma Volatile_Full_Access (LOCAL_NAME);
6597 This is similar in effect to pragma Volatile, except that any reference to the
6598 object is guaranteed to be done only with instructions that read or write all
6599 the bits of the object. Furthermore, if the object is of a composite type,
6600 then any reference to a component of the object is guaranteed to read and/or
6601 write all the bits of the object.
6603 The intention is that this be suitable for use with memory-mapped I/O devices
6604 on some machines. Note that there are two important respects in which this is
6605 different from `pragma Atomic`. First a reference to a `Volatile_Full_Access`
6606 object is not a sequential action in the RM 9.10 sense and, therefore, does
6607 not create a synchronization point. Second, in the case of `pragma Atomic`,
6608 there is no guarantee that all the bits will be accessed if the reference
6609 is not to the whole object; the compiler is allowed (and generally will)
6610 access only part of the object in this case.
6612 It is not permissible to specify `Atomic` and `Volatile_Full_Access` for
6613 the same object.
6615 It is not permissible to specify `Volatile_Full_Access` for a composite
6616 (record or array) type or object that has at least one `Aliased` component.
6618 Pragma Warning_As_Error
6619 =======================
6621 Syntax:
6624 .. code-block:: ada
6626   pragma Warning_As_Error (static_string_EXPRESSION);
6629 This configuration pragma allows the programmer to specify a set
6630 of warnings that will be treated as errors. Any warning which
6631 matches the pattern given by the pragma argument will be treated
6632 as an error. This gives much more precise control that -gnatwe
6633 which treats all warnings as errors.
6635 The pattern may contain asterisks, which match zero or more characters in
6636 the message. For example, you can use
6637 `pragma Warning_As_Error ("bits of*unused")` to treat the warning
6638 message `warning: 960 bits of "a" unused` as an error. No other regular
6639 expression notations are permitted. All characters other than asterisk in
6640 these three specific cases are treated as literal characters in the match.
6641 The match is case insensitive, for example XYZ matches xyz.
6643 Note that the pattern matches if it occurs anywhere within the warning
6644 message string (it is not necessary to put an asterisk at the start and
6645 the end of the message, since this is implied).
6647 Another possibility for the static_string_EXPRESSION which works whether
6648 or not error tags are enabled (*-gnatw.d*) is to use the
6649 *-gnatw* tag string, enclosed in brackets,
6650 as shown in the example below, to treat a class of warnings as errors.
6652 The above use of patterns to match the message applies only to warning
6653 messages generated by the front end. This pragma can also be applied to
6654 warnings provided by the back end and mentioned in :ref:`Pragma_Warnings`.
6655 By using a single full *-Wxxx* switch in the pragma, such warnings
6656 can also be treated as errors.
6658 The pragma can appear either in a global configuration pragma file
6659 (e.g. :file:`gnat.adc`), or at the start of a file. Given a global
6660 configuration pragma file containing:
6663 .. code-block:: ada
6665   pragma Warning_As_Error ("[-gnatwj]");
6668 which will treat all obsolescent feature warnings as errors, the
6669 following program compiles as shown (compile options here are
6670 *-gnatwa.d -gnatl -gnatj55*).
6675        1. pragma Warning_As_Error ("*never assigned*");
6676        2. function Warnerr return String is
6677        3.    X : Integer;
6678              |
6679           >>> error: variable "X" is never read and
6680               never assigned [-gnatwv] [warning-as-error]
6682        4.    Y : Integer;
6683              |
6684           >>> warning: variable "Y" is assigned but
6685               never read [-gnatwu]
6687        5. begin
6688        6.    Y := 0;
6689        7.    return %ABC%;
6690                     |
6691           >>> error: use of "%" is an obsolescent
6692               feature (RM J.2(4)), use """ instead
6693               [-gnatwj] [warning-as-error]
6695        8. end;
6697    8 lines: No errors, 3 warnings (2 treated as errors)
6700 Note that this pragma does not affect the set of warnings issued in
6701 any way, it merely changes the effect of a matching warning if one
6702 is produced as a result of other warnings options. As shown in this
6703 example, if the pragma results in a warning being treated as an error,
6704 the tag is changed from "warning:" to "error:" and the string
6705 "[warning-as-error]" is appended to the end of the message.
6707 .. _Pragma_Warnings:
6709 Pragma Warnings
6710 ===============
6712 Syntax:
6715 .. code-block:: ada
6717   pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]);
6719   DETAILS ::= On | Off
6720   DETAILS ::= On | Off, local_NAME
6721   DETAILS ::= static_string_EXPRESSION
6722   DETAILS ::= On | Off, static_string_EXPRESSION
6724   TOOL_NAME ::= GNAT | GNATProve
6726   REASON ::= Reason => STRING_LITERAL {& STRING_LITERAL}
6728 Note: in Ada 83 mode, a string literal may be used in place of a static string
6729 expression (which does not exist in Ada 83).
6731 Note if the second argument of `DETAILS` is a `local_NAME` then the
6732 second form is always understood. If the intention is to use
6733 the fourth form, then you can write `NAME & ""` to force the
6734 intepretation as a `static_string_EXPRESSION`.
6736 Note: if the first argument is a valid `TOOL_NAME`, it will be interpreted
6737 that way. The use of the `TOOL_NAME` argument is relevant only to users
6738 of SPARK and GNATprove, see last part of this section for details.
6740 Normally warnings are enabled, with the output being controlled by
6741 the command line switch.  Warnings (`Off`) turns off generation of
6742 warnings until a Warnings (`On`) is encountered or the end of the
6743 current unit.  If generation of warnings is turned off using this
6744 pragma, then some or all of the warning messages are suppressed,
6745 regardless of the setting of the command line switches.
6747 The `Reason` parameter may optionally appear as the last argument
6748 in any of the forms of this pragma. It is intended purely for the
6749 purposes of documenting the reason for the `Warnings` pragma.
6750 The compiler will check that the argument is a static string but
6751 otherwise ignore this argument. Other tools may provide specialized
6752 processing for this string.
6754 The form with a single argument (or two arguments if Reason present),
6755 where the first argument is `ON` or `OFF`
6756 may be used as a configuration pragma.
6758 If the `LOCAL_NAME` parameter is present, warnings are suppressed for
6759 the specified entity.  This suppression is effective from the point where
6760 it occurs till the end of the extended scope of the variable (similar to
6761 the scope of `Suppress`). This form cannot be used as a configuration
6762 pragma.
6764 In the case where the first argument is other than `ON` or
6765 `OFF`,
6766 the third form with a single static_string_EXPRESSION argument (and possible
6767 reason) provides more precise
6768 control over which warnings are active. The string is a list of letters
6769 specifying which warnings are to be activated and which deactivated. The
6770 code for these letters is the same as the string used in the command
6771 line switch controlling warnings. For a brief summary, use the gnatmake
6772 command with no arguments, which will generate usage information containing
6773 the list of warnings switches supported. For
6774 full details see the section on `Warning Message Control` in the
6775 :title:`GNAT User's Guide`.
6776 This form can also be used as a configuration pragma.
6778 The warnings controlled by the *-gnatw* switch are generated by the
6779 front end of the compiler. The GCC back end can provide additional warnings
6780 and they are controlled by the *-W* switch. Such warnings can be
6781 identified by the appearance of a string of the form `[-Wxxx]` in the
6782 message which designates the *-Wxxx* switch that controls the message.
6783 The form with a single static_string_EXPRESSION argument also works for these
6784 warnings, but the string must be a single full *-Wxxx* switch in this
6785 case. The above reference lists a few examples of these additional warnings.
6787 The specified warnings will be in effect until the end of the program
6788 or another pragma Warnings is encountered. The effect of the pragma is
6789 cumulative. Initially the set of warnings is the standard default set
6790 as possibly modified by compiler switches. Then each pragma Warning
6791 modifies this set of warnings as specified. This form of the pragma may
6792 also be used as a configuration pragma.
6794 The fourth form, with an `On|Off` parameter and a string, is used to
6795 control individual messages, based on their text. The string argument
6796 is a pattern that is used to match against the text of individual
6797 warning messages (not including the initial "warning: " tag).
6799 The pattern may contain asterisks, which match zero or more characters in
6800 the message. For example, you can use
6801 `pragma Warnings (Off, "bits of*unused")` to suppress the warning
6802 message `warning: 960 bits of "a" unused`. No other regular
6803 expression notations are permitted. All characters other than asterisk in
6804 these three specific cases are treated as literal characters in the match.
6805 The match is case insensitive, for example XYZ matches xyz.
6807 Note that the pattern matches if it occurs anywhere within the warning
6808 message string (it is not necessary to put an asterisk at the start and
6809 the end of the message, since this is implied).
6811 The above use of patterns to match the message applies only to warning
6812 messages generated by the front end. This form of the pragma with a string
6813 argument can also be used to control warnings provided by the back end and
6814 mentioned above. By using a single full *-Wxxx* switch in the pragma,
6815 such warnings can be turned on and off.
6817 There are two ways to use the pragma in this form. The OFF form can be used
6818 as a configuration pragma. The effect is to suppress all warnings (if any)
6819 that match the pattern string throughout the compilation (or match the
6820 -W switch in the back end case).
6822 The second usage is to suppress a warning locally, and in this case, two
6823 pragmas must appear in sequence:
6826 .. code-block:: ada
6828   pragma Warnings (Off, Pattern);
6829   ... code where given warning is to be suppressed
6830   pragma Warnings (On, Pattern);
6833 In this usage, the pattern string must match in the Off and On
6834 pragmas, and (if *-gnatw.w* is given) at least one matching
6835 warning must be suppressed.
6837 Note: to write a string that will match any warning, use the string
6838 `"***"`. It will not work to use a single asterisk or two
6839 asterisks since this looks like an operator name. This form with three
6840 asterisks is similar in effect to specifying `pragma Warnings (Off)` except (if *-gnatw.w* is given) that a matching
6841 `pragma Warnings (On, "***")` will be required. This can be
6842 helpful in avoiding forgetting to turn warnings back on.
6844 Note: the debug flag -gnatd.i (`/NOWARNINGS_PRAGMAS` in VMS) can be
6845 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
6846 be useful in checking whether obsolete pragmas in existing programs are hiding
6847 real problems.
6849 Note: pragma Warnings does not affect the processing of style messages. See
6850 separate entry for pragma Style_Checks for control of style messages.
6852 Users of the formal verification tool GNATprove for the SPARK subset of Ada may
6853 use the version of the pragma with a `TOOL_NAME` parameter.
6855 If present, `TOOL_NAME` is the name of a tool, currently either `GNAT` for the
6856 compiler or `GNATprove` for the formal verification tool. A given tool only
6857 takes into account pragma Warnings that do not specify a tool name, or that
6858 specify the matching tool name. This makes it possible to disable warnings
6859 selectively for each tool, and as a consequence to detect useless pragma
6860 Warnings with switch `-gnatw.w`.
6862 Pragma Weak_External
6863 ====================
6865 Syntax:
6868 .. code-block:: ada
6870   pragma Weak_External ([Entity =>] LOCAL_NAME);
6873 `LOCAL_NAME` must refer to an object that is declared at the library
6874 level. This pragma specifies that the given entity should be marked as a
6875 weak symbol for the linker. It is equivalent to `__attribute__((weak))`
6876 in GNU C and causes `LOCAL_NAME` to be emitted as a weak symbol instead
6877 of a regular symbol, that is to say a symbol that does not have to be
6878 resolved by the linker if used in conjunction with a pragma Import.
6880 When a weak symbol is not resolved by the linker, its address is set to
6881 zero. This is useful in writing interfaces to external modules that may
6882 or may not be linked in the final executable, for example depending on
6883 configuration settings.
6885 If a program references at run time an entity to which this pragma has been
6886 applied, and the corresponding symbol was not resolved at link time, then
6887 the execution of the program is erroneous. It is not erroneous to take the
6888 Address of such an entity, for example to guard potential references,
6889 as shown in the example below.
6891 Some file formats do not support weak symbols so not all target machines
6892 support this pragma.
6895 .. code-block:: ada
6897   --  Example of the use of pragma Weak_External
6899   package External_Module is
6900     key : Integer;
6901     pragma Import (C, key);
6902     pragma Weak_External (key);
6903     function Present return boolean;
6904   end External_Module;
6906   with System; use System;
6907   package body External_Module is
6908     function Present return boolean is
6909     begin
6910       return key'Address /= System.Null_Address;
6911     end Present;
6912   end External_Module;
6915 Pragma Wide_Character_Encoding
6916 ==============================
6918 Syntax:
6921 .. code-block:: ada
6923   pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
6926 This pragma specifies the wide character encoding to be used in program
6927 source text appearing subsequently. It is a configuration pragma, but may
6928 also be used at any point that a pragma is allowed, and it is permissible
6929 to have more than one such pragma in a file, allowing multiple encodings
6930 to appear within the same file.
6932 The argument can be an identifier or a character literal. In the identifier
6933 case, it is one of `HEX`, `UPPER`, `SHIFT_JIS`,
6934 `EUC`, `UTF8`, or `BRACKETS`. In the character literal
6935 case it is correspondingly one of the characters :kbd:`h`, :kbd:`u`,
6936 :kbd:`s`, :kbd:`e`, :kbd:`8`, or :kbd:`b`.
6938 Note that when the pragma is used within a file, it affects only the
6939 encoding within that file, and does not affect withed units, specs,
6940 or subunits.