Next: , Previous: Pragma Check_Name, Up: Implementation Defined Pragmas


Pragma Check_Policy

Syntax:

     pragma Check_Policy
      ([Name   =>] CHECK_KIND,
       [Policy =>] POLICY_IDENTIFIER);
     
     pragma Check_Policy (
         CHECK_KIND => POLICY_IDENTIFIER
      {, CHECK_KIND => POLICY_IDENTIFIER});
     
     ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
     
     CHECK_KIND ::= IDENTIFIER           |
                    Pre'Class            |
                    Post'Class           |
                    Type_Invariant'Class |
                    Invariant'Class
     
     The identifiers Name and Policy are not allowed as CHECK_KIND values. This
     avoids confusion between the two possible syntax forms for this pragma.
     
     POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE

This pragma is used to set the checking policy for assertions (specified by aspects or pragmas), the Debug pragma, or additional checks to be checked using the Check pragma. It may appear either as a configuration pragma, or within a declarative part of package. In the latter case, it applies from the point where it appears to the end of the declarative region (like pragma Suppress).

The Check_Policy pragma is similar to the predefined Assertion_Policy pragma, and if the check kind corresponds to one of the assertion kinds that are allowed by Assertion_Policy, then the effect is identical.

If the first argument is Debug, then the policy applies to Debug pragmas, disabling their effect if the policy is OFF, DISABLE, or IGNORE, and allowing them to execute with normal semantics if the policy is ON or CHECK. In addition if the policy is DISABLE, then the procedure call in Debug pragmas will be totally ignored and not analyzed semantically.

Finally the first argument may be some other identifier than the above possibilities, in which case it controls a set of named assertions that can be checked using pragma Check. For example, if the pragma:

     pragma Check_Policy (Critical_Error, OFF);

is given, then subsequent Check pragmas whose first argument is also Critical_Error will be disabled.

The check policy is OFF to turn off corresponding checks, and ON to turn on corresponding checks. The default for a set of checks for which no Check_Policy is given is OFF unless the compiler switch -gnata is given, which turns on all checks by default.

The check policy settings CHECK and IGNORE are recognized as synonyms for ON and OFF. These synonyms are provided for compatibility with the standard Assertion_Policy pragma. The check policy setting DISABLE causes the second argument of a corresponding Check pragma to be completely ignored and not analyzed.