OSDN Git Service

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