1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1999-2011, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
28 package body Warnsw is
30 ----------------------------
31 -- Set_Dot_Warning_Switch --
32 ----------------------------
34 function Set_Dot_Warning_Switch (C : Character) return Boolean is
38 Warn_On_Assertion_Failure := True;
41 Warn_On_Assertion_Failure := False;
44 Warn_On_Biased_Representation := True;
47 Warn_On_Biased_Representation := False;
50 Warn_On_Unrepped_Components := True;
53 Warn_On_Unrepped_Components := False;
56 Address_Clause_Overlay_Warnings := True;
57 Check_Unreferenced := True;
58 Check_Unreferenced_Formals := 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;
98 Set_GNAT_Mode_Warnings;
101 Warn_On_Record_Holes := True;
104 Warn_On_Record_Holes := False;
107 Warn_On_Overlap := True;
110 Warn_On_Overlap := False;
113 List_Inherited_Aspects := True;
116 List_Inherited_Aspects := False;
119 Warn_On_Suspicious_Modulus_Value := True;
122 Warn_On_Suspicious_Modulus_Value := False;
125 Warn_On_Atomic_Synchronization := True;
128 Warn_On_Atomic_Synchronization := False;
131 Warn_On_All_Unread_Out_Parameters := True;
134 Warn_On_All_Unread_Out_Parameters := False;
137 Warn_On_Parameter_Order := True;
140 Warn_On_Parameter_Order := False;
143 Warn_On_Object_Renames_Function := True;
146 Warn_On_Object_Renames_Function := False;
149 Warn_On_Overridden_Size := True;
152 Warn_On_Overridden_Size := False;
155 Warn_On_Suspicious_Contract := True;
158 Warn_On_Suspicious_Contract := False;
161 Warn_On_Unordered_Enumeration_Type := True;
164 Warn_On_Unordered_Enumeration_Type := False;
167 Warn_On_Reverse_Bit_Order := True;
170 Warn_On_Reverse_Bit_Order := False;
173 Warn_On_Warnings_Off := True;
176 Warn_On_Warnings_Off := False;
179 Warn_On_Non_Local_Exception := True;
182 Warn_On_Non_Local_Exception := False;
183 No_Warn_On_Non_Local_Exception := True;
190 end Set_Dot_Warning_Switch;
192 ----------------------------
193 -- Set_GNAT_Mode_Warnings --
194 ----------------------------
196 procedure Set_GNAT_Mode_Warnings is
198 Address_Clause_Overlay_Warnings := True;
199 Check_Unreferenced := True;
200 Check_Unreferenced_Formals := 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
248 Check_Unreferenced := True;
249 Check_Unreferenced_Formals := 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;
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;
317 No_Warn_On_Non_Local_Exception := True;
320 Warn_On_Bad_Fixed_Value := True;
323 Warn_On_Bad_Fixed_Value := False;
326 Constant_Condition_Warnings := True;
329 Constant_Condition_Warnings := False;
332 Warn_On_Dereference := True;
335 Warn_On_Dereference := False;
338 Warning_Mode := Treat_As_Error;
341 Check_Unreferenced_Formals := True;
344 Check_Unreferenced_Formals := False;
347 Warn_On_Unrecognized_Pragma := True;
350 Warn_On_Unrecognized_Pragma := False;
353 Warn_On_Hiding := True;
356 Warn_On_Hiding := False;
359 Implementation_Unit_Warnings := True;
362 Implementation_Unit_Warnings := False;
365 Warn_On_Obsolescent_Feature := True;
368 Warn_On_Obsolescent_Feature := False;
371 Warn_On_Constant := True;
374 Warn_On_Constant := False;
377 Elab_Warnings := True;
380 Elab_Warnings := False;
383 Warn_On_Modified_Unread := True;
386 Warn_On_Modified_Unread := False;
389 Warning_Mode := Normal;
392 Address_Clause_Overlay_Warnings := True;
395 Address_Clause_Overlay_Warnings := False;
398 Ineffective_Inline_Warnings := True;
401 Ineffective_Inline_Warnings := False;
404 Warn_On_Questionable_Missing_Parens := True;
407 Warn_On_Questionable_Missing_Parens := False;
410 Warn_On_Redundant_Constructs := True;
413 Warn_On_Redundant_Constructs := False;
416 Warning_Mode := Suppress;
419 Warn_On_Deleted_Code := True;
422 Warn_On_Deleted_Code := False;
425 Check_Unreferenced := True;
427 Check_Unreferenced_Formals := True;
430 Check_Unreferenced := False;
431 Check_Withs := False;
432 Check_Unreferenced_Formals := False;
435 Warn_On_No_Value_Assigned := True;
438 Warn_On_No_Value_Assigned := False;
441 Warn_On_Assumed_Low_Bound := True;
444 Warn_On_Assumed_Low_Bound := False;
447 Warn_On_Export_Import := True;
450 Warn_On_Export_Import := False;
453 Warn_On_Ada_2005_Compatibility := True;
454 Warn_On_Ada_2012_Compatibility := True;
457 Warn_On_Ada_2005_Compatibility := False;
458 Warn_On_Ada_2012_Compatibility := False;
461 Warn_On_Unchecked_Conversion := True;
464 Warn_On_Unchecked_Conversion := False;
471 end Set_Warning_Switch;