FSF GCC merge 02/23/03
[official-gcc.git] / gcc / ada / validsw.adb
blob43942b870e757d456572f773a17191b3965c1911
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- V A L I D S W --
6 -- --
7 -- B o d y --
8 -- --
9 -- --
10 -- Copyright (C) 2001-2002 Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 -- --
26 ------------------------------------------------------------------------------
28 with Opt; use Opt;
30 package body Validsw is
32 ----------------------------------
33 -- Reset_Validity_Check_Options --
34 ----------------------------------
36 procedure Reset_Validity_Check_Options is
37 begin
38 Validity_Check_Copies := False;
39 Validity_Check_Default := True;
40 Validity_Check_Floating_Point := False;
41 Validity_Check_In_Out_Params := False;
42 Validity_Check_In_Params := False;
43 Validity_Check_Operands := False;
44 Validity_Check_Returns := False;
45 Validity_Check_Subscripts := False;
46 Validity_Check_Tests := False;
47 end Reset_Validity_Check_Options;
49 ---------------------------------
50 -- Save_Validity_Check_Options --
51 ---------------------------------
53 procedure Save_Validity_Check_Options
54 (Options : out Validity_Check_Options)
56 P : Natural := 0;
58 procedure Add (C : Character; S : Boolean);
59 -- Add given character C to string if switch S is true
61 procedure Add (C : Character; S : Boolean) is
62 begin
63 if S then
64 P := P + 1;
65 Options (P) := C;
66 end if;
67 end Add;
69 -- Start of processing for Save_Validity_Check_Options
71 begin
72 for K in Options'Range loop
73 Options (K) := ' ';
74 end loop;
76 Add ('n', not Validity_Check_Default);
78 Add ('c', Validity_Check_Copies);
79 Add ('f', Validity_Check_Floating_Point);
80 Add ('i', Validity_Check_In_Params);
81 Add ('m', Validity_Check_In_Out_Params);
82 Add ('o', Validity_Check_Operands);
83 Add ('r', Validity_Check_Returns);
84 Add ('s', Validity_Check_Subscripts);
85 Add ('t', Validity_Check_Tests);
86 end Save_Validity_Check_Options;
88 ----------------------------------------
89 -- Set_Default_Validity_Check_Options --
90 ----------------------------------------
92 procedure Set_Default_Validity_Check_Options is
93 begin
94 Reset_Validity_Check_Options;
95 Set_Validity_Check_Options ("d");
96 end Set_Default_Validity_Check_Options;
98 --------------------------------
99 -- Set_Validity_Check_Options --
100 --------------------------------
102 -- Version used when no error checking is required
104 procedure Set_Validity_Check_Options (Options : String) is
105 OK : Boolean;
106 EC : Natural;
108 begin
109 Set_Validity_Check_Options (Options, OK, EC);
110 end Set_Validity_Check_Options;
112 -- Normal version with error checking
114 procedure Set_Validity_Check_Options
115 (Options : String;
116 OK : out Boolean;
117 Err_Col : out Natural)
119 J : Natural;
120 C : Character;
122 begin
123 Reset_Validity_Check_Options;
125 J := Options'First;
126 while J <= Options'Last loop
127 C := Options (J);
128 J := J + 1;
130 -- Turn on validity checking (gets turned off by Vn)
132 Validity_Checks_On := True;
134 case C is
136 when 'c' =>
137 Validity_Check_Copies := True;
139 when 'd' =>
140 Validity_Check_Default := True;
142 when 'f' =>
143 Validity_Check_Floating_Point := True;
145 when 'i' =>
146 Validity_Check_In_Params := True;
148 when 'm' =>
149 Validity_Check_In_Out_Params := True;
151 when 'o' =>
152 Validity_Check_Operands := True;
154 when 'r' =>
155 Validity_Check_Returns := True;
157 when 's' =>
158 Validity_Check_Subscripts := True;
160 when 't' =>
161 Validity_Check_Tests := True;
163 when 'C' =>
164 Validity_Check_Copies := False;
166 when 'D' =>
167 Validity_Check_Default := False;
169 when 'I' =>
170 Validity_Check_In_Params := False;
172 when 'F' =>
173 Validity_Check_Floating_Point := False;
175 when 'M' =>
176 Validity_Check_In_Out_Params := False;
178 when 'O' =>
179 Validity_Check_Operands := False;
181 when 'R' =>
182 Validity_Check_Returns := False;
184 when 'S' =>
185 Validity_Check_Subscripts := False;
187 when 'T' =>
188 Validity_Check_Tests := False;
190 when 'a' =>
191 Validity_Check_Copies := True;
192 Validity_Check_Default := True;
193 Validity_Check_Floating_Point := True;
194 Validity_Check_In_Out_Params := True;
195 Validity_Check_In_Params := True;
196 Validity_Check_Operands := True;
197 Validity_Check_Returns := True;
198 Validity_Check_Subscripts := True;
199 Validity_Check_Tests := True;
201 when 'n' =>
202 Validity_Check_Copies := False;
203 Validity_Check_Default := False;
204 Validity_Check_Floating_Point := False;
205 Validity_Check_In_Out_Params := False;
206 Validity_Check_In_Params := False;
207 Validity_Check_Operands := False;
208 Validity_Check_Returns := False;
209 Validity_Check_Subscripts := False;
210 Validity_Check_Tests := False;
211 Validity_Checks_On := False;
213 when ' ' =>
214 null;
216 when others =>
217 OK := False;
218 Err_Col := J - 1;
219 return;
220 end case;
221 end loop;
223 OK := True;
224 Err_Col := Options'Last + 1;
225 end Set_Validity_Check_Options;
227 end Validsw;