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