Next: Pragma Subtitle, Previous: Pragma Stream_Convert, Up: Implementation Defined Pragmas
pragma Style_Checks (string_LITERAL | ALL_CHECKS | On | Off [, LOCAL_NAME]);
This pragma is used in conjunction with compiler switches to control the built in style checking provided by GNAT. The compiler switches, if set, provide an initial setting for the switches, and this pragma may be used to modify these settings, or the settings may be provided entirely by the use of the pragma. This pragma can be used anywhere that a pragma is legal, including use as a configuration pragma (including use in the gnat.adc file).
The form with a string literal specifies which style options are to be activated. These are additive, so they apply in addition to any previously set style check options. The codes for the options are the same as those used in the -gnaty switch to gcc or gnatmake. For example the following two methods can be used to enable layout checking:
pragma Style_Checks ("l");
gcc -c -gnatyl ...
The form ALL_CHECKS activates all standard checks (its use is equivalent
to the use of the gnaty
switch with no options. See GNAT User's Guide, for details.)
Note: the behavior is slightly different in GNAT mode (-gnatg used). In this case, ALL_CHECKS implies the standard set of GNAT mode style check options (i.e. equivalent to -gnatyg).
The forms with Off
and On
can be used to temporarily disable style checks
as shown in the following example:
pragma Style_Checks ("k"); -- requires keywords in lower case pragma Style_Checks (Off); -- turn off style checks NULL; -- this will not generate an error message pragma Style_Checks (On); -- turn style checks back on NULL; -- this will generate an error message
Finally the two argument form is allowed only if the first argument is
On
or Off
. The effect is to turn of semantic style checks
for the specified entity, as shown in the following example:
pragma Style_Checks ("r"); -- require consistency of identifier casing Arg : Integer; Rf1 : Integer := ARG; -- incorrect, wrong case pragma Style_Checks (Off, Arg); Rf2 : Integer := ARG; -- OK, no error