OSDN Git Service

* ChangeLog.vta: New.
[pf3gnuchains/gcc-fork.git] / gcc / ada / validsw.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              V A L I D S W                               --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 2001-2007, 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 with Opt; use Opt;
27
28 package body Validsw is
29
30    ----------------------------------
31    -- Reset_Validity_Check_Options --
32    ----------------------------------
33
34    procedure Reset_Validity_Check_Options is
35    begin
36       Validity_Check_Components     := False;
37       Validity_Check_Copies         := False;
38       Validity_Check_Default        := True;
39       Validity_Check_Floating_Point := False;
40       Validity_Check_In_Out_Params  := False;
41       Validity_Check_In_Params      := False;
42       Validity_Check_Operands       := False;
43       Validity_Check_Returns        := False;
44       Validity_Check_Subscripts     := False;
45       Validity_Check_Tests          := False;
46    end Reset_Validity_Check_Options;
47
48    ---------------------------------
49    -- Save_Validity_Check_Options --
50    ---------------------------------
51
52    procedure Save_Validity_Check_Options
53      (Options : out Validity_Check_Options)
54    is
55       P : Natural := 0;
56
57       procedure Add (C : Character; S : Boolean);
58       --  Add given character C to string if switch S is true
59
60       procedure Add (C : Character; S : Boolean) is
61       begin
62          if S then
63             P := P + 1;
64             Options (P) := C;
65          end if;
66       end Add;
67
68    --  Start of processing for Save_Validity_Check_Options
69
70    begin
71       for K in Options'Range loop
72          Options (K) := ' ';
73       end loop;
74
75       Add ('n', not Validity_Check_Default);
76
77       Add ('c', Validity_Check_Copies);
78       Add ('e', Validity_Check_Components);
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;
87
88    ----------------------------------------
89    -- Set_Default_Validity_Check_Options --
90    ----------------------------------------
91
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;
97
98    --------------------------------
99    -- Set_Validity_Check_Options --
100    --------------------------------
101
102    --  Version used when no error checking is required
103
104    procedure Set_Validity_Check_Options (Options : String) is
105       OK : Boolean;
106       EC : Natural;
107
108    begin
109       Set_Validity_Check_Options (Options, OK, EC);
110    end Set_Validity_Check_Options;
111
112    --  Normal version with error checking
113
114    procedure Set_Validity_Check_Options
115      (Options  : String;
116       OK       : out Boolean;
117       Err_Col  : out Natural)
118    is
119       J : Natural;
120       C : Character;
121
122    begin
123       J := Options'First;
124       while J <= Options'Last loop
125          C := Options (J);
126          J := J + 1;
127
128          --  Turn on validity checking (gets turned off by Vn)
129
130          Validity_Checks_On := True;
131
132          case C is
133
134             when 'c' =>
135                Validity_Check_Copies         := True;
136
137             when 'd' =>
138                Validity_Check_Default        := True;
139
140             when 'e' =>
141                Validity_Check_Components     := True;
142
143             when 'f' =>
144                Validity_Check_Floating_Point := True;
145
146             when 'i' =>
147                Validity_Check_In_Params      := True;
148
149             when 'm' =>
150                Validity_Check_In_Out_Params  := True;
151
152             when 'o' =>
153                Validity_Check_Operands       := True;
154
155             when 'p' =>
156                Validity_Check_Parameters     := True;
157
158             when 'r' =>
159                Validity_Check_Returns        := True;
160
161             when 's' =>
162                Validity_Check_Subscripts     := True;
163
164             when 't' =>
165                Validity_Check_Tests          := True;
166
167             when 'C' =>
168                Validity_Check_Copies         := False;
169
170             when 'D' =>
171                Validity_Check_Default        := False;
172
173             when 'E' =>
174                Validity_Check_Components     := False;
175
176             when 'I' =>
177                Validity_Check_In_Params      := False;
178
179             when 'F' =>
180                Validity_Check_Floating_Point := False;
181
182             when 'M' =>
183                Validity_Check_In_Out_Params  := False;
184
185             when 'O' =>
186                Validity_Check_Operands       := False;
187
188             when 'P' =>
189                Validity_Check_Parameters     := False;
190
191             when 'R' =>
192                Validity_Check_Returns        := False;
193
194             when 'S' =>
195                Validity_Check_Subscripts     := False;
196
197             when 'T' =>
198                Validity_Check_Tests          := False;
199
200             when 'a' =>
201                Validity_Check_Components     := True;
202                Validity_Check_Copies         := True;
203                Validity_Check_Default        := True;
204                Validity_Check_Floating_Point := True;
205                Validity_Check_In_Out_Params  := True;
206                Validity_Check_In_Params      := True;
207                Validity_Check_Operands       := True;
208                Validity_Check_Parameters     := True;
209                Validity_Check_Returns        := True;
210                Validity_Check_Subscripts     := True;
211                Validity_Check_Tests          := True;
212
213             when 'n' =>
214                Validity_Check_Components     := False;
215                Validity_Check_Copies         := False;
216                Validity_Check_Default        := False;
217                Validity_Check_Floating_Point := False;
218                Validity_Check_In_Out_Params  := False;
219                Validity_Check_In_Params      := False;
220                Validity_Check_Operands       := False;
221                Validity_Check_Parameters     := False;
222                Validity_Check_Returns        := False;
223                Validity_Check_Subscripts     := False;
224                Validity_Check_Tests          := False;
225                Validity_Checks_On            := False;
226
227             when ' ' =>
228                null;
229
230             when others =>
231                OK      := False;
232                Err_Col := J - 1;
233                return;
234          end case;
235       end loop;
236
237       OK := True;
238       Err_Col := Options'Last + 1;
239    end Set_Validity_Check_Options;
240
241 end Validsw;