OSDN Git Service

2007-04-20 Vincent Celier <celier@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / validsw.ads
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-2006, 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 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,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  This unit contains the routines used to handle setting of validity
28 --  checking options.
29
30 package Validsw is
31
32    -----------------------------
33    -- Validity Check Switches --
34    -----------------------------
35
36    --  The following flags determine the specific set of validity checks
37    --  to be made if validity checking is active (Validity_Checks_On = True)
38
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.
43
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.
49
50    Validity_Check_Components : Boolean := False;
51    --  Controls validity checking for assignment to elementary components of
52    --  records. If this switch is set true using -gnatVe, or an 'e' in the
53    --  argument of Validity_Checks pragma, then the right hand of an assignment
54    --  to such a component is checked for validity.
55
56    Validity_Check_Default : Boolean := True;
57    --  Controls default (reference manual) validity checking. If this switch is
58    --  set to True using -gnatVd or a 'd' in the argument of a Validity_ Checks
59    --  pragma (or the initial default value is used, set True), then left side
60    --  subscripts and case statement arguments are checked for validity. This
61    --  switch is also set by default if no -gnatV switch is used and no
62    --  Validity_Checks pragma is processed.
63
64    Validity_Check_Floating_Point : Boolean := False;
65    --  Normally validity checking applies only to discrete values (integer
66    --  and enumeration types). If this switch is set to True using -gnatVf
67    --  or an 'f' in the argument of a Validity_Checks pragma, then floating-
68    --  point values are also checked. The context in which such checks
69    --  occur depends on other flags, e.g. if Validity_Check_Copies is also
70    --  set then floating-point values on the right side of an assignment
71    --  will be validity checked.
72
73    Validity_Check_In_Out_Params : Boolean := False;
74    --  Controls the validity checking of IN OUT parameters. If this switch
75    --  is set to True using -gnatVm or a 'm' in the argument of a pragma
76    --  Validity_Checks, then the initial value of all IN OUT parameters
77    --  will be checked at the point of call of a procecure. Note that the
78    --  character 'm' here stands for modified (parameters).
79
80    Validity_Check_In_Params : Boolean := False;
81    --  Controls the validity checking of IN parameters. If this switch is
82    --  set to True using -gnatVm or an 'i' in the argument of a pragma
83    --  Validity_Checks, then the initial value of all IN parameters
84    --  will be checked at the point of call of a procecure or function.
85
86    Validity_Check_Operands : Boolean := False;
87    --  Controls validity checking of operands. If this switch is set to
88    --  True using -gnatVo or an 'o' in the argument of a Validity_Checks
89    --  pragma, then operands of all predefined operators and attributes
90    --  will be validity checked.
91
92    Validity_Check_Parameters : Boolean := False;
93    --  This controls validity treatment for parameters within a subprogram.
94    --  Normally if validity checking is enabled for parameters on a call
95    --  (Validity_Check_In[_Out]_Params) then an assumption is made that the
96    --  parameter values are valid on entry and not checked again within a
97    --  procedure. Setting Validity_Check_Parameters removes this assumption
98    --  and ensures that no assumptions are made about parameters, so that
99    --  they will always be checked.
100
101    Validity_Check_Returns : Boolean := False;
102    --  Controls validity checking of returned values. If this switch is set
103    --  to True using -gnatVr, or an 'r' in the argument of a Validity_Checks
104    --  pragma, then the expression in a RETURN statement is validity checked.
105
106    Validity_Check_Subscripts : Boolean := False;
107    --  Controls validity checking of subscripts. If this switch is set to
108    --  True using -gnatVs, or an 's' in the argument of a Validity_Checks
109    --  pragma, then all subscripts are checked for validity. Note that left
110    --  side subscript checking is controlled also by Validity_Check_Default.
111    --  If Validity_Check_Subscripts is True, then all subscripts are checked,
112    --  otherwise if Validity_Check_Default is True, then left side subscripts
113    --  are checked, otherwise no subscripts are checked.
114
115    Validity_Check_Tests : Boolean := False;
116    --  Controls validity checking of tests that occur in conditions (i.e. the
117    --  tests in IF, WHILE, and EXIT statements, and in entry guards). If this
118    --  switch is set to True using -gnatVt, or a 't' in the argument of a
119    --  Validity_Checks pragma, then all such conditions are validity checked.
120
121    Force_Validity_Checks : Boolean := False;
122    --  Normally, operands that do not come from source (i.e. cases of expander
123    --  generated code) are not checked, if this flag is set True, then checking
124    --  of such operands is forced (if Validity_Check_Operands is set).
125
126    -----------------
127    -- Subprograms --
128    -----------------
129
130    procedure Set_Default_Validity_Check_Options;
131    --  This procedure is called to set the default validity checking options
132    --  that apply if no Validity_Check switches or pragma is given.
133
134    procedure Set_Validity_Check_Options
135      (Options  : String;
136       OK       : out Boolean;
137       Err_Col  : out Natural);
138    --  This procedure is called to set the validity check options that
139    --  correspond to the characters in the given Options string. If
140    --  all options are valid, then Set_Default_Validity_Check_Options
141    --  is first called to set the defaults, and then the options in the
142    --  given string are set in an additive manner. If any invalid character
143    --  is found, then OK is False on exit, and Err_Col is the index in
144    --  in options of the bad character. If all options are valid, then
145    --  OK is True on return, and Err_Col is set to options'Last + 1.
146
147    procedure Set_Validity_Check_Options (Options : String);
148    --  Like the above procedure, except that the call is simply ignored if
149    --  there are any error conditions, this is for example appopriate for
150    --  calls where the string is known to be valid, e.g. because it was
151    --  obtained by Save_Validity_Check_Options.
152
153    procedure Reset_Validity_Check_Options;
154    --  Sets all validity check options to off
155
156    subtype Validity_Check_Options is String (1 .. 16);
157    --  Long enough string to hold all options from Save call below
158
159    procedure Save_Validity_Check_Options
160      (Options : out Validity_Check_Options);
161    --  Sets Options to represent current selection of options. This
162    --  set can be restored by first calling Reset_Validity_Check_Options,
163    --  and then calling Set_Validity_Check_Options with the Options string.
164
165 end Validsw;