1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2003 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This unit contains the routines used to handle setting of validity
32 -----------------------------
33 -- Validity Check Switches --
34 -----------------------------
36 -- The following flags determine the specific set of validity checks
37 -- to be made if validity checking is active (Validity_Checks_On = True)
39 -- See GNAT users guide for an exact description of each option. The letter
40 -- given in the comment is the letter used in the -gnatV compiler switch
41 -- or in the argument of a Validity_Checks pragma to activate the option.
42 -- The corresponding upper case letter deactivates the option.
44 Validity_Check_Copies
: Boolean := False;
45 -- Controls the validity checking of copies. If this switch is set to
46 -- true using -gnatVc, or a 'c' in the argument of a Validity_Checks
47 -- pragma, then the right side of assignments and also initializing
48 -- expressions in object declarations are checked for validity.
50 Validity_Check_Default
: Boolean := True;
51 -- Controls default (reference manual) validity checking. If this switch
52 -- is set to True using -gnatVd or a 'd' in the argument of a Validity_
53 -- Checks pragma then left side subscripts and case statement arguments
54 -- are checked for validity. This switch is also set by default if no
55 -- -gnatV switch is used and no Validity_Checks pragma is processed.
57 Validity_Check_Floating_Point
: Boolean := False;
58 -- Normally validity checking applies only to discrete values (integer
59 -- and enumeration types). If this switch is set to True using -gnatVf
60 -- or an 'f' in the argument of a Validity_Checks pragma, then floating-
61 -- point values are also checked. The context in which such checks
62 -- occur depends on other flags, e.g. if Validity_Check_Copies is also
63 -- set then floating-point values on the right side of an assignment
64 -- will be validity checked.
66 Validity_Check_In_Out_Params
: Boolean := False;
67 -- Controls the validity checking of IN OUT parameters. If this switch
68 -- is set to True using -gnatVm or a 'm' in the argument of a pragma
69 -- Validity_Checks, then the initial value of all IN OUT parameters
70 -- will be checked at the point of call of a procecure. Note that the
71 -- character 'm' here stands for modified (parameters).
73 Validity_Check_In_Params
: Boolean := False;
74 -- Controls the validity checking of IN parameters. If this switch is
75 -- set to True using -gnatVm or an 'i' in the argument of a pragma
76 -- Validity_Checks, then the initial value of all IN parameters
77 -- will be checked at the point of call of a procecure or function.
79 Validity_Check_Operands
: Boolean := False;
80 -- Controls validity checking of operands. If this switch is set to
81 -- True using -gnatVo or an 'o' in the argument of a Validity_Checks
82 -- pragma, then operands of all predefined operators and attributes
83 -- will be validity checked.
85 Validity_Check_Parameters
: Boolean := False;
86 -- This controls validity treatment for parameters within a subprogram.
87 -- Normally if validity checking is enabled for parameters on a call
88 -- (Validity_Check_In[_Out]_Params) then an assumption is made that the
89 -- parameter values are valid on entry and not checked again within a
90 -- procedure. Setting Validity_Check_Parameters removes this assumption
91 -- and ensures that no assumptions are made about parameters, so that
92 -- they will always be checked.
94 Validity_Check_Returns
: Boolean := False;
95 -- Controls validity checking of returned values. If this switch is set
96 -- to True using -gnatVr, or an 'r' in the argument of a Validity_Checks
97 -- pragma, then the expression in a RETURN statement is validity checked.
99 Validity_Check_Subscripts
: Boolean := False;
100 -- Controls validity checking of subscripts. If this switch is set to
101 -- True using -gnatVs, or an 's' in the argument of a Validity_Checks
102 -- pragma, then all subscripts are checked for validity. Note that left
103 -- side subscript checking is controlled also by Validity_Check_Default.
104 -- If Validity_Check_Subscripts is True, then all subscripts are checked,
105 -- otherwise if Validity_Check_Default is True, then left side subscripts
106 -- are checked, otherwise no subscripts are checked.
108 Validity_Check_Tests
: Boolean := False;
109 -- Controls validity checking of tests that occur in conditions (i.e. the
110 -- tests in IF, WHILE, and EXIT statements, and in entry guards). If this
111 -- switch is set to True using -gnatVt, or a 't' in the argument of a
112 -- Validity_Checks pragma, then all such conditions are validity checked.
114 Force_Validity_Checks
: Boolean := False;
115 -- Normally, operands that do not come from source (i.e. cases of expander
116 -- generated code) are not checked, if this flag is set True, then checking
117 -- of such operands is forced (if Validity_Check_Operands is set).
123 procedure Set_Default_Validity_Check_Options
;
124 -- This procedure is called to set the default validity checking options
125 -- that apply if no Validity_Check switches or pragma is given.
127 procedure Set_Validity_Check_Options
130 Err_Col
: out Natural);
131 -- This procedure is called to set the validity check options that
132 -- correspond to the characters in the given Options string. If
133 -- all options are valid, then Set_Default_Validity_Check_Options
134 -- is first called to set the defaults, and then the options in the
135 -- given string are set in an additive manner. If any invalid character
136 -- is found, then OK is False on exit, and Err_Col is the index in
137 -- in options of the bad character. If all options are valid, then
138 -- OK is True on return, and Err_Col is set to options'Last + 1.
140 procedure Set_Validity_Check_Options
(Options
: String);
141 -- Like the above procedure, except that the call is simply ignored if
142 -- there are any error conditions, this is for example appopriate for
143 -- calls where the string is known to be valid, e.g. because it was
144 -- obtained by Save_Validity_Check_Options.
146 procedure Reset_Validity_Check_Options
;
147 -- Sets all validity check options to off
149 subtype Validity_Check_Options
is String (1 .. 16);
150 -- Long enough string to hold all options from Save call below
152 procedure Save_Validity_Check_Options
153 (Options
: out Validity_Check_Options
);
154 -- Sets Options to represent current selection of options. This
155 -- set can be restored by first calling Reset_Validity_Check_Options,
156 -- and then calling Set_Validity_Check_Options with the Options string.