cfgloopmanip.c (copy_loop_info): New function.
[official-gcc.git] / gcc / ada / warnsw.adb
blob8e2b1b6a879810af1cfd48c1dbc2d742500c120a
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 ------------------------------------------------------------------------------
26 with Opt; use Opt;
28 package body Warnsw is
30 ----------------------------
31 -- Set_Dot_Warning_Switch --
32 ----------------------------
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;
40 when 'A' =>
41 Warn_On_Assertion_Failure := False;
43 when 'b' =>
44 Warn_On_Biased_Representation := True;
46 when 'B' =>
47 Warn_On_Biased_Representation := False;
49 when 'c' =>
50 Warn_On_Unrepped_Components := True;
52 when 'C' =>
53 Warn_On_Unrepped_Components := False;
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;
97 when 'g' =>
98 Set_GNAT_Mode_Warnings;
100 when 'h' =>
101 Warn_On_Record_Holes := True;
103 when 'H' =>
104 Warn_On_Record_Holes := False;
106 when 'i' =>
107 Warn_On_Overlap := True;
109 when 'I' =>
110 Warn_On_Overlap := False;
112 when 'l' =>
113 List_Inherited_Aspects := True;
115 when 'L' =>
116 List_Inherited_Aspects := False;
118 when 'm' =>
119 Warn_On_Suspicious_Modulus_Value := True;
121 when 'M' =>
122 Warn_On_Suspicious_Modulus_Value := False;
124 when 'n' =>
125 Warn_On_Atomic_Synchronization := True;
127 when 'N' =>
128 Warn_On_Atomic_Synchronization := False;
130 when 'o' =>
131 Warn_On_All_Unread_Out_Parameters := True;
133 when 'O' =>
134 Warn_On_All_Unread_Out_Parameters := False;
136 when 'p' =>
137 Warn_On_Parameter_Order := True;
139 when 'P' =>
140 Warn_On_Parameter_Order := False;
142 when 'r' =>
143 Warn_On_Object_Renames_Function := True;
145 when 'R' =>
146 Warn_On_Object_Renames_Function := False;
148 when 's' =>
149 Warn_On_Overridden_Size := True;
151 when 'S' =>
152 Warn_On_Overridden_Size := False;
154 when 't' =>
155 Warn_On_Suspicious_Contract := True;
157 when 'T' =>
158 Warn_On_Suspicious_Contract := False;
160 when 'u' =>
161 Warn_On_Unordered_Enumeration_Type := True;
163 when 'U' =>
164 Warn_On_Unordered_Enumeration_Type := False;
166 when 'v' =>
167 Warn_On_Reverse_Bit_Order := True;
169 when 'V' =>
170 Warn_On_Reverse_Bit_Order := False;
172 when 'w' =>
173 Warn_On_Warnings_Off := True;
175 when 'W' =>
176 Warn_On_Warnings_Off := False;
178 when 'x' =>
179 Warn_On_Non_Local_Exception := True;
181 when 'X' =>
182 Warn_On_Non_Local_Exception := False;
183 No_Warn_On_Non_Local_Exception := True;
185 when others =>
186 return False;
187 end case;
189 return True;
190 end Set_Dot_Warning_Switch;
192 ----------------------------
193 -- Set_GNAT_Mode_Warnings --
194 ----------------------------
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;
240 ------------------------
241 -- Set_Warning_Switch --
242 ------------------------
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;
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;
318 No_Warn_On_Non_Local_Exception := True;
320 when 'b' =>
321 Warn_On_Bad_Fixed_Value := True;
323 when 'B' =>
324 Warn_On_Bad_Fixed_Value := False;
326 when 'c' =>
327 Constant_Condition_Warnings := True;
329 when 'C' =>
330 Constant_Condition_Warnings := False;
332 when 'd' =>
333 Warn_On_Dereference := True;
335 when 'D' =>
336 Warn_On_Dereference := False;
338 when 'e' =>
339 Warning_Mode := Treat_As_Error;
341 when 'f' =>
342 Check_Unreferenced_Formals := True;
344 when 'F' =>
345 Check_Unreferenced_Formals := False;
347 when 'g' =>
348 Warn_On_Unrecognized_Pragma := True;
350 when 'G' =>
351 Warn_On_Unrecognized_Pragma := False;
353 when 'h' =>
354 Warn_On_Hiding := True;
356 when 'H' =>
357 Warn_On_Hiding := False;
359 when 'i' =>
360 Implementation_Unit_Warnings := True;
362 when 'I' =>
363 Implementation_Unit_Warnings := False;
365 when 'j' =>
366 Warn_On_Obsolescent_Feature := True;
368 when 'J' =>
369 Warn_On_Obsolescent_Feature := False;
371 when 'k' =>
372 Warn_On_Constant := True;
374 when 'K' =>
375 Warn_On_Constant := False;
377 when 'l' =>
378 Elab_Warnings := True;
380 when 'L' =>
381 Elab_Warnings := False;
383 when 'm' =>
384 Warn_On_Modified_Unread := True;
386 when 'M' =>
387 Warn_On_Modified_Unread := False;
389 when 'n' =>
390 Warning_Mode := Normal;
392 when 'o' =>
393 Address_Clause_Overlay_Warnings := True;
395 when 'O' =>
396 Address_Clause_Overlay_Warnings := False;
398 when 'p' =>
399 Ineffective_Inline_Warnings := True;
401 when 'P' =>
402 Ineffective_Inline_Warnings := False;
404 when 'q' =>
405 Warn_On_Questionable_Missing_Parens := True;
407 when 'Q' =>
408 Warn_On_Questionable_Missing_Parens := False;
410 when 'r' =>
411 Warn_On_Redundant_Constructs := True;
413 when 'R' =>
414 Warn_On_Redundant_Constructs := False;
416 when 's' =>
417 Warning_Mode := Suppress;
419 when 't' =>
420 Warn_On_Deleted_Code := True;
422 when 'T' =>
423 Warn_On_Deleted_Code := False;
425 when 'u' =>
426 Check_Unreferenced := True;
427 Check_Withs := True;
428 Check_Unreferenced_Formals := True;
430 when 'U' =>
431 Check_Unreferenced := False;
432 Check_Withs := False;
433 Check_Unreferenced_Formals := False;
435 when 'v' =>
436 Warn_On_No_Value_Assigned := True;
438 when 'V' =>
439 Warn_On_No_Value_Assigned := False;
441 when 'w' =>
442 Warn_On_Assumed_Low_Bound := True;
444 when 'W' =>
445 Warn_On_Assumed_Low_Bound := False;
447 when 'x' =>
448 Warn_On_Export_Import := True;
450 when 'X' =>
451 Warn_On_Export_Import := False;
453 when 'y' =>
454 Warn_On_Ada_2005_Compatibility := True;
455 Warn_On_Ada_2012_Compatibility := True;
457 when 'Y' =>
458 Warn_On_Ada_2005_Compatibility := False;
459 Warn_On_Ada_2012_Compatibility := False;
461 when 'z' =>
462 Warn_On_Unchecked_Conversion := True;
464 when 'Z' =>
465 Warn_On_Unchecked_Conversion := False;
467 when others =>
468 return False;
469 end case;
471 return True;
472 end Set_Warning_Switch;
474 end Warnsw;