annotate gcc/ada/validsw.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- V A L I D S W --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2001-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This unit contains the routines used to handle setting of validity
kono
parents:
diff changeset
27 -- checking options.
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 package Validsw is
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 -----------------------------
kono
parents:
diff changeset
32 -- Validity Check Switches --
kono
parents:
diff changeset
33 -----------------------------
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 -- The following flags determine the specific set of validity checks
kono
parents:
diff changeset
36 -- to be made if validity checking is active (Validity_Checks_On = True)
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 -- See GNAT users guide for an exact description of each option. The letter
kono
parents:
diff changeset
39 -- given in the comment is the letter used in the -gnatV compiler switch
kono
parents:
diff changeset
40 -- or in the argument of a Validity_Checks pragma to activate the option.
kono
parents:
diff changeset
41 -- The corresponding upper case letter deactivates the option.
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 Validity_Check_Copies : Boolean := False;
kono
parents:
diff changeset
44 -- Controls the validity checking of copies. If this switch is set to
kono
parents:
diff changeset
45 -- true using -gnatVc, or a 'c' in the argument of a Validity_Checks
kono
parents:
diff changeset
46 -- pragma, then the right side of assignments and also initializing
kono
parents:
diff changeset
47 -- expressions in object declarations are checked for validity.
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 Validity_Check_Components : Boolean := False;
kono
parents:
diff changeset
50 -- Controls validity checking for assignment to elementary components of
kono
parents:
diff changeset
51 -- records. If this switch is set true using -gnatVe, or an 'e' in the
kono
parents:
diff changeset
52 -- argument of Validity_Checks pragma, then the right hand of an assignment
kono
parents:
diff changeset
53 -- to such a component is checked for validity.
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 Validity_Check_Default : Boolean := True;
kono
parents:
diff changeset
56 -- Controls default (reference manual) validity checking. If this switch is
kono
parents:
diff changeset
57 -- set to True using -gnatVd or a 'd' in the argument of a Validity_Checks
kono
parents:
diff changeset
58 -- pragma (or the initial default value is used, set True), then left side
kono
parents:
diff changeset
59 -- subscripts and case statement arguments are checked for validity. This
kono
parents:
diff changeset
60 -- switch is also set by default if no -gnatV switch is used and no
kono
parents:
diff changeset
61 -- Validity_Checks pragma is processed.
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 Validity_Check_Floating_Point : Boolean := False;
kono
parents:
diff changeset
64 -- Normally validity checking applies only to discrete values (integer
kono
parents:
diff changeset
65 -- and enumeration types). If this switch is set to True using -gnatVf
kono
parents:
diff changeset
66 -- or an 'f' in the argument of a Validity_Checks pragma, then floating-
kono
parents:
diff changeset
67 -- point values are also checked. The context in which such checks
kono
parents:
diff changeset
68 -- occur depends on other flags, e.g. if Validity_Check_Copies is also
kono
parents:
diff changeset
69 -- set then floating-point values on the right side of an assignment
kono
parents:
diff changeset
70 -- will be validity checked.
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 Validity_Check_In_Out_Params : Boolean := False;
kono
parents:
diff changeset
73 -- Controls the validity checking of IN OUT parameters. If this switch
kono
parents:
diff changeset
74 -- is set to True using -gnatVm or a 'm' in the argument of a pragma
kono
parents:
diff changeset
75 -- Validity_Checks, then the initial value of all IN OUT parameters
kono
parents:
diff changeset
76 -- will be checked at the point of call of a procedure. Note that the
kono
parents:
diff changeset
77 -- character 'm' here stands for modified (parameters).
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 Validity_Check_In_Params : Boolean := False;
kono
parents:
diff changeset
80 -- Controls the validity checking of IN parameters. If this switch is
kono
parents:
diff changeset
81 -- set to True using -gnatVi or an 'i' in the argument of a pragma
kono
parents:
diff changeset
82 -- Validity_Checks, then the initial value of all IN parameters
kono
parents:
diff changeset
83 -- will be checked at the point of call of a procedure or function.
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 Validity_Check_Operands : Boolean := False;
kono
parents:
diff changeset
86 -- Controls validity checking of operands. If this switch is set to
kono
parents:
diff changeset
87 -- True using -gnatVo or an 'o' in the argument of a Validity_Checks
kono
parents:
diff changeset
88 -- pragma, then operands of all predefined operators and attributes
kono
parents:
diff changeset
89 -- will be validity checked.
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 Validity_Check_Parameters : Boolean := False;
kono
parents:
diff changeset
92 -- This controls validity treatment for parameters within a subprogram.
kono
parents:
diff changeset
93 -- Normally if validity checking is enabled for parameters on a call
kono
parents:
diff changeset
94 -- (Validity_Check_In[_Out]_Params) then an assumption is made that the
kono
parents:
diff changeset
95 -- parameter values are valid on entry and not checked again within a
kono
parents:
diff changeset
96 -- procedure. Setting Validity_Check_Parameters removes this assumption
kono
parents:
diff changeset
97 -- and ensures that no assumptions are made about parameters, so that
kono
parents:
diff changeset
98 -- they will always be checked.
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 Validity_Check_Returns : Boolean := False;
kono
parents:
diff changeset
101 -- Controls validity checking of returned values. If this switch is set
kono
parents:
diff changeset
102 -- to True using -gnatVr, or an 'r' in the argument of a Validity_Checks
kono
parents:
diff changeset
103 -- pragma, then the expression in a RETURN statement is validity checked.
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 Validity_Check_Subscripts : Boolean := False;
kono
parents:
diff changeset
106 -- Controls validity checking of subscripts. If this switch is set to
kono
parents:
diff changeset
107 -- True using -gnatVs, or an 's' in the argument of a Validity_Checks
kono
parents:
diff changeset
108 -- pragma, then all subscripts are checked for validity. Note that left
kono
parents:
diff changeset
109 -- side subscript checking is controlled also by Validity_Check_Default.
kono
parents:
diff changeset
110 -- If Validity_Check_Subscripts is True, then all subscripts are checked,
kono
parents:
diff changeset
111 -- otherwise if Validity_Check_Default is True, then left side subscripts
kono
parents:
diff changeset
112 -- are checked, otherwise no subscripts are checked.
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 Validity_Check_Tests : Boolean := False;
kono
parents:
diff changeset
115 -- Controls validity checking of tests that occur in conditions (i.e. the
kono
parents:
diff changeset
116 -- tests in IF, WHILE, and EXIT statements, and in entry guards). If this
kono
parents:
diff changeset
117 -- switch is set to True using -gnatVt, or a 't' in the argument of a
kono
parents:
diff changeset
118 -- Validity_Checks pragma, then all such conditions are validity checked.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 Force_Validity_Checks : Boolean := False;
kono
parents:
diff changeset
121 -- Normally, operands that do not come from source (i.e. cases of expander
kono
parents:
diff changeset
122 -- generated code) are not checked, if this flag is set True, then checking
kono
parents:
diff changeset
123 -- of such operands is forced (if Validity_Check_Operands is set).
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 -----------------
kono
parents:
diff changeset
126 -- Subprograms --
kono
parents:
diff changeset
127 -----------------
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 procedure Set_Default_Validity_Check_Options;
kono
parents:
diff changeset
130 -- This procedure is called to set the default validity checking options
kono
parents:
diff changeset
131 -- that apply if no Validity_Check switches or pragma is given.
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 procedure Set_Validity_Check_Options
kono
parents:
diff changeset
134 (Options : String;
kono
parents:
diff changeset
135 OK : out Boolean;
kono
parents:
diff changeset
136 Err_Col : out Natural);
kono
parents:
diff changeset
137 -- This procedure is called to set the validity check options that
kono
parents:
diff changeset
138 -- correspond to the characters in the given Options string. If
kono
parents:
diff changeset
139 -- all options are valid, then Set_Default_Validity_Check_Options
kono
parents:
diff changeset
140 -- is first called to set the defaults, and then the options in the
kono
parents:
diff changeset
141 -- given string are set in an additive manner. If any invalid character
kono
parents:
diff changeset
142 -- is found, then OK is False on exit, and Err_Col is the index in
kono
parents:
diff changeset
143 -- in options of the bad character. If all options are valid, then
kono
parents:
diff changeset
144 -- OK is True on return, and Err_Col is set to options'Last + 1.
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 procedure Set_Validity_Check_Options (Options : String);
kono
parents:
diff changeset
147 -- Like the above procedure, except that the call is simply ignored if
kono
parents:
diff changeset
148 -- there are any error conditions, this is for example appropriate for
kono
parents:
diff changeset
149 -- calls where the string is known to be valid, e.g. because it was
kono
parents:
diff changeset
150 -- obtained by Save_Validity_Check_Options.
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 procedure Reset_Validity_Check_Options;
kono
parents:
diff changeset
153 -- Sets all validity check options to off
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 subtype Validity_Check_Options is String (1 .. 16);
kono
parents:
diff changeset
156 -- Long enough string to hold all options from Save call below
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 procedure Save_Validity_Check_Options
kono
parents:
diff changeset
159 (Options : out Validity_Check_Options);
kono
parents:
diff changeset
160 -- Sets Options to represent current selection of options. This
kono
parents:
diff changeset
161 -- set can be restored by first calling Reset_Validity_Check_Options,
kono
parents:
diff changeset
162 -- and then calling Set_Validity_Check_Options with the Options string.
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 end Validsw;