1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2020, 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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This unit contains the routines used to handle setting of validity
31 -----------------------------
32 -- Validity Check Switches --
33 -----------------------------
35 -- The following flags determine the specific set of validity checks
36 -- to be made if validity checking is active (Validity_Checks_On = True)
38 -- See GNAT users guide for an exact description of each option. The letter
39 -- given in the comment is the letter used in the -gnatV compiler switch
40 -- or in the argument of a Validity_Checks pragma to activate the option.
41 -- The corresponding upper case letter deactivates the option.
43 Validity_Check_Components
: Boolean := False;
44 -- Controls validity checking for assignment to elementary components of
45 -- records. If this switch is set to True using -gnatVe, or an 'e' in the
46 -- argument of Validity_Checks pragma, then the right-hand side of an
47 -- assignment to such a component is checked for validity.
49 Validity_Check_Copies
: Boolean := False;
50 -- Controls the validity checking of copies. If this switch is set to
51 -- True using -gnatVc, or a 'c' in the argument of a Validity_Checks
52 -- pragma, then the right-hand side of assignments and also initializing
53 -- expressions in object declarations are checked for validity.
55 Validity_Check_Default
: Boolean := True;
56 -- Controls default (reference manual) validity checking. If this switch is
57 -- set to True using -gnatVd or a 'd' in the argument of a Validity_Checks
58 -- pragma (or the initial default value is used, set True), then left-hand
59 -- side subscripts and case statement arguments are checked for validity.
60 -- This switch is also set by default if no -gnatV switch is used and no
61 -- Validity_Checks pragma is processed.
63 Validity_Check_Floating_Point
: Boolean := False;
64 -- Normally validity checking applies only to discrete values (integer and
65 -- enumeration types). If this switch is set to True using -gnatVf or an
66 -- 'f' in the argument of a Validity_Checks pragma, then floating-point
67 -- values are also checked. If the context in which such checks occur
68 -- depends on other flags, e.g. if Validity_Check_Copies is also set,
69 -- then floating-point values on the right-hand side of an assignment
70 -- will be validity checked.
72 Validity_Check_In_Out_Params
: Boolean := False;
73 -- Controls the validity checking of IN OUT parameters. If this switch
74 -- is set to True using -gnatVm or a 'm' in the argument of a pragma
75 -- Validity_Checks, then the initial value of all IN OUT parameters
76 -- will be checked at the point of call of a procedure. Note that the
77 -- character 'm' here stands for modified (parameters).
79 Validity_Check_In_Params
: Boolean := False;
80 -- Controls the validity checking of IN parameters. If this switch is
81 -- set to True using -gnatVi or an 'i' in the argument of a pragma
82 -- Validity_Checks, then the initial value of all IN parameters
83 -- will be checked at the point of call of a procedure or function.
85 Validity_Check_Operands
: Boolean := False;
86 -- Controls validity checking of operands. If this switch is set to
87 -- True using -gnatVo or an 'o' in the argument of a Validity_Checks
88 -- pragma, then operands of all predefined operators and attributes
89 -- will be validity checked.
91 Validity_Check_Parameters
: Boolean := False;
92 -- This controls validity treatment for parameters within a subprogram.
93 -- Normally if validity checking is enabled for parameters on a call
94 -- (Validity_Check_In[_Out]_Params) then an assumption is made that the
95 -- parameter values are valid on entry and not checked again within a
96 -- procedure. Setting Validity_Check_Parameters removes this assumption
97 -- and ensures that no assumptions are made about parameters, so that
98 -- they will always be checked.
100 Validity_Check_Returns
: Boolean := False;
101 -- Controls validity checking of returned values. If this switch is set
102 -- to True using -gnatVr, or an 'r' in the argument of a Validity_Checks
103 -- pragma, then the expression in a RETURN statement is validity checked.
105 Validity_Check_Subscripts
: Boolean := False;
106 -- Controls validity checking of subscripts. If this switch is set to True
107 -- using -gnatVs, or an 's' in the argument of a Validity_Checks pragma,
108 -- then all subscripts are checked for validity. Note that left-hand side
109 -- subscript checking is also controlled by Validity_Check_Default. If
110 -- Validity_Check_Subscripts is True, then all subscripts are checked,
111 -- otherwise if Validity_Check_Default is True, then left-hand side
112 -- subscripts are checked; otherwise no subscripts are checked.
114 Validity_Check_Tests
: Boolean := False;
115 -- Controls validity checking of tests that occur in conditions (i.e. the
116 -- tests in IF, WHILE, and EXIT statements, and in entry guards). If this
117 -- switch is set to True using -gnatVt, or a 't' in the argument of a
118 -- Validity_Checks pragma, then all such conditions are validity checked.
120 Force_Validity_Checks
: Boolean := False;
121 -- Normally, operands that do not come from source (i.e. cases of expander
122 -- generated code) are not checked, if this flag is set True, then checking
123 -- of such operands is forced (if Validity_Check_Operands is set).
129 procedure Set_Validity_Check_Options
132 Err_Col
: out Natural);
133 -- This procedure is called to set the validity check options that
134 -- correspond to the characters in the given Options string. If
135 -- all options are valid, then Set_Default_Validity_Check_Options
136 -- is first called to set the defaults, and then the options in the
137 -- given string are set in an additive manner. If any invalid character
138 -- is found, then OK is False on exit, and Err_Col is the index in
139 -- in options of the bad character. If all options are valid, then
140 -- OK is True on return, and Err_Col is set to options'Last + 1.
142 procedure Set_Validity_Check_Options
(Options
: String);
143 -- Like the above procedure, except that the call is simply ignored if
144 -- there are any error conditions, this is for example appropriate for
145 -- calls where the string is known to be valid.
147 procedure Reset_Validity_Check_Options
;
148 -- Sets all validity check options to off
150 subtype Validity_Check_Options
is String (1 .. 16);
151 -- Long enough string to hold all options from Save call below