OSDN Git Service

2012-01-10 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / ada / warnsw.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               W A R N S W                                --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 1999-2011, 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 Warnsw is
29
30    ----------------------------
31    -- Set_Dot_Warning_Switch --
32    ----------------------------
33
34    function Set_Dot_Warning_Switch (C : Character) return Boolean is
35    begin
36       case C is
37          when 'a' =>
38             Warn_On_Assertion_Failure           := True;
39
40          when 'A' =>
41             Warn_On_Assertion_Failure           := False;
42
43          when 'b' =>
44             Warn_On_Biased_Representation       := True;
45
46          when 'B' =>
47             Warn_On_Biased_Representation       := False;
48
49          when 'c' =>
50             Warn_On_Unrepped_Components         := True;
51
52          when 'C' =>
53             Warn_On_Unrepped_Components         := False;
54
55          when 'e' =>
56             Address_Clause_Overlay_Warnings     := True;
57             Check_Unreferenced                  := True;
58             Check_Unreferenced_Formals          := True;
59             Check_Withs                         := True;
60             Constant_Condition_Warnings         := True;
61             Elab_Warnings                       := True;
62             Implementation_Unit_Warnings        := True;
63             Ineffective_Inline_Warnings         := True;
64             List_Inherited_Aspects              := True;
65             Warn_On_Ada_2005_Compatibility      := True;
66             Warn_On_Ada_2012_Compatibility      := True;
67             Warn_On_All_Unread_Out_Parameters   := True;
68             Warn_On_Assertion_Failure           := True;
69             Warn_On_Assumed_Low_Bound           := True;
70             Warn_On_Atomic_Synchronization      := True;
71             Warn_On_Bad_Fixed_Value             := True;
72             Warn_On_Biased_Representation       := True;
73             Warn_On_Constant                    := True;
74             Warn_On_Deleted_Code                := True;
75             Warn_On_Dereference                 := True;
76             Warn_On_Export_Import               := True;
77             Warn_On_Hiding                      := True;
78             Warn_On_Modified_Unread             := True;
79             Warn_On_No_Value_Assigned           := True;
80             Warn_On_Non_Local_Exception         := True;
81             Warn_On_Object_Renames_Function     := True;
82             Warn_On_Obsolescent_Feature         := True;
83             Warn_On_Overlap                     := True;
84             Warn_On_Overridden_Size             := True;
85             Warn_On_Parameter_Order             := True;
86             Warn_On_Questionable_Missing_Parens := True;
87             Warn_On_Record_Holes                := True;
88             Warn_On_Redundant_Constructs        := True;
89             Warn_On_Reverse_Bit_Order           := True;
90             Warn_On_Suspicious_Contract         := True;
91             Warn_On_Unchecked_Conversion        := True;
92             Warn_On_Unordered_Enumeration_Type  := True;
93             Warn_On_Unrecognized_Pragma         := True;
94             Warn_On_Unrepped_Components         := True;
95             Warn_On_Warnings_Off                := True;
96
97          when 'g' =>
98             Set_GNAT_Mode_Warnings;
99
100          when 'h' =>
101             Warn_On_Record_Holes                := True;
102
103          when 'H' =>
104             Warn_On_Record_Holes                := False;
105
106          when 'i' =>
107             Warn_On_Overlap                     := True;
108
109          when 'I' =>
110             Warn_On_Overlap                     := False;
111
112          when 'l' =>
113             List_Inherited_Aspects              := True;
114
115          when 'L' =>
116             List_Inherited_Aspects              := False;
117
118          when 'm' =>
119             Warn_On_Suspicious_Modulus_Value    := True;
120
121          when 'M' =>
122             Warn_On_Suspicious_Modulus_Value    := False;
123
124          when 'n' =>
125             Warn_On_Atomic_Synchronization      := True;
126
127          when 'N' =>
128             Warn_On_Atomic_Synchronization      := False;
129
130          when 'o' =>
131             Warn_On_All_Unread_Out_Parameters   := True;
132
133          when 'O' =>
134             Warn_On_All_Unread_Out_Parameters   := False;
135
136          when 'p' =>
137             Warn_On_Parameter_Order             := True;
138
139          when 'P' =>
140             Warn_On_Parameter_Order             := False;
141
142          when 'r' =>
143             Warn_On_Object_Renames_Function     := True;
144
145          when 'R' =>
146             Warn_On_Object_Renames_Function     := False;
147
148          when 's' =>
149             Warn_On_Overridden_Size             := True;
150
151          when 'S' =>
152             Warn_On_Overridden_Size             := False;
153
154          when 't' =>
155             Warn_On_Suspicious_Contract         := True;
156
157          when 'T' =>
158             Warn_On_Suspicious_Contract         := False;
159
160          when 'u' =>
161             Warn_On_Unordered_Enumeration_Type  := True;
162
163          when 'U' =>
164             Warn_On_Unordered_Enumeration_Type  := False;
165
166          when 'v' =>
167             Warn_On_Reverse_Bit_Order           := True;
168
169          when 'V' =>
170             Warn_On_Reverse_Bit_Order           := False;
171
172          when 'w' =>
173             Warn_On_Warnings_Off                := True;
174
175          when 'W' =>
176             Warn_On_Warnings_Off                := False;
177
178          when 'x' =>
179             Warn_On_Non_Local_Exception         := True;
180
181          when 'X' =>
182             Warn_On_Non_Local_Exception         := False;
183             No_Warn_On_Non_Local_Exception      := True;
184
185          when others =>
186             return False;
187       end case;
188
189       return True;
190    end Set_Dot_Warning_Switch;
191
192    ----------------------------
193    -- Set_GNAT_Mode_Warnings --
194    ----------------------------
195
196    procedure Set_GNAT_Mode_Warnings is
197    begin
198       Address_Clause_Overlay_Warnings     := True;
199       Check_Unreferenced                  := True;
200       Check_Unreferenced_Formals          := True;
201       Check_Withs                         := True;
202       Constant_Condition_Warnings         := True;
203       Elab_Warnings                       := False;
204       Implementation_Unit_Warnings        := False;
205       Ineffective_Inline_Warnings         := True;
206       List_Inherited_Aspects              := False;
207       Warn_On_Ada_2005_Compatibility      := True;
208       Warn_On_Ada_2012_Compatibility      := True;
209       Warn_On_All_Unread_Out_Parameters   := False;
210       Warn_On_Assertion_Failure           := True;
211       Warn_On_Assumed_Low_Bound           := True;
212       Warn_On_Atomic_Synchronization      := False;
213       Warn_On_Bad_Fixed_Value             := True;
214       Warn_On_Biased_Representation       := True;
215       Warn_On_Constant                    := True;
216       Warn_On_Deleted_Code                := False;
217       Warn_On_Dereference                 := False;
218       Warn_On_Export_Import               := True;
219       Warn_On_Hiding                      := False;
220       Warn_On_Modified_Unread             := True;
221       Warn_On_No_Value_Assigned           := True;
222       Warn_On_Non_Local_Exception         := False;
223       Warn_On_Object_Renames_Function     := True;
224       Warn_On_Obsolescent_Feature         := True;
225       Warn_On_Overlap                     := True;
226       Warn_On_Overridden_Size             := True;
227       Warn_On_Parameter_Order             := True;
228       Warn_On_Questionable_Missing_Parens := True;
229       Warn_On_Record_Holes                := False;
230       Warn_On_Redundant_Constructs        := True;
231       Warn_On_Reverse_Bit_Order           := False;
232       Warn_On_Suspicious_Contract         := True;
233       Warn_On_Unchecked_Conversion        := True;
234       Warn_On_Unordered_Enumeration_Type  := False;
235       Warn_On_Unrecognized_Pragma         := True;
236       Warn_On_Unrepped_Components         := False;
237       Warn_On_Warnings_Off                := False;
238    end Set_GNAT_Mode_Warnings;
239
240    ------------------------
241    -- Set_Warning_Switch --
242    ------------------------
243
244    function Set_Warning_Switch (C : Character) return Boolean is
245    begin
246       case C is
247          when 'a' =>
248             Check_Unreferenced                  := True;
249             Check_Unreferenced_Formals          := True;
250             Check_Withs                         := True;
251             Constant_Condition_Warnings         := True;
252             Implementation_Unit_Warnings        := True;
253             Ineffective_Inline_Warnings         := True;
254             Warn_On_Ada_2005_Compatibility      := True;
255             Warn_On_Ada_2012_Compatibility      := True;
256             Warn_On_Assertion_Failure           := True;
257             Warn_On_Assumed_Low_Bound           := True;
258             Warn_On_Bad_Fixed_Value             := True;
259             Warn_On_Biased_Representation       := True;
260             Warn_On_Constant                    := True;
261             Warn_On_Export_Import               := True;
262             Warn_On_Modified_Unread             := True;
263             Warn_On_No_Value_Assigned           := True;
264             Warn_On_Non_Local_Exception         := True;
265             Warn_On_Object_Renames_Function     := True;
266             Warn_On_Obsolescent_Feature         := True;
267             Warn_On_Parameter_Order             := True;
268             Warn_On_Questionable_Missing_Parens := True;
269             Warn_On_Redundant_Constructs        := True;
270             Warn_On_Reverse_Bit_Order           := True;
271             Warn_On_Suspicious_Contract         := True;
272             Warn_On_Unchecked_Conversion        := True;
273             Warn_On_Unrecognized_Pragma         := True;
274             Warn_On_Unrepped_Components         := True;
275
276          when 'A' =>
277             Address_Clause_Overlay_Warnings     := False;
278             Check_Unreferenced                  := False;
279             Check_Unreferenced_Formals          := False;
280             Check_Withs                         := False;
281             Constant_Condition_Warnings         := False;
282             Elab_Warnings                       := False;
283             Implementation_Unit_Warnings        := False;
284             Ineffective_Inline_Warnings         := False;
285             List_Inherited_Aspects              := False;
286             Warn_On_Ada_2005_Compatibility      := False;
287             Warn_On_Ada_2012_Compatibility      := False;
288             Warn_On_All_Unread_Out_Parameters   := False;
289             Warn_On_Assertion_Failure           := False;
290             Warn_On_Assumed_Low_Bound           := False;
291             Warn_On_Bad_Fixed_Value             := False;
292             Warn_On_Biased_Representation       := False;
293             Warn_On_Constant                    := False;
294             Warn_On_Deleted_Code                := False;
295             Warn_On_Dereference                 := False;
296             Warn_On_Export_Import               := False;
297             Warn_On_Hiding                      := False;
298             Warn_On_Modified_Unread             := False;
299             Warn_On_No_Value_Assigned           := False;
300             Warn_On_Non_Local_Exception         := False;
301             Warn_On_Object_Renames_Function     := False;
302             Warn_On_Obsolescent_Feature         := False;
303             Warn_On_Overlap                     := False;
304             Warn_On_Overridden_Size             := False;
305             Warn_On_Parameter_Order             := False;
306             Warn_On_Record_Holes                := False;
307             Warn_On_Questionable_Missing_Parens := False;
308             Warn_On_Redundant_Constructs        := False;
309             Warn_On_Reverse_Bit_Order           := False;
310             Warn_On_Suspicious_Contract         := False;
311             Warn_On_Unchecked_Conversion        := False;
312             Warn_On_Unordered_Enumeration_Type  := False;
313             Warn_On_Unrecognized_Pragma         := False;
314             Warn_On_Unrepped_Components         := False;
315             Warn_On_Warnings_Off                := False;
316
317             No_Warn_On_Non_Local_Exception      := True;
318
319          when 'b' =>
320             Warn_On_Bad_Fixed_Value             := True;
321
322          when 'B' =>
323             Warn_On_Bad_Fixed_Value             := False;
324
325          when 'c' =>
326             Constant_Condition_Warnings         := True;
327
328          when 'C' =>
329             Constant_Condition_Warnings         := False;
330
331          when 'd' =>
332             Warn_On_Dereference                 := True;
333
334          when 'D' =>
335             Warn_On_Dereference                 := False;
336
337          when 'e' =>
338             Warning_Mode                        := Treat_As_Error;
339
340          when 'f' =>
341             Check_Unreferenced_Formals          := True;
342
343          when 'F' =>
344             Check_Unreferenced_Formals          := False;
345
346          when 'g' =>
347             Warn_On_Unrecognized_Pragma         := True;
348
349          when 'G' =>
350             Warn_On_Unrecognized_Pragma         := False;
351
352          when 'h' =>
353             Warn_On_Hiding                      := True;
354
355          when 'H' =>
356             Warn_On_Hiding                      := False;
357
358          when 'i' =>
359             Implementation_Unit_Warnings        := True;
360
361          when 'I' =>
362             Implementation_Unit_Warnings        := False;
363
364          when 'j' =>
365             Warn_On_Obsolescent_Feature         := True;
366
367          when 'J' =>
368             Warn_On_Obsolescent_Feature         := False;
369
370          when 'k' =>
371             Warn_On_Constant                    := True;
372
373          when 'K' =>
374             Warn_On_Constant                    := False;
375
376          when 'l' =>
377             Elab_Warnings                       := True;
378
379          when 'L' =>
380             Elab_Warnings                       := False;
381
382          when 'm' =>
383             Warn_On_Modified_Unread             := True;
384
385          when 'M' =>
386             Warn_On_Modified_Unread             := False;
387
388          when 'n' =>
389             Warning_Mode                        := Normal;
390
391          when 'o' =>
392             Address_Clause_Overlay_Warnings     := True;
393
394          when 'O' =>
395             Address_Clause_Overlay_Warnings     := False;
396
397          when 'p' =>
398             Ineffective_Inline_Warnings         := True;
399
400          when 'P' =>
401             Ineffective_Inline_Warnings         := False;
402
403          when 'q' =>
404             Warn_On_Questionable_Missing_Parens := True;
405
406          when 'Q' =>
407             Warn_On_Questionable_Missing_Parens := False;
408
409          when 'r' =>
410             Warn_On_Redundant_Constructs        := True;
411
412          when 'R' =>
413             Warn_On_Redundant_Constructs        := False;
414
415          when 's' =>
416             Warning_Mode                        := Suppress;
417
418          when 't' =>
419             Warn_On_Deleted_Code                := True;
420
421          when 'T' =>
422             Warn_On_Deleted_Code                := False;
423
424          when 'u' =>
425             Check_Unreferenced                  := True;
426             Check_Withs                         := True;
427             Check_Unreferenced_Formals          := True;
428
429          when 'U' =>
430             Check_Unreferenced                  := False;
431             Check_Withs                         := False;
432             Check_Unreferenced_Formals          := False;
433
434          when 'v' =>
435             Warn_On_No_Value_Assigned           := True;
436
437          when 'V' =>
438             Warn_On_No_Value_Assigned           := False;
439
440          when 'w' =>
441             Warn_On_Assumed_Low_Bound           := True;
442
443          when 'W' =>
444             Warn_On_Assumed_Low_Bound           := False;
445
446          when 'x' =>
447             Warn_On_Export_Import               := True;
448
449          when 'X' =>
450             Warn_On_Export_Import               := False;
451
452          when 'y' =>
453             Warn_On_Ada_2005_Compatibility      := True;
454             Warn_On_Ada_2012_Compatibility      := True;
455
456          when 'Y' =>
457             Warn_On_Ada_2005_Compatibility      := False;
458             Warn_On_Ada_2012_Compatibility      := False;
459
460          when 'z' =>
461             Warn_On_Unchecked_Conversion        := True;
462
463          when 'Z' =>
464             Warn_On_Unchecked_Conversion        := False;
465
466          when others =>
467             return False;
468       end case;
469
470       return True;
471    end Set_Warning_Switch;
472
473 end Warnsw;