1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 2001 Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 ------------------------------------------------------------------------------
28 -- This unit contains the routines used to handle setting of validity
33 -----------------------------
34 -- Validity Check Switches --
35 -----------------------------
37 -- The following flags determine the specific set of validity checks
38 -- to be made if validity checking is active (Validity_Checks_On = True)
40 -- See GNAT users guide for an exact description of each option. The letter
41 -- given in the comment is the letter used in the -gnatV compiler switch
42 -- or in the argument of a Validity_Checks pragma to activate the option.
43 -- The corresponding upper case letter deactivates the option.
45 Validity_Check_Copies
: Boolean := False;
46 -- Controls the validity checking of copies. If this switch is set to
47 -- true using -gnatVc, or a 'c' in the argument of a Validity_Checks
48 -- pragma, then the right side of assignments and also initializing
49 -- expressions in object declarations are checked for validity.
51 Validity_Check_Default
: Boolean := True;
52 -- Controls default (reference manual) validity checking. If this switch
53 -- is set to True using -gnatVd or a 'd' in the argument of a Validity_
54 -- Checks pragma then left side subscripts and case statement arguments
55 -- are checked for validity. This switch is also set by default if no
56 -- -gnatV switch is used and no Validity_Checks pragma is processed.
58 Validity_Check_Floating_Point
: Boolean := False;
59 -- Normally validity checking applies only to discrete values (integer
60 -- and enumeration types). If this switch is set to True using -gnatVf
61 -- or an 'f' in the argument of a Validity_Checks pragma, then floating-
62 -- point values are also checked. The context in which such checks
63 -- occur depends on other flags, e.g. if Validity_Check_Copies is also
64 -- set then floating-point values on the right side of an assignment
65 -- will be validity checked.
67 Validity_Check_In_Out_Params
: Boolean := False;
68 -- Controls the validity checking of IN OUT parameters. If this switch
69 -- is set to True using -gnatVm or a 'm' in the argument of a pragma
70 -- Validity_Checks, then the initial value of all IN OUT parameters
71 -- will be checked at the point of call of a procecure. Note that the
72 -- character 'm' here stands for modified (parameters).
74 Validity_Check_In_Params
: Boolean := False;
75 -- Controls the validity checking of IN parameters. If this switch is
76 -- set to True using -gnatVm or an 'i' in the argument of a pragma
77 -- Validity_Checks, then the initial value of all IN parameters
78 -- will be checked at the point of call of a procecure or function.
80 Validity_Check_Operands
: Boolean := False;
81 -- Controls validity checking of operands. If this switch is set to
82 -- True using -gnatVo or an 'o' in the argument of a Validity_Checks
83 -- pragma, then operands of all predefined operators and attributes
84 -- will be validity checked.
86 Validity_Check_Returns
: Boolean := False;
87 -- Controls validity checking of returned values. If this switch is set
88 -- to True using -gnatVr, or an 'r' in the argument of a Validity_Checks
89 -- pragma, then the expression in a RETURN statement is validity checked.
91 Validity_Check_Subscripts
: Boolean := False;
92 -- Controls validity checking of subscripts. If this switch is set to
93 -- True using -gnatVs, or an 's' in the argument of a Validity_Checks
94 -- pragma, then all subscripts are checked for validity. Note that left
95 -- side subscript checking is controlled also by Validity_Check_Default.
96 -- If Validity_Check_Subscripts is True, then all subscripts are checked,
97 -- otherwise if Validity_Check_Default is True, then left side subscripts
98 -- are checked, otherwise no subscripts are checked.
100 Validity_Check_Tests
: Boolean := False;
101 -- Controls validity checking of tests that occur in conditions (i.e. the
102 -- tests in IF, WHILE, and EXIT statements, and in entry guards). If this
103 -- switch is set to True using -gnatVt, or a 't' in the argument of a
104 -- Validity_Checks pragma, then all such conditions are validity checked.
110 procedure Set_Default_Validity_Check_Options
;
111 -- This procedure is called to set the default validity checking options
112 -- that apply if no Validity_Check switches or pragma is given.
114 procedure Set_Validity_Check_Options
117 Err_Col
: out Natural);
118 -- This procedure is called to set the validity check options that
119 -- correspond to the characters in the given Options string. If
120 -- all options are valid, then Set_Default_Validity_Check_Options
121 -- is first called to set the defaults, and then the options in the
122 -- given string are set in an additive manner. If any invalid character
123 -- is found, then OK is False on exit, and Err_Col is the index in
124 -- in options of the bad character. If all options are valid, then
125 -- OK is True on return, and Err_Col is set to options'Last + 1.
127 procedure Set_Validity_Check_Options
(Options
: String);
128 -- Like the above procedure, except that the call is simply ignored if
129 -- there are any error conditions, this is for example appopriate for
130 -- calls where the string is known to be valid, e.g. because it was
131 -- obtained by Save_Validity_Check_Options.
133 procedure Reset_Validity_Check_Options
;
134 -- Sets all validity check options to off
136 subtype Validity_Check_Options
is String (1 .. 16);
137 -- Long enough string to hold all options from Save call below
139 procedure Save_Validity_Check_Options
140 (Options
: out Validity_Check_Options
);
141 -- Sets Options to represent current selection of options. This
142 -- set can be restored by first calling Reset_Validity_Check_Options,
143 -- and then calling Set_Validity_Check_Options with the Options string.