Implement -mmemcpy-strategy= and -mmemset-strategy= options
[official-gcc.git] / gcc / ada / warnsw.adb
blobc194b3182c1b1e43142f3a3a1110ff93571b7123
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-2013, 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 Err_Vars; use Err_Vars;
27 with Opt; use Opt;
28 with Targparm; use Targparm;
29 package body Warnsw is
31 ----------------------------
32 -- Set_Dot_Warning_Switch --
33 ----------------------------
35 function Set_Dot_Warning_Switch (C : Character) return Boolean is
36 begin
37 case C is
38 when 'a' =>
39 Warn_On_Assertion_Failure := True;
41 when 'A' =>
42 Warn_On_Assertion_Failure := False;
44 when 'b' =>
45 Warn_On_Biased_Representation := True;
47 when 'B' =>
48 Warn_On_Biased_Representation := False;
50 when 'c' =>
51 Warn_On_Unrepped_Components := True;
53 when 'C' =>
54 Warn_On_Unrepped_Components := False;
56 when 'd' =>
57 if OpenVMS_On_Target then
58 return False;
59 end if;
61 Warning_Doc_Switch := True;
63 when 'D' =>
64 if OpenVMS_On_Target then
65 return False;
66 end if;
68 Warning_Doc_Switch := False;
70 when 'e' =>
71 Address_Clause_Overlay_Warnings := True;
72 Check_Unreferenced := True;
73 Check_Unreferenced_Formals := True;
74 Check_Withs := True;
75 Constant_Condition_Warnings := True;
76 Elab_Warnings := True;
77 Implementation_Unit_Warnings := True;
78 Ineffective_Inline_Warnings := True;
79 List_Inherited_Aspects := True;
81 if not OpenVMS_On_Target then
82 Warning_Doc_Switch := True;
83 end if;
85 Warn_On_Ada_2005_Compatibility := True;
86 Warn_On_Ada_2012_Compatibility := True;
87 Warn_On_All_Unread_Out_Parameters := True;
88 Warn_On_Assertion_Failure := True;
89 Warn_On_Assumed_Low_Bound := True;
90 Warn_On_Atomic_Synchronization := True;
91 Warn_On_Bad_Fixed_Value := True;
92 Warn_On_Biased_Representation := True;
93 Warn_On_Constant := True;
94 Warn_On_Deleted_Code := True;
95 Warn_On_Dereference := True;
96 Warn_On_Export_Import := True;
97 Warn_On_Hiding := True;
98 Warn_On_Modified_Unread := True;
99 Warn_On_No_Value_Assigned := True;
100 Warn_On_Non_Local_Exception := True;
101 Warn_On_Object_Renames_Function := True;
102 Warn_On_Obsolescent_Feature := True;
103 Warn_On_Overlap := True;
104 Warn_On_Overridden_Size := True;
105 Warn_On_Parameter_Order := True;
106 Warn_On_Questionable_Missing_Parens := True;
107 Warn_On_Record_Holes := True;
108 Warn_On_Redundant_Constructs := True;
109 Warn_On_Reverse_Bit_Order := True;
110 Warn_On_Standard_Redefinition := True;
111 Warn_On_Suspicious_Contract := True;
112 Warn_On_Unchecked_Conversion := True;
113 Warn_On_Unordered_Enumeration_Type := True;
114 Warn_On_Unrecognized_Pragma := True;
115 Warn_On_Unrepped_Components := True;
116 Warn_On_Warnings_Off := True;
118 when 'g' =>
119 Set_GNAT_Mode_Warnings;
121 when 'h' =>
122 Warn_On_Record_Holes := True;
124 when 'H' =>
125 Warn_On_Record_Holes := False;
127 when 'i' =>
128 Warn_On_Overlap := True;
130 when 'I' =>
131 Warn_On_Overlap := False;
133 when 'k' =>
134 Warn_On_Standard_Redefinition := True;
136 when 'K' =>
137 Warn_On_Standard_Redefinition := False;
139 when 'l' =>
140 List_Inherited_Aspects := True;
142 when 'L' =>
143 List_Inherited_Aspects := False;
145 when 'm' =>
146 Warn_On_Suspicious_Modulus_Value := True;
148 when 'M' =>
149 Warn_On_Suspicious_Modulus_Value := False;
151 when 'n' =>
152 Warn_On_Atomic_Synchronization := True;
154 when 'N' =>
155 Warn_On_Atomic_Synchronization := False;
157 when 'o' =>
158 Warn_On_All_Unread_Out_Parameters := True;
160 when 'O' =>
161 Warn_On_All_Unread_Out_Parameters := False;
163 when 'p' =>
164 Warn_On_Parameter_Order := True;
166 when 'P' =>
167 Warn_On_Parameter_Order := False;
169 when 'r' =>
170 Warn_On_Object_Renames_Function := True;
172 when 'R' =>
173 Warn_On_Object_Renames_Function := False;
175 when 's' =>
176 Warn_On_Overridden_Size := True;
178 when 'S' =>
179 Warn_On_Overridden_Size := False;
181 when 't' =>
182 Warn_On_Suspicious_Contract := True;
184 when 'T' =>
185 Warn_On_Suspicious_Contract := False;
187 when 'u' =>
188 Warn_On_Unordered_Enumeration_Type := True;
190 when 'U' =>
191 Warn_On_Unordered_Enumeration_Type := False;
193 when 'v' =>
194 Warn_On_Reverse_Bit_Order := True;
196 when 'V' =>
197 Warn_On_Reverse_Bit_Order := False;
199 when 'w' =>
200 Warn_On_Warnings_Off := True;
202 when 'W' =>
203 Warn_On_Warnings_Off := False;
205 when 'x' =>
206 Warn_On_Non_Local_Exception := True;
208 when 'X' =>
209 Warn_On_Non_Local_Exception := False;
210 No_Warn_On_Non_Local_Exception := True;
212 when others =>
213 return False;
214 end case;
216 return True;
217 end Set_Dot_Warning_Switch;
219 ----------------------------
220 -- Set_GNAT_Mode_Warnings --
221 ----------------------------
223 procedure Set_GNAT_Mode_Warnings is
224 begin
225 Address_Clause_Overlay_Warnings := True;
226 Check_Unreferenced := True;
227 Check_Unreferenced_Formals := True;
228 Check_Withs := True;
229 Constant_Condition_Warnings := True;
230 Elab_Warnings := False;
231 Implementation_Unit_Warnings := False;
232 Ineffective_Inline_Warnings := True;
233 List_Inherited_Aspects := False;
234 Warning_Doc_Switch := False;
235 Warn_On_Ada_2005_Compatibility := True;
236 Warn_On_Ada_2012_Compatibility := True;
237 Warn_On_All_Unread_Out_Parameters := False;
238 Warn_On_Assertion_Failure := True;
239 Warn_On_Assumed_Low_Bound := True;
240 Warn_On_Atomic_Synchronization := False;
241 Warn_On_Bad_Fixed_Value := True;
242 Warn_On_Biased_Representation := True;
243 Warn_On_Constant := True;
244 Warn_On_Deleted_Code := False;
245 Warn_On_Dereference := False;
246 Warn_On_Export_Import := True;
247 Warn_On_Hiding := False;
248 Warn_On_Modified_Unread := True;
249 Warn_On_No_Value_Assigned := True;
250 Warn_On_Non_Local_Exception := False;
251 Warn_On_Object_Renames_Function := True;
252 Warn_On_Obsolescent_Feature := True;
253 Warn_On_Overlap := True;
254 Warn_On_Overridden_Size := True;
255 Warn_On_Parameter_Order := True;
256 Warn_On_Questionable_Missing_Parens := True;
257 Warn_On_Record_Holes := False;
258 Warn_On_Redundant_Constructs := True;
259 Warn_On_Reverse_Bit_Order := False;
260 Warn_On_Suspicious_Contract := True;
261 Warn_On_Unchecked_Conversion := True;
262 Warn_On_Unordered_Enumeration_Type := False;
263 Warn_On_Unrecognized_Pragma := True;
264 Warn_On_Unrepped_Components := False;
265 Warn_On_Warnings_Off := False;
266 end Set_GNAT_Mode_Warnings;
268 ------------------------
269 -- Set_Warning_Switch --
270 ------------------------
272 function Set_Warning_Switch (C : Character) return Boolean is
273 begin
274 case C is
275 when 'a' =>
276 Check_Unreferenced := True;
277 Check_Unreferenced_Formals := True;
278 Check_Withs := True;
279 Constant_Condition_Warnings := True;
280 Implementation_Unit_Warnings := True;
281 Ineffective_Inline_Warnings := True;
282 Warn_On_Ada_2005_Compatibility := True;
283 Warn_On_Ada_2012_Compatibility := True;
284 Warn_On_Assertion_Failure := True;
285 Warn_On_Assumed_Low_Bound := True;
286 Warn_On_Bad_Fixed_Value := True;
287 Warn_On_Biased_Representation := True;
288 Warn_On_Constant := True;
289 Warn_On_Export_Import := True;
290 Warn_On_Modified_Unread := True;
291 Warn_On_No_Value_Assigned := True;
292 Warn_On_Non_Local_Exception := True;
293 Warn_On_Object_Renames_Function := True;
294 Warn_On_Obsolescent_Feature := True;
295 Warn_On_Overlap := True;
296 Warn_On_Parameter_Order := True;
297 Warn_On_Questionable_Missing_Parens := True;
298 Warn_On_Redundant_Constructs := True;
299 Warn_On_Reverse_Bit_Order := True;
300 Warn_On_Suspicious_Contract := True;
301 Warn_On_Unchecked_Conversion := True;
302 Warn_On_Unrecognized_Pragma := True;
303 Warn_On_Unrepped_Components := True;
305 when 'A' =>
306 Address_Clause_Overlay_Warnings := False;
307 Check_Unreferenced := False;
308 Check_Unreferenced_Formals := False;
309 Check_Withs := False;
310 Constant_Condition_Warnings := False;
311 Elab_Warnings := False;
312 Implementation_Unit_Warnings := False;
313 Ineffective_Inline_Warnings := False;
314 List_Inherited_Aspects := False;
315 Warning_Doc_Switch := False;
316 Warn_On_Ada_2005_Compatibility := False;
317 Warn_On_Ada_2012_Compatibility := False;
318 Warn_On_All_Unread_Out_Parameters := False;
319 Warn_On_Assertion_Failure := False;
320 Warn_On_Assumed_Low_Bound := False;
321 Warn_On_Bad_Fixed_Value := False;
322 Warn_On_Biased_Representation := False;
323 Warn_On_Constant := False;
324 Warn_On_Deleted_Code := False;
325 Warn_On_Dereference := False;
326 Warn_On_Export_Import := False;
327 Warn_On_Hiding := False;
328 Warn_On_Modified_Unread := False;
329 Warn_On_No_Value_Assigned := False;
330 Warn_On_Non_Local_Exception := False;
331 Warn_On_Object_Renames_Function := False;
332 Warn_On_Obsolescent_Feature := False;
333 Warn_On_Overlap := False;
334 Warn_On_Overridden_Size := False;
335 Warn_On_Parameter_Order := False;
336 Warn_On_Record_Holes := False;
337 Warn_On_Questionable_Missing_Parens := False;
338 Warn_On_Redundant_Constructs := False;
339 Warn_On_Reverse_Bit_Order := False;
340 Warn_On_Standard_Redefinition := False;
341 Warn_On_Suspicious_Contract := False;
342 Warn_On_Suspicious_Modulus_Value := False;
343 Warn_On_Unchecked_Conversion := False;
344 Warn_On_Unordered_Enumeration_Type := False;
345 Warn_On_Unrecognized_Pragma := False;
346 Warn_On_Unrepped_Components := False;
347 Warn_On_Warnings_Off := False;
349 No_Warn_On_Non_Local_Exception := True;
351 when 'b' =>
352 Warn_On_Bad_Fixed_Value := True;
354 when 'B' =>
355 Warn_On_Bad_Fixed_Value := False;
357 when 'c' =>
358 Constant_Condition_Warnings := True;
360 when 'C' =>
361 Constant_Condition_Warnings := False;
363 when 'd' =>
364 Warn_On_Dereference := True;
366 when 'D' =>
367 Warn_On_Dereference := False;
369 when 'e' =>
370 Warning_Mode := Treat_As_Error;
372 when 'f' =>
373 Check_Unreferenced_Formals := True;
375 when 'F' =>
376 Check_Unreferenced_Formals := False;
378 when 'g' =>
379 Warn_On_Unrecognized_Pragma := True;
381 when 'G' =>
382 Warn_On_Unrecognized_Pragma := False;
384 when 'h' =>
385 Warn_On_Hiding := True;
387 when 'H' =>
388 Warn_On_Hiding := False;
390 when 'i' =>
391 Implementation_Unit_Warnings := True;
393 when 'I' =>
394 Implementation_Unit_Warnings := False;
396 when 'j' =>
397 Warn_On_Obsolescent_Feature := True;
399 when 'J' =>
400 Warn_On_Obsolescent_Feature := False;
402 when 'k' =>
403 Warn_On_Constant := True;
405 when 'K' =>
406 Warn_On_Constant := False;
408 when 'l' =>
409 Elab_Warnings := True;
411 when 'L' =>
412 Elab_Warnings := False;
414 when 'm' =>
415 Warn_On_Modified_Unread := True;
417 when 'M' =>
418 Warn_On_Modified_Unread := False;
420 when 'n' =>
421 Warning_Mode := Normal;
423 when 'o' =>
424 Address_Clause_Overlay_Warnings := True;
426 when 'O' =>
427 Address_Clause_Overlay_Warnings := False;
429 when 'p' =>
430 Ineffective_Inline_Warnings := True;
432 when 'P' =>
433 Ineffective_Inline_Warnings := False;
435 when 'q' =>
436 Warn_On_Questionable_Missing_Parens := True;
438 when 'Q' =>
439 Warn_On_Questionable_Missing_Parens := False;
441 when 'r' =>
442 Warn_On_Redundant_Constructs := True;
444 when 'R' =>
445 Warn_On_Redundant_Constructs := False;
447 when 's' =>
448 Warning_Mode := Suppress;
450 when 't' =>
451 Warn_On_Deleted_Code := True;
453 when 'T' =>
454 Warn_On_Deleted_Code := False;
456 when 'u' =>
457 Check_Unreferenced := True;
458 Check_Withs := True;
459 Check_Unreferenced_Formals := True;
461 when 'U' =>
462 Check_Unreferenced := False;
463 Check_Withs := False;
464 Check_Unreferenced_Formals := False;
466 when 'v' =>
467 Warn_On_No_Value_Assigned := True;
469 when 'V' =>
470 Warn_On_No_Value_Assigned := False;
472 when 'w' =>
473 Warn_On_Assumed_Low_Bound := True;
475 when 'W' =>
476 Warn_On_Assumed_Low_Bound := False;
478 when 'x' =>
479 Warn_On_Export_Import := True;
481 when 'X' =>
482 Warn_On_Export_Import := False;
484 when 'y' =>
485 Warn_On_Ada_2005_Compatibility := True;
486 Warn_On_Ada_2012_Compatibility := True;
488 when 'Y' =>
489 Warn_On_Ada_2005_Compatibility := False;
490 Warn_On_Ada_2012_Compatibility := False;
492 when 'z' =>
493 Warn_On_Unchecked_Conversion := True;
495 when 'Z' =>
496 Warn_On_Unchecked_Conversion := False;
498 when others =>
499 return False;
500 end case;
502 return True;
503 end Set_Warning_Switch;
505 end Warnsw;