OSDN Git Service

Daily bump.
[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-2012, 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_Suspicious_Modulus_Value    := False;
312             Warn_On_Unchecked_Conversion        := False;
313             Warn_On_Unordered_Enumeration_Type  := False;
314             Warn_On_Unrecognized_Pragma         := False;
315             Warn_On_Unrepped_Components         := False;
316             Warn_On_Warnings_Off                := False;
317
318             No_Warn_On_Non_Local_Exception      := True;
319
320          when 'b' =>
321             Warn_On_Bad_Fixed_Value             := True;
322
323          when 'B' =>
324             Warn_On_Bad_Fixed_Value             := False;
325
326          when 'c' =>
327             Constant_Condition_Warnings         := True;
328
329          when 'C' =>
330             Constant_Condition_Warnings         := False;
331
332          when 'd' =>
333             Warn_On_Dereference                 := True;
334
335          when 'D' =>
336             Warn_On_Dereference                 := False;
337
338          when 'e' =>
339             Warning_Mode                        := Treat_As_Error;
340
341          when 'f' =>
342             Check_Unreferenced_Formals          := True;
343
344          when 'F' =>
345             Check_Unreferenced_Formals          := False;
346
347          when 'g' =>
348             Warn_On_Unrecognized_Pragma         := True;
349
350          when 'G' =>
351             Warn_On_Unrecognized_Pragma         := False;
352
353          when 'h' =>
354             Warn_On_Hiding                      := True;
355
356          when 'H' =>
357             Warn_On_Hiding                      := False;
358
359          when 'i' =>
360             Implementation_Unit_Warnings        := True;
361
362          when 'I' =>
363             Implementation_Unit_Warnings        := False;
364
365          when 'j' =>
366             Warn_On_Obsolescent_Feature         := True;
367
368          when 'J' =>
369             Warn_On_Obsolescent_Feature         := False;
370
371          when 'k' =>
372             Warn_On_Constant                    := True;
373
374          when 'K' =>
375             Warn_On_Constant                    := False;
376
377          when 'l' =>
378             Elab_Warnings                       := True;
379
380          when 'L' =>
381             Elab_Warnings                       := False;
382
383          when 'm' =>
384             Warn_On_Modified_Unread             := True;
385
386          when 'M' =>
387             Warn_On_Modified_Unread             := False;
388
389          when 'n' =>
390             Warning_Mode                        := Normal;
391
392          when 'o' =>
393             Address_Clause_Overlay_Warnings     := True;
394
395          when 'O' =>
396             Address_Clause_Overlay_Warnings     := False;
397
398          when 'p' =>
399             Ineffective_Inline_Warnings         := True;
400
401          when 'P' =>
402             Ineffective_Inline_Warnings         := False;
403
404          when 'q' =>
405             Warn_On_Questionable_Missing_Parens := True;
406
407          when 'Q' =>
408             Warn_On_Questionable_Missing_Parens := False;
409
410          when 'r' =>
411             Warn_On_Redundant_Constructs        := True;
412
413          when 'R' =>
414             Warn_On_Redundant_Constructs        := False;
415
416          when 's' =>
417             Warning_Mode                        := Suppress;
418
419          when 't' =>
420             Warn_On_Deleted_Code                := True;
421
422          when 'T' =>
423             Warn_On_Deleted_Code                := False;
424
425          when 'u' =>
426             Check_Unreferenced                  := True;
427             Check_Withs                         := True;
428             Check_Unreferenced_Formals          := True;
429
430          when 'U' =>
431             Check_Unreferenced                  := False;
432             Check_Withs                         := False;
433             Check_Unreferenced_Formals          := False;
434
435          when 'v' =>
436             Warn_On_No_Value_Assigned           := True;
437
438          when 'V' =>
439             Warn_On_No_Value_Assigned           := False;
440
441          when 'w' =>
442             Warn_On_Assumed_Low_Bound           := True;
443
444          when 'W' =>
445             Warn_On_Assumed_Low_Bound           := False;
446
447          when 'x' =>
448             Warn_On_Export_Import               := True;
449
450          when 'X' =>
451             Warn_On_Export_Import               := False;
452
453          when 'y' =>
454             Warn_On_Ada_2005_Compatibility      := True;
455             Warn_On_Ada_2012_Compatibility      := True;
456
457          when 'Y' =>
458             Warn_On_Ada_2005_Compatibility      := False;
459             Warn_On_Ada_2012_Compatibility      := False;
460
461          when 'z' =>
462             Warn_On_Unchecked_Conversion        := True;
463
464          when 'Z' =>
465             Warn_On_Unchecked_Conversion        := False;
466
467          when others =>
468             return False;
469       end case;
470
471       return True;
472    end Set_Warning_Switch;
473
474 end Warnsw;