Lady Ada

Ada '83 Language Reference Manual

Copyright 1980, 1982, 1983 owned by the United States Government. Direct reproduction and usage requests to the Ada Information Clearinghouse.


2.8. Pragmas

[PREVIOUS][UP][NEXT]

A pragma is used to convey information to the compiler. A pragma starts with the reserved word pragma followed by an identifier that is the name of the pragma.

    pragma ::=
       pragma identifier [(argument_association {, argument_association})]; 

    argument_association ::=
         [argument_identifier =>] name
       | [argument_identifier =>] expression                                               

Pragmas are only allowed at the following places in a program:

Additional restrictions exist for the placement of specific pragmas.

Some pragmas have arguments. Argument associations can be either positional or named as for parameter associations of subprogram calls (see 6.4). Named associations are, however, only possible if the argument identifiers are defined. A name given in an argument must be either a name visible at the place of the pragma or an identifier specific to the pragma.

The pragmas defined by the language are described in Annex B: they must be supported by every implementation. In addition, an implementation may provide implementation-defined pragmas, which must then be described in Appendix F. An implementation is not allowed to define pragmas whose presence or absence influences the legality of the text outside such pragmas. Consequently, the legality of a program does not depend on the presence or absence of implementation-defined pragmas.

A pragma that is not language-defined has no effect if its identifier is not recognized by the (current) implementation. Furthermore, a pragma (whether language-defined or implementation-defined) has no effect if its placement or its arguments do not correspond to what is allowed for the pragma. The region of text over which a pragma has an effect depends on the pragma.

Examples:

    pragma LIST(OFF);
    pragma OPTIMIZE(TIME);
    pragma INLINE(SETMASK);
    pragma SUPPRESS(RANGE_CHECK, ON => INDEX);  

Note:

It is recommended (but not required) that implementations issue warnings for pragmas that are not recognized and therefore ignored.

References: compilation unit, delimiter, discriminant part, exception handler, expression, formal part, identifier, pragma, legal, name, reserved word, statement, static expression, variant, visibility.

Categories ending with "declaration" comprise: basic declaration 3.1, component declaration 3.7, entry declaration 9.5, generic parameter declaration 12.1

Categories ending with "clause" comprise: alignment clause 13.4, component clause 13.4, context clause 10.1.1, representation clause 13.1, use clause 8.4, with clause 10.1.1

Categories ending with "alternative" comprise: accept alternative 9.7.1, case statement alternative 5.4, delay alternative 9.7.1, select alternative 9.7.1, selective wait alternative 9.7.1, terminate alternative 9.7.1

Rationale references: 2.1 Lexical Structure

Style Guide references: 8.4.2 Coupling Due to Pragmas, 9.1.1 Pragma Inline

[INDEX][CONTENTS]


[Ada Information Clearinghouse]

Address any questions or comments to adainfo@sw-eng.falls-church.va.us.