1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1999-2013, 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 ------------------------------------------------------------------------------
26 with Err_Vars
; use Err_Vars
;
28 with Output
; use Output
;
30 package body Warnsw
is
32 ----------------------
33 -- Restore_Warnings --
34 ----------------------
36 procedure Restore_Warnings
(W
: Warning_Record
) is
38 Address_Clause_Overlay_Warnings
:=
39 W
.Address_Clause_Overlay_Warnings
;
42 Check_Unreferenced_Formals
:=
43 W
.Check_Unreferenced_Formals
;
46 Constant_Condition_Warnings
:=
47 W
.Constant_Condition_Warnings
;
52 Implementation_Unit_Warnings
:=
53 W
.Implementation_Unit_Warnings
;
54 Ineffective_Inline_Warnings
:=
55 W
.Ineffective_Inline_Warnings
;
56 List_Body_Required_Info
:=
57 W
.List_Body_Required_Info
;
58 List_Inherited_Aspects
:=
59 W
.List_Inherited_Aspects
;
62 Warn_On_Ada_2005_Compatibility
:=
63 W
.Warn_On_Ada_2005_Compatibility
;
64 Warn_On_Ada_2012_Compatibility
:=
65 W
.Warn_On_Ada_2012_Compatibility
;
66 Warn_On_All_Unread_Out_Parameters
:=
67 W
.Warn_On_All_Unread_Out_Parameters
;
68 Warn_On_Assertion_Failure
:=
69 W
.Warn_On_Assertion_Failure
;
70 Warn_On_Assumed_Low_Bound
:=
71 W
.Warn_On_Assumed_Low_Bound
;
72 Warn_On_Atomic_Synchronization
:=
73 W
.Warn_On_Atomic_Synchronization
;
74 Warn_On_Bad_Fixed_Value
:=
75 W
.Warn_On_Bad_Fixed_Value
;
76 Warn_On_Biased_Representation
:=
77 W
.Warn_On_Biased_Representation
;
80 Warn_On_Deleted_Code
:=
81 W
.Warn_On_Deleted_Code
;
82 Warn_On_Dereference
:=
83 W
.Warn_On_Dereference
;
84 Warn_On_Export_Import
:=
85 W
.Warn_On_Export_Import
;
88 Warn_On_Modified_Unread
:=
89 W
.Warn_On_Modified_Unread
;
90 Warn_On_No_Value_Assigned
:=
91 W
.Warn_On_No_Value_Assigned
;
92 Warn_On_Non_Local_Exception
:=
93 W
.Warn_On_Non_Local_Exception
;
94 Warn_On_Object_Renames_Function
:=
95 W
.Warn_On_Object_Renames_Function
;
96 Warn_On_Obsolescent_Feature
:=
97 W
.Warn_On_Obsolescent_Feature
;
100 Warn_On_Overridden_Size
:=
101 W
.Warn_On_Overridden_Size
;
102 Warn_On_Parameter_Order
:=
103 W
.Warn_On_Parameter_Order
;
104 Warn_On_Questionable_Missing_Parens
:=
105 W
.Warn_On_Questionable_Missing_Parens
;
106 Warn_On_Record_Holes
:=
107 W
.Warn_On_Record_Holes
;
108 Warn_On_Redundant_Constructs
:=
109 W
.Warn_On_Redundant_Constructs
;
110 Warn_On_Reverse_Bit_Order
:=
111 W
.Warn_On_Reverse_Bit_Order
;
112 Warn_On_Standard_Redefinition
:=
113 W
.Warn_On_Standard_Redefinition
;
114 Warn_On_Suspicious_Contract
:=
115 W
.Warn_On_Suspicious_Contract
;
116 Warn_On_Unchecked_Conversion
:=
117 W
.Warn_On_Unchecked_Conversion
;
118 Warn_On_Unordered_Enumeration_Type
:=
119 W
.Warn_On_Unordered_Enumeration_Type
;
120 Warn_On_Unrecognized_Pragma
:=
121 W
.Warn_On_Unrecognized_Pragma
;
122 Warn_On_Unrepped_Components
:=
123 W
.Warn_On_Unrepped_Components
;
124 Warn_On_Warnings_Off
:=
125 W
.Warn_On_Warnings_Off
;
126 end Restore_Warnings
;
132 function Save_Warnings
return Warning_Record
is
136 W
.Address_Clause_Overlay_Warnings
:=
137 Address_Clause_Overlay_Warnings
;
138 W
.Check_Unreferenced
:=
140 W
.Check_Unreferenced_Formals
:=
141 Check_Unreferenced_Formals
;
144 W
.Constant_Condition_Warnings
:=
145 Constant_Condition_Warnings
;
146 W
.Elab_Info_Messages
:=
150 W
.Implementation_Unit_Warnings
:=
151 Implementation_Unit_Warnings
;
152 W
.Ineffective_Inline_Warnings
:=
153 Ineffective_Inline_Warnings
;
154 W
.List_Body_Required_Info
:=
155 List_Body_Required_Info
;
156 W
.List_Inherited_Aspects
:=
157 List_Inherited_Aspects
;
158 W
.Warning_Doc_Switch
:=
160 W
.Warn_On_Ada_2005_Compatibility
:=
161 Warn_On_Ada_2005_Compatibility
;
162 W
.Warn_On_Ada_2012_Compatibility
:=
163 Warn_On_Ada_2012_Compatibility
;
164 W
.Warn_On_All_Unread_Out_Parameters
:=
165 Warn_On_All_Unread_Out_Parameters
;
166 W
.Warn_On_Assertion_Failure
:=
167 Warn_On_Assertion_Failure
;
168 W
.Warn_On_Assumed_Low_Bound
:=
169 Warn_On_Assumed_Low_Bound
;
170 W
.Warn_On_Atomic_Synchronization
:=
171 Warn_On_Atomic_Synchronization
;
172 W
.Warn_On_Bad_Fixed_Value
:=
173 Warn_On_Bad_Fixed_Value
;
174 W
.Warn_On_Biased_Representation
:=
175 Warn_On_Biased_Representation
;
176 W
.Warn_On_Constant
:=
178 W
.Warn_On_Deleted_Code
:=
179 Warn_On_Deleted_Code
;
180 W
.Warn_On_Dereference
:=
182 W
.Warn_On_Export_Import
:=
183 Warn_On_Export_Import
;
186 W
.Warn_On_Modified_Unread
:=
187 Warn_On_Modified_Unread
;
188 W
.Warn_On_No_Value_Assigned
:=
189 Warn_On_No_Value_Assigned
;
190 W
.Warn_On_Non_Local_Exception
:=
191 Warn_On_Non_Local_Exception
;
192 W
.Warn_On_Object_Renames_Function
:=
193 Warn_On_Object_Renames_Function
;
194 W
.Warn_On_Obsolescent_Feature
:=
195 Warn_On_Obsolescent_Feature
;
198 W
.Warn_On_Overridden_Size
:=
199 Warn_On_Overridden_Size
;
200 W
.Warn_On_Parameter_Order
:=
201 Warn_On_Parameter_Order
;
202 W
.Warn_On_Questionable_Missing_Parens
:=
203 Warn_On_Questionable_Missing_Parens
;
204 W
.Warn_On_Record_Holes
:=
205 Warn_On_Record_Holes
;
206 W
.Warn_On_Redundant_Constructs
:=
207 Warn_On_Redundant_Constructs
;
208 W
.Warn_On_Reverse_Bit_Order
:=
209 Warn_On_Reverse_Bit_Order
;
210 W
.Warn_On_Standard_Redefinition
:=
211 Warn_On_Standard_Redefinition
;
212 W
.Warn_On_Suspicious_Contract
:=
213 Warn_On_Suspicious_Contract
;
214 W
.Warn_On_Unchecked_Conversion
:=
215 Warn_On_Unchecked_Conversion
;
216 W
.Warn_On_Unordered_Enumeration_Type
:=
217 Warn_On_Unordered_Enumeration_Type
;
218 W
.Warn_On_Unrecognized_Pragma
:=
219 Warn_On_Unrecognized_Pragma
;
220 W
.Warn_On_Unrepped_Components
:=
221 Warn_On_Unrepped_Components
;
222 W
.Warn_On_Warnings_Off
:=
223 Warn_On_Warnings_Off
;
228 ----------------------------
229 -- Set_Dot_Warning_Switch --
230 ----------------------------
232 function Set_Dot_Warning_Switch
(C
: Character) return Boolean is
236 Warn_On_Assertion_Failure
:= True;
239 Warn_On_Assertion_Failure
:= False;
242 Warn_On_Biased_Representation
:= True;
245 Warn_On_Biased_Representation
:= False;
248 Warn_On_Unrepped_Components
:= True;
251 Warn_On_Unrepped_Components
:= False;
254 Warning_Doc_Switch
:= True;
257 Warning_Doc_Switch
:= False;
260 Address_Clause_Overlay_Warnings
:= True;
261 Check_Unreferenced
:= True;
262 Check_Unreferenced_Formals
:= True;
264 Constant_Condition_Warnings
:= True;
265 Elab_Warnings
:= True;
266 Implementation_Unit_Warnings
:= True;
267 Ineffective_Inline_Warnings
:= True;
268 List_Body_Required_Info
:= True;
269 List_Inherited_Aspects
:= True;
270 Warn_On_Ada_2005_Compatibility
:= True;
271 Warn_On_Ada_2012_Compatibility
:= True;
272 Warn_On_All_Unread_Out_Parameters
:= True;
273 Warn_On_Assertion_Failure
:= True;
274 Warn_On_Assumed_Low_Bound
:= True;
275 Warn_On_Atomic_Synchronization
:= True;
276 Warn_On_Bad_Fixed_Value
:= True;
277 Warn_On_Biased_Representation
:= True;
278 Warn_On_Constant
:= True;
279 Warn_On_Deleted_Code
:= True;
280 Warn_On_Dereference
:= True;
281 Warn_On_Export_Import
:= True;
282 Warn_On_Hiding
:= True;
283 Warn_On_Modified_Unread
:= True;
284 Warn_On_No_Value_Assigned
:= True;
285 Warn_On_Non_Local_Exception
:= True;
286 Warn_On_Object_Renames_Function
:= True;
287 Warn_On_Obsolescent_Feature
:= True;
288 Warn_On_Overlap
:= True;
289 Warn_On_Overridden_Size
:= True;
290 Warn_On_Parameter_Order
:= True;
291 Warn_On_Questionable_Missing_Parens
:= True;
292 Warn_On_Record_Holes
:= True;
293 Warn_On_Redundant_Constructs
:= True;
294 Warn_On_Reverse_Bit_Order
:= True;
295 Warn_On_Standard_Redefinition
:= True;
296 Warn_On_Suspicious_Contract
:= True;
297 Warn_On_Unchecked_Conversion
:= True;
298 Warn_On_Unordered_Enumeration_Type
:= True;
299 Warn_On_Unrecognized_Pragma
:= True;
300 Warn_On_Unrepped_Components
:= True;
301 Warn_On_Warnings_Off
:= True;
304 Set_GNAT_Mode_Warnings
;
307 Warn_On_Record_Holes
:= True;
310 Warn_On_Record_Holes
:= False;
313 Warn_On_Overlap
:= True;
316 Warn_On_Overlap
:= False;
319 Warn_On_Standard_Redefinition
:= True;
322 Warn_On_Standard_Redefinition
:= False;
325 List_Inherited_Aspects
:= True;
328 List_Inherited_Aspects
:= False;
331 Warn_On_Suspicious_Modulus_Value
:= True;
334 Warn_On_Suspicious_Modulus_Value
:= False;
337 Warn_On_Atomic_Synchronization
:= True;
340 Warn_On_Atomic_Synchronization
:= False;
343 Warn_On_All_Unread_Out_Parameters
:= True;
346 Warn_On_All_Unread_Out_Parameters
:= False;
349 Warn_On_Parameter_Order
:= True;
352 Warn_On_Parameter_Order
:= False;
355 Warn_On_Object_Renames_Function
:= True;
358 Warn_On_Object_Renames_Function
:= False;
361 Warn_On_Overridden_Size
:= True;
364 Warn_On_Overridden_Size
:= False;
367 Warn_On_Suspicious_Contract
:= True;
370 Warn_On_Suspicious_Contract
:= False;
373 Warn_On_Unordered_Enumeration_Type
:= True;
376 Warn_On_Unordered_Enumeration_Type
:= False;
379 Warn_On_Reverse_Bit_Order
:= True;
382 Warn_On_Reverse_Bit_Order
:= False;
385 Warn_On_Warnings_Off
:= True;
388 Warn_On_Warnings_Off
:= False;
391 Warn_On_Non_Local_Exception
:= True;
394 Warn_On_Non_Local_Exception
:= False;
395 No_Warn_On_Non_Local_Exception
:= True;
398 List_Body_Required_Info
:= True;
401 List_Body_Required_Info
:= False;
404 if Ignore_Unrecognized_VWY_Switches
then
405 Write_Line
("unrecognized switch -gnatw." & C
& " ignored");
412 end Set_Dot_Warning_Switch
;
414 ----------------------------
415 -- Set_GNAT_Mode_Warnings --
416 ----------------------------
418 procedure Set_GNAT_Mode_Warnings
is
420 Address_Clause_Overlay_Warnings
:= True;
421 Check_Unreferenced
:= True;
422 Check_Unreferenced_Formals
:= True;
424 Constant_Condition_Warnings
:= True;
425 Elab_Warnings
:= False;
426 Implementation_Unit_Warnings
:= False;
427 Ineffective_Inline_Warnings
:= True;
428 List_Body_Required_Info
:= False;
429 List_Inherited_Aspects
:= False;
430 Warning_Doc_Switch
:= False;
431 Warn_On_Ada_2005_Compatibility
:= True;
432 Warn_On_Ada_2012_Compatibility
:= True;
433 Warn_On_All_Unread_Out_Parameters
:= False;
434 Warn_On_Assertion_Failure
:= True;
435 Warn_On_Assumed_Low_Bound
:= True;
436 Warn_On_Atomic_Synchronization
:= False;
437 Warn_On_Bad_Fixed_Value
:= True;
438 Warn_On_Biased_Representation
:= True;
439 Warn_On_Constant
:= True;
440 Warn_On_Deleted_Code
:= False;
441 Warn_On_Dereference
:= False;
442 Warn_On_Export_Import
:= True;
443 Warn_On_Hiding
:= False;
444 Warn_On_Modified_Unread
:= True;
445 Warn_On_No_Value_Assigned
:= True;
446 Warn_On_Non_Local_Exception
:= False;
447 Warn_On_Object_Renames_Function
:= True;
448 Warn_On_Obsolescent_Feature
:= True;
449 Warn_On_Overlap
:= True;
450 Warn_On_Overridden_Size
:= True;
451 Warn_On_Parameter_Order
:= True;
452 Warn_On_Questionable_Missing_Parens
:= True;
453 Warn_On_Record_Holes
:= False;
454 Warn_On_Redundant_Constructs
:= True;
455 Warn_On_Reverse_Bit_Order
:= False;
456 Warn_On_Suspicious_Contract
:= True;
457 Warn_On_Unchecked_Conversion
:= True;
458 Warn_On_Unordered_Enumeration_Type
:= False;
459 Warn_On_Unrecognized_Pragma
:= True;
460 Warn_On_Unrepped_Components
:= False;
461 Warn_On_Warnings_Off
:= False;
462 end Set_GNAT_Mode_Warnings
;
464 ------------------------
465 -- Set_Warning_Switch --
466 ------------------------
468 function Set_Warning_Switch
(C
: Character) return Boolean is
472 Check_Unreferenced
:= True;
473 Check_Unreferenced_Formals
:= True;
475 Constant_Condition_Warnings
:= True;
476 Implementation_Unit_Warnings
:= True;
477 Ineffective_Inline_Warnings
:= True;
478 Warn_On_Ada_2005_Compatibility
:= True;
479 Warn_On_Ada_2012_Compatibility
:= True;
480 Warn_On_Assertion_Failure
:= True;
481 Warn_On_Assumed_Low_Bound
:= True;
482 Warn_On_Bad_Fixed_Value
:= True;
483 Warn_On_Biased_Representation
:= True;
484 Warn_On_Constant
:= True;
485 Warn_On_Export_Import
:= True;
486 Warn_On_Modified_Unread
:= True;
487 Warn_On_No_Value_Assigned
:= True;
488 Warn_On_Non_Local_Exception
:= True;
489 Warn_On_Object_Renames_Function
:= True;
490 Warn_On_Obsolescent_Feature
:= True;
491 Warn_On_Overlap
:= True;
492 Warn_On_Parameter_Order
:= True;
493 Warn_On_Questionable_Missing_Parens
:= True;
494 Warn_On_Redundant_Constructs
:= True;
495 Warn_On_Reverse_Bit_Order
:= True;
496 Warn_On_Suspicious_Contract
:= True;
497 Warn_On_Unchecked_Conversion
:= True;
498 Warn_On_Unrecognized_Pragma
:= True;
499 Warn_On_Unrepped_Components
:= True;
502 Address_Clause_Overlay_Warnings
:= False;
503 Check_Unreferenced
:= False;
504 Check_Unreferenced_Formals
:= False;
505 Check_Withs
:= False;
506 Constant_Condition_Warnings
:= False;
507 Elab_Warnings
:= False;
508 Implementation_Unit_Warnings
:= False;
509 Ineffective_Inline_Warnings
:= False;
510 List_Body_Required_Info
:= False;
511 List_Inherited_Aspects
:= False;
512 Warning_Doc_Switch
:= False;
513 Warn_On_Ada_2005_Compatibility
:= False;
514 Warn_On_Ada_2012_Compatibility
:= False;
515 Warn_On_All_Unread_Out_Parameters
:= False;
516 Warn_On_Assertion_Failure
:= False;
517 Warn_On_Assumed_Low_Bound
:= False;
518 Warn_On_Bad_Fixed_Value
:= False;
519 Warn_On_Biased_Representation
:= False;
520 Warn_On_Constant
:= False;
521 Warn_On_Deleted_Code
:= False;
522 Warn_On_Dereference
:= False;
523 Warn_On_Export_Import
:= False;
524 Warn_On_Hiding
:= False;
525 Warn_On_Modified_Unread
:= False;
526 Warn_On_No_Value_Assigned
:= False;
527 Warn_On_Non_Local_Exception
:= False;
528 Warn_On_Object_Renames_Function
:= False;
529 Warn_On_Obsolescent_Feature
:= False;
530 Warn_On_Overlap
:= False;
531 Warn_On_Overridden_Size
:= False;
532 Warn_On_Parameter_Order
:= False;
533 Warn_On_Record_Holes
:= False;
534 Warn_On_Questionable_Missing_Parens
:= False;
535 Warn_On_Redundant_Constructs
:= False;
536 Warn_On_Reverse_Bit_Order
:= False;
537 Warn_On_Standard_Redefinition
:= False;
538 Warn_On_Suspicious_Contract
:= False;
539 Warn_On_Suspicious_Modulus_Value
:= False;
540 Warn_On_Unchecked_Conversion
:= False;
541 Warn_On_Unordered_Enumeration_Type
:= False;
542 Warn_On_Unrecognized_Pragma
:= False;
543 Warn_On_Unrepped_Components
:= False;
544 Warn_On_Warnings_Off
:= False;
546 No_Warn_On_Non_Local_Exception
:= True;
549 Warn_On_Bad_Fixed_Value
:= True;
552 Warn_On_Bad_Fixed_Value
:= False;
555 Constant_Condition_Warnings
:= True;
558 Constant_Condition_Warnings
:= False;
561 Warn_On_Dereference
:= True;
564 Warn_On_Dereference
:= False;
567 Warning_Mode
:= Treat_As_Error
;
570 Check_Unreferenced_Formals
:= True;
573 Check_Unreferenced_Formals
:= False;
576 Warn_On_Unrecognized_Pragma
:= True;
579 Warn_On_Unrecognized_Pragma
:= False;
582 Warn_On_Hiding
:= True;
585 Warn_On_Hiding
:= False;
588 Implementation_Unit_Warnings
:= True;
591 Implementation_Unit_Warnings
:= False;
594 Warn_On_Obsolescent_Feature
:= True;
597 Warn_On_Obsolescent_Feature
:= False;
600 Warn_On_Constant
:= True;
603 Warn_On_Constant
:= False;
606 Elab_Warnings
:= True;
609 Elab_Warnings
:= False;
612 Warn_On_Modified_Unread
:= True;
615 Warn_On_Modified_Unread
:= False;
618 Warning_Mode
:= Normal
;
621 Address_Clause_Overlay_Warnings
:= True;
624 Address_Clause_Overlay_Warnings
:= False;
627 Ineffective_Inline_Warnings
:= True;
630 Ineffective_Inline_Warnings
:= False;
633 Warn_On_Questionable_Missing_Parens
:= True;
636 Warn_On_Questionable_Missing_Parens
:= False;
639 Warn_On_Redundant_Constructs
:= True;
642 Warn_On_Redundant_Constructs
:= False;
645 Warning_Mode
:= Suppress
;
648 Warn_On_Deleted_Code
:= True;
651 Warn_On_Deleted_Code
:= False;
654 Check_Unreferenced
:= True;
656 Check_Unreferenced_Formals
:= True;
659 Check_Unreferenced
:= False;
660 Check_Withs
:= False;
661 Check_Unreferenced_Formals
:= False;
664 Warn_On_No_Value_Assigned
:= True;
667 Warn_On_No_Value_Assigned
:= False;
670 Warn_On_Assumed_Low_Bound
:= True;
673 Warn_On_Assumed_Low_Bound
:= False;
676 Warn_On_Export_Import
:= True;
679 Warn_On_Export_Import
:= False;
682 Warn_On_Ada_2005_Compatibility
:= True;
683 Warn_On_Ada_2012_Compatibility
:= True;
686 Warn_On_Ada_2005_Compatibility
:= False;
687 Warn_On_Ada_2012_Compatibility
:= False;
690 Warn_On_Unchecked_Conversion
:= True;
693 Warn_On_Unchecked_Conversion
:= False;
696 if Ignore_Unrecognized_VWY_Switches
then
697 Write_Line
("unrecognized switch -gnatw" & C
& " ignored");
705 end Set_Warning_Switch
;