Mercurial > hg > CbC > CbC_gcc
comparison gcc/ada/validsw.ads @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 ------------------------------------------------------------------------------ | |
2 -- -- | |
3 -- GNAT COMPILER COMPONENTS -- | |
4 -- -- | |
5 -- V A L I D S W -- | |
6 -- -- | |
7 -- S p e c -- | |
8 -- -- | |
9 -- Copyright (C) 2001-2017, Free Software Foundation, Inc. -- | |
10 -- -- | |
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. -- | |
20 -- -- | |
21 -- GNAT was originally developed by the GNAT team at New York University. -- | |
22 -- Extensive contributions were provided by Ada Core Technologies Inc. -- | |
23 -- -- | |
24 ------------------------------------------------------------------------------ | |
25 | |
26 -- This unit contains the routines used to handle setting of validity | |
27 -- checking options. | |
28 | |
29 package Validsw is | |
30 | |
31 ----------------------------- | |
32 -- Validity Check Switches -- | |
33 ----------------------------- | |
34 | |
35 -- The following flags determine the specific set of validity checks | |
36 -- to be made if validity checking is active (Validity_Checks_On = True) | |
37 | |
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. | |
42 | |
43 Validity_Check_Copies : Boolean := False; | |
44 -- Controls the validity checking of copies. If this switch is set to | |
45 -- true using -gnatVc, or a 'c' in the argument of a Validity_Checks | |
46 -- pragma, then the right side of assignments and also initializing | |
47 -- expressions in object declarations are checked for validity. | |
48 | |
49 Validity_Check_Components : Boolean := False; | |
50 -- Controls validity checking for assignment to elementary components of | |
51 -- records. If this switch is set true using -gnatVe, or an 'e' in the | |
52 -- argument of Validity_Checks pragma, then the right hand of an assignment | |
53 -- to such a component is checked for validity. | |
54 | |
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 side | |
59 -- subscripts and case statement arguments are checked for validity. This | |
60 -- switch is also set by default if no -gnatV switch is used and no | |
61 -- Validity_Checks pragma is processed. | |
62 | |
63 Validity_Check_Floating_Point : Boolean := False; | |
64 -- Normally validity checking applies only to discrete values (integer | |
65 -- and enumeration types). If this switch is set to True using -gnatVf | |
66 -- or an 'f' in the argument of a Validity_Checks pragma, then floating- | |
67 -- point values are also checked. The context in which such checks | |
68 -- occur depends on other flags, e.g. if Validity_Check_Copies is also | |
69 -- set then floating-point values on the right side of an assignment | |
70 -- will be validity checked. | |
71 | |
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). | |
78 | |
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. | |
84 | |
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. | |
90 | |
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. | |
99 | |
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. | |
104 | |
105 Validity_Check_Subscripts : Boolean := False; | |
106 -- Controls validity checking of subscripts. If this switch is set to | |
107 -- True using -gnatVs, or an 's' in the argument of a Validity_Checks | |
108 -- pragma, then all subscripts are checked for validity. Note that left | |
109 -- side subscript checking is controlled also by Validity_Check_Default. | |
110 -- If Validity_Check_Subscripts is True, then all subscripts are checked, | |
111 -- otherwise if Validity_Check_Default is True, then left side subscripts | |
112 -- are checked, otherwise no subscripts are checked. | |
113 | |
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. | |
119 | |
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). | |
124 | |
125 ----------------- | |
126 -- Subprograms -- | |
127 ----------------- | |
128 | |
129 procedure Set_Default_Validity_Check_Options; | |
130 -- This procedure is called to set the default validity checking options | |
131 -- that apply if no Validity_Check switches or pragma is given. | |
132 | |
133 procedure Set_Validity_Check_Options | |
134 (Options : String; | |
135 OK : out Boolean; | |
136 Err_Col : out Natural); | |
137 -- This procedure is called to set the validity check options that | |
138 -- correspond to the characters in the given Options string. If | |
139 -- all options are valid, then Set_Default_Validity_Check_Options | |
140 -- is first called to set the defaults, and then the options in the | |
141 -- given string are set in an additive manner. If any invalid character | |
142 -- is found, then OK is False on exit, and Err_Col is the index in | |
143 -- in options of the bad character. If all options are valid, then | |
144 -- OK is True on return, and Err_Col is set to options'Last + 1. | |
145 | |
146 procedure Set_Validity_Check_Options (Options : String); | |
147 -- Like the above procedure, except that the call is simply ignored if | |
148 -- there are any error conditions, this is for example appropriate for | |
149 -- calls where the string is known to be valid, e.g. because it was | |
150 -- obtained by Save_Validity_Check_Options. | |
151 | |
152 procedure Reset_Validity_Check_Options; | |
153 -- Sets all validity check options to off | |
154 | |
155 subtype Validity_Check_Options is String (1 .. 16); | |
156 -- Long enough string to hold all options from Save call below | |
157 | |
158 procedure Save_Validity_Check_Options | |
159 (Options : out Validity_Check_Options); | |
160 -- Sets Options to represent current selection of options. This | |
161 -- set can be restored by first calling Reset_Validity_Check_Options, | |
162 -- and then calling Set_Validity_Check_Options with the Options string. | |
163 | |
164 end Validsw; |