summaryrefslogtreecommitdiff
path: root/gcc/ada/validsw.adb
blob: 22730dc769097287316b2320ad48132b437fd096 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
------------------------------------------------------------------------------
--                                                                          --
--                         GNAT COMPILER COMPONENTS                         --
--                                                                          --
--                              V A L I D S W                               --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
--                            $Revision$
--                                                                          --
--          Copyright (C) 2001-2002 Free Software Foundation, Inc.          --
--                                                                          --
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
-- for  more details.  You should have  received  a copy of the GNU General --
-- Public License  distributed with GNAT;  see file COPYING.  If not, write --
-- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
-- MA 02111-1307, USA.                                                      --
--                                                                          --
-- GNAT was originally developed  by the GNAT team at  New York University. --
-- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
--                                                                          --
------------------------------------------------------------------------------

with Opt; use Opt;

package body Validsw is

   ----------------------------------
   -- Reset_Validity_Check_Options --
   ----------------------------------

   procedure Reset_Validity_Check_Options is
   begin
      Validity_Check_Copies         := False;
      Validity_Check_Default        := True;
      Validity_Check_Floating_Point := False;
      Validity_Check_In_Out_Params  := False;
      Validity_Check_In_Params      := False;
      Validity_Check_Operands       := False;
      Validity_Check_Returns        := False;
      Validity_Check_Subscripts     := False;
      Validity_Check_Tests          := False;
   end Reset_Validity_Check_Options;

   ---------------------------------
   -- Save_Validity_Check_Options --
   ---------------------------------

   procedure Save_Validity_Check_Options
     (Options : out Validity_Check_Options)
   is
      P : Natural := 0;

      procedure Add (C : Character; S : Boolean);
      --  Add given character C to string if switch S is true

      procedure Add (C : Character; S : Boolean) is
      begin
         if S then
            P := P + 1;
            Options (P) := C;
         end if;
      end Add;

   --  Start of processing for Save_Validity_Check_Options

   begin
      for K in Options'Range loop
         Options (K) := ' ';
      end loop;

      Add ('n', not Validity_Check_Default);

      Add ('c', Validity_Check_Copies);
      Add ('f', Validity_Check_Floating_Point);
      Add ('i', Validity_Check_In_Params);
      Add ('m', Validity_Check_In_Out_Params);
      Add ('o', Validity_Check_Operands);
      Add ('r', Validity_Check_Returns);
      Add ('s', Validity_Check_Subscripts);
      Add ('t', Validity_Check_Tests);
   end Save_Validity_Check_Options;

   ----------------------------------------
   -- Set_Default_Validity_Check_Options --
   ----------------------------------------

   procedure Set_Default_Validity_Check_Options is
   begin
      Reset_Validity_Check_Options;
      Set_Validity_Check_Options ("d");
   end Set_Default_Validity_Check_Options;

   --------------------------------
   -- Set_Validity_Check_Options --
   --------------------------------

   --  Version used when no error checking is required

   procedure Set_Validity_Check_Options (Options : String) is
      OK : Boolean;
      EC : Natural;

   begin
      Set_Validity_Check_Options (Options, OK, EC);
   end Set_Validity_Check_Options;

   --  Normal version with error checking

   procedure Set_Validity_Check_Options
     (Options  : String;
      OK       : out Boolean;
      Err_Col  : out Natural)
   is
      J : Natural;
      C : Character;

   begin
      Reset_Validity_Check_Options;

      J := Options'First;
      while J <= Options'Last loop
         C := Options (J);
         J := J + 1;

         --  Turn on validity checking (gets turned off by Vn)

         Validity_Checks_On := True;

         case C is

            when 'c' =>
               Validity_Check_Copies         := True;

            when 'd' =>
               Validity_Check_Default        := True;

            when 'f' =>
               Validity_Check_Floating_Point := True;

            when 'i' =>
               Validity_Check_In_Params      := True;

            when 'm' =>
               Validity_Check_In_Out_Params  := True;

            when 'o' =>
               Validity_Check_Operands       := True;

            when 'r' =>
               Validity_Check_Returns        := True;

            when 's' =>
               Validity_Check_Subscripts     := True;

            when 't' =>
               Validity_Check_Tests          := True;

            when 'C' =>
               Validity_Check_Copies         := False;

            when 'D' =>
               Validity_Check_Default        := False;

            when 'I' =>
               Validity_Check_In_Params      := False;

            when 'F' =>
               Validity_Check_Floating_Point := False;

            when 'M' =>
               Validity_Check_In_Out_Params  := False;

            when 'O' =>
               Validity_Check_Operands       := False;

            when 'R' =>
               Validity_Check_Returns        := False;

            when 'S' =>
               Validity_Check_Subscripts     := False;

            when 'T' =>
               Validity_Check_Tests          := False;

            when 'a' =>
               Validity_Check_Copies         := True;
               Validity_Check_Default        := True;
               Validity_Check_Floating_Point := True;
               Validity_Check_In_Out_Params  := True;
               Validity_Check_In_Params      := True;
               Validity_Check_Operands       := True;
               Validity_Check_Returns        := True;
               Validity_Check_Subscripts     := True;
               Validity_Check_Tests          := True;

            when 'n' =>
               Validity_Check_Copies         := False;
               Validity_Check_Default        := False;
               Validity_Check_Floating_Point := False;
               Validity_Check_In_Out_Params  := False;
               Validity_Check_In_Params      := False;
               Validity_Check_Operands       := False;
               Validity_Check_Returns        := False;
               Validity_Check_Subscripts     := False;
               Validity_Check_Tests          := False;
               Validity_Checks_On            := False;

            when ' ' =>
               null;

            when others =>
               OK      := False;
               Err_Col := J - 1;
               return;
         end case;
      end loop;

      OK := True;
      Err_Col := Options'Last + 1;
   end Set_Validity_Check_Options;

end Validsw;