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
;
50 Implementation_Unit_Warnings
:=
51 W
.Implementation_Unit_Warnings
;
52 Ineffective_Inline_Warnings
:=
53 W
.Ineffective_Inline_Warnings
;
54 List_Body_Required_Info
:=
55 W
.List_Body_Required_Info
;
56 List_Inherited_Aspects
:=
57 W
.List_Inherited_Aspects
;
60 Warn_On_Ada_2005_Compatibility
:=
61 W
.Warn_On_Ada_2005_Compatibility
;
62 Warn_On_Ada_2012_Compatibility
:=
63 W
.Warn_On_Ada_2012_Compatibility
;
64 Warn_On_All_Unread_Out_Parameters
:=
65 W
.Warn_On_All_Unread_Out_Parameters
;
66 Warn_On_Assertion_Failure
:=
67 W
.Warn_On_Assertion_Failure
;
68 Warn_On_Assumed_Low_Bound
:=
69 W
.Warn_On_Assumed_Low_Bound
;
70 Warn_On_Atomic_Synchronization
:=
71 W
.Warn_On_Atomic_Synchronization
;
72 Warn_On_Bad_Fixed_Value
:=
73 W
.Warn_On_Bad_Fixed_Value
;
74 Warn_On_Biased_Representation
:=
75 W
.Warn_On_Biased_Representation
;
78 Warn_On_Deleted_Code
:=
79 W
.Warn_On_Deleted_Code
;
80 Warn_On_Dereference
:=
81 W
.Warn_On_Dereference
;
82 Warn_On_Export_Import
:=
83 W
.Warn_On_Export_Import
;
86 Warn_On_Modified_Unread
:=
87 W
.Warn_On_Modified_Unread
;
88 Warn_On_No_Value_Assigned
:=
89 W
.Warn_On_No_Value_Assigned
;
90 Warn_On_Non_Local_Exception
:=
91 W
.Warn_On_Non_Local_Exception
;
92 Warn_On_Object_Renames_Function
:=
93 W
.Warn_On_Object_Renames_Function
;
94 Warn_On_Obsolescent_Feature
:=
95 W
.Warn_On_Obsolescent_Feature
;
98 Warn_On_Overridden_Size
:=
99 W
.Warn_On_Overridden_Size
;
100 Warn_On_Parameter_Order
:=
101 W
.Warn_On_Parameter_Order
;
102 Warn_On_Questionable_Missing_Parens
:=
103 W
.Warn_On_Questionable_Missing_Parens
;
104 Warn_On_Record_Holes
:=
105 W
.Warn_On_Record_Holes
;
106 Warn_On_Redundant_Constructs
:=
107 W
.Warn_On_Redundant_Constructs
;
108 Warn_On_Reverse_Bit_Order
:=
109 W
.Warn_On_Reverse_Bit_Order
;
110 Warn_On_Standard_Redefinition
:=
111 W
.Warn_On_Standard_Redefinition
;
112 Warn_On_Suspicious_Contract
:=
113 W
.Warn_On_Suspicious_Contract
;
114 Warn_On_Unchecked_Conversion
:=
115 W
.Warn_On_Unchecked_Conversion
;
116 Warn_On_Unordered_Enumeration_Type
:=
117 W
.Warn_On_Unordered_Enumeration_Type
;
118 Warn_On_Unrecognized_Pragma
:=
119 W
.Warn_On_Unrecognized_Pragma
;
120 Warn_On_Unrepped_Components
:=
121 W
.Warn_On_Unrepped_Components
;
122 Warn_On_Warnings_Off
:=
123 W
.Warn_On_Warnings_Off
;
124 end Restore_Warnings
;
130 function Save_Warnings
return Warning_Record
is
134 W
.Address_Clause_Overlay_Warnings
:=
135 Address_Clause_Overlay_Warnings
;
136 W
.Check_Unreferenced
:=
138 W
.Check_Unreferenced_Formals
:=
139 Check_Unreferenced_Formals
;
142 W
.Constant_Condition_Warnings
:=
143 Constant_Condition_Warnings
;
146 W
.Implementation_Unit_Warnings
:=
147 Implementation_Unit_Warnings
;
148 W
.Ineffective_Inline_Warnings
:=
149 Ineffective_Inline_Warnings
;
150 W
.List_Body_Required_Info
:=
151 List_Body_Required_Info
;
152 W
.List_Inherited_Aspects
:=
153 List_Inherited_Aspects
;
154 W
.Warning_Doc_Switch
:=
156 W
.Warn_On_Ada_2005_Compatibility
:=
157 Warn_On_Ada_2005_Compatibility
;
158 W
.Warn_On_Ada_2012_Compatibility
:=
159 Warn_On_Ada_2012_Compatibility
;
160 W
.Warn_On_All_Unread_Out_Parameters
:=
161 Warn_On_All_Unread_Out_Parameters
;
162 W
.Warn_On_Assertion_Failure
:=
163 Warn_On_Assertion_Failure
;
164 W
.Warn_On_Assumed_Low_Bound
:=
165 Warn_On_Assumed_Low_Bound
;
166 W
.Warn_On_Atomic_Synchronization
:=
167 Warn_On_Atomic_Synchronization
;
168 W
.Warn_On_Bad_Fixed_Value
:=
169 Warn_On_Bad_Fixed_Value
;
170 W
.Warn_On_Biased_Representation
:=
171 Warn_On_Biased_Representation
;
172 W
.Warn_On_Constant
:=
174 W
.Warn_On_Deleted_Code
:=
175 Warn_On_Deleted_Code
;
176 W
.Warn_On_Dereference
:=
178 W
.Warn_On_Export_Import
:=
179 Warn_On_Export_Import
;
182 W
.Warn_On_Modified_Unread
:=
183 Warn_On_Modified_Unread
;
184 W
.Warn_On_No_Value_Assigned
:=
185 Warn_On_No_Value_Assigned
;
186 W
.Warn_On_Non_Local_Exception
:=
187 Warn_On_Non_Local_Exception
;
188 W
.Warn_On_Object_Renames_Function
:=
189 Warn_On_Object_Renames_Function
;
190 W
.Warn_On_Obsolescent_Feature
:=
191 Warn_On_Obsolescent_Feature
;
194 W
.Warn_On_Overridden_Size
:=
195 Warn_On_Overridden_Size
;
196 W
.Warn_On_Parameter_Order
:=
197 Warn_On_Parameter_Order
;
198 W
.Warn_On_Questionable_Missing_Parens
:=
199 Warn_On_Questionable_Missing_Parens
;
200 W
.Warn_On_Record_Holes
:=
201 Warn_On_Record_Holes
;
202 W
.Warn_On_Redundant_Constructs
:=
203 Warn_On_Redundant_Constructs
;
204 W
.Warn_On_Reverse_Bit_Order
:=
205 Warn_On_Reverse_Bit_Order
;
206 W
.Warn_On_Standard_Redefinition
:=
207 Warn_On_Standard_Redefinition
;
208 W
.Warn_On_Suspicious_Contract
:=
209 Warn_On_Suspicious_Contract
;
210 W
.Warn_On_Unchecked_Conversion
:=
211 Warn_On_Unchecked_Conversion
;
212 W
.Warn_On_Unordered_Enumeration_Type
:=
213 Warn_On_Unordered_Enumeration_Type
;
214 W
.Warn_On_Unrecognized_Pragma
:=
215 Warn_On_Unrecognized_Pragma
;
216 W
.Warn_On_Unrepped_Components
:=
217 Warn_On_Unrepped_Components
;
218 W
.Warn_On_Warnings_Off
:=
219 Warn_On_Warnings_Off
;
224 ----------------------------
225 -- Set_Dot_Warning_Switch --
226 ----------------------------
228 function Set_Dot_Warning_Switch
(C
: Character) return Boolean is
232 Warn_On_Assertion_Failure
:= True;
235 Warn_On_Assertion_Failure
:= False;
238 Warn_On_Biased_Representation
:= True;
241 Warn_On_Biased_Representation
:= False;
244 Warn_On_Unrepped_Components
:= True;
247 Warn_On_Unrepped_Components
:= False;
250 Warning_Doc_Switch
:= True;
253 Warning_Doc_Switch
:= False;
256 Address_Clause_Overlay_Warnings
:= True;
257 Check_Unreferenced
:= True;
258 Check_Unreferenced_Formals
:= True;
260 Constant_Condition_Warnings
:= True;
261 Elab_Warnings
:= True;
262 Implementation_Unit_Warnings
:= True;
263 Ineffective_Inline_Warnings
:= True;
264 List_Body_Required_Info
:= True;
265 List_Inherited_Aspects
:= True;
266 Warning_Doc_Switch
:= True;
267 Warn_On_Ada_2005_Compatibility
:= True;
268 Warn_On_Ada_2012_Compatibility
:= True;
269 Warn_On_All_Unread_Out_Parameters
:= True;
270 Warn_On_Assertion_Failure
:= True;
271 Warn_On_Assumed_Low_Bound
:= True;
272 Warn_On_Atomic_Synchronization
:= True;
273 Warn_On_Bad_Fixed_Value
:= True;
274 Warn_On_Biased_Representation
:= True;
275 Warn_On_Constant
:= True;
276 Warn_On_Deleted_Code
:= True;
277 Warn_On_Dereference
:= True;
278 Warn_On_Export_Import
:= True;
279 Warn_On_Hiding
:= True;
280 Warn_On_Modified_Unread
:= True;
281 Warn_On_No_Value_Assigned
:= True;
282 Warn_On_Non_Local_Exception
:= True;
283 Warn_On_Object_Renames_Function
:= True;
284 Warn_On_Obsolescent_Feature
:= True;
285 Warn_On_Overlap
:= True;
286 Warn_On_Overridden_Size
:= True;
287 Warn_On_Parameter_Order
:= True;
288 Warn_On_Questionable_Missing_Parens
:= True;
289 Warn_On_Record_Holes
:= True;
290 Warn_On_Redundant_Constructs
:= True;
291 Warn_On_Reverse_Bit_Order
:= True;
292 Warn_On_Standard_Redefinition
:= True;
293 Warn_On_Suspicious_Contract
:= True;
294 Warn_On_Unchecked_Conversion
:= True;
295 Warn_On_Unordered_Enumeration_Type
:= True;
296 Warn_On_Unrecognized_Pragma
:= True;
297 Warn_On_Unrepped_Components
:= True;
298 Warn_On_Warnings_Off
:= True;
301 Set_GNAT_Mode_Warnings
;
304 Warn_On_Record_Holes
:= True;
307 Warn_On_Record_Holes
:= False;
310 Warn_On_Overlap
:= True;
313 Warn_On_Overlap
:= False;
316 Warn_On_Standard_Redefinition
:= True;
319 Warn_On_Standard_Redefinition
:= False;
322 List_Inherited_Aspects
:= True;
325 List_Inherited_Aspects
:= False;
328 Warn_On_Suspicious_Modulus_Value
:= True;
331 Warn_On_Suspicious_Modulus_Value
:= False;
334 Warn_On_Atomic_Synchronization
:= True;
337 Warn_On_Atomic_Synchronization
:= False;
340 Warn_On_All_Unread_Out_Parameters
:= True;
343 Warn_On_All_Unread_Out_Parameters
:= False;
346 Warn_On_Parameter_Order
:= True;
349 Warn_On_Parameter_Order
:= False;
352 Warn_On_Object_Renames_Function
:= True;
355 Warn_On_Object_Renames_Function
:= False;
358 Warn_On_Overridden_Size
:= True;
361 Warn_On_Overridden_Size
:= False;
364 Warn_On_Suspicious_Contract
:= True;
367 Warn_On_Suspicious_Contract
:= False;
370 Warn_On_Unordered_Enumeration_Type
:= True;
373 Warn_On_Unordered_Enumeration_Type
:= False;
376 Warn_On_Reverse_Bit_Order
:= True;
379 Warn_On_Reverse_Bit_Order
:= False;
382 Warn_On_Warnings_Off
:= True;
385 Warn_On_Warnings_Off
:= False;
388 Warn_On_Non_Local_Exception
:= True;
391 Warn_On_Non_Local_Exception
:= False;
392 No_Warn_On_Non_Local_Exception
:= True;
395 List_Body_Required_Info
:= True;
398 List_Body_Required_Info
:= False;
401 if Ignore_Unrecognized_VWY_Switches
then
402 Write_Line
("unrecognized switch -gnatw." & C
& " ignored");
409 end Set_Dot_Warning_Switch
;
411 ----------------------------
412 -- Set_GNAT_Mode_Warnings --
413 ----------------------------
415 procedure Set_GNAT_Mode_Warnings
is
417 Address_Clause_Overlay_Warnings
:= True;
418 Check_Unreferenced
:= True;
419 Check_Unreferenced_Formals
:= True;
421 Constant_Condition_Warnings
:= True;
422 Elab_Warnings
:= False;
423 Implementation_Unit_Warnings
:= False;
424 Ineffective_Inline_Warnings
:= True;
425 List_Body_Required_Info
:= False;
426 List_Inherited_Aspects
:= False;
427 Warning_Doc_Switch
:= False;
428 Warn_On_Ada_2005_Compatibility
:= True;
429 Warn_On_Ada_2012_Compatibility
:= True;
430 Warn_On_All_Unread_Out_Parameters
:= False;
431 Warn_On_Assertion_Failure
:= True;
432 Warn_On_Assumed_Low_Bound
:= True;
433 Warn_On_Atomic_Synchronization
:= False;
434 Warn_On_Bad_Fixed_Value
:= True;
435 Warn_On_Biased_Representation
:= True;
436 Warn_On_Constant
:= True;
437 Warn_On_Deleted_Code
:= False;
438 Warn_On_Dereference
:= False;
439 Warn_On_Export_Import
:= True;
440 Warn_On_Hiding
:= False;
441 Warn_On_Modified_Unread
:= True;
442 Warn_On_No_Value_Assigned
:= True;
443 Warn_On_Non_Local_Exception
:= False;
444 Warn_On_Object_Renames_Function
:= True;
445 Warn_On_Obsolescent_Feature
:= True;
446 Warn_On_Overlap
:= True;
447 Warn_On_Overridden_Size
:= True;
448 Warn_On_Parameter_Order
:= True;
449 Warn_On_Questionable_Missing_Parens
:= True;
450 Warn_On_Record_Holes
:= False;
451 Warn_On_Redundant_Constructs
:= True;
452 Warn_On_Reverse_Bit_Order
:= False;
453 Warn_On_Suspicious_Contract
:= True;
454 Warn_On_Unchecked_Conversion
:= True;
455 Warn_On_Unordered_Enumeration_Type
:= False;
456 Warn_On_Unrecognized_Pragma
:= True;
457 Warn_On_Unrepped_Components
:= False;
458 Warn_On_Warnings_Off
:= False;
459 end Set_GNAT_Mode_Warnings
;
461 ------------------------
462 -- Set_Warning_Switch --
463 ------------------------
465 function Set_Warning_Switch
(C
: Character) return Boolean is
469 Check_Unreferenced
:= True;
470 Check_Unreferenced_Formals
:= True;
472 Constant_Condition_Warnings
:= True;
473 Implementation_Unit_Warnings
:= True;
474 Ineffective_Inline_Warnings
:= True;
475 Warn_On_Ada_2005_Compatibility
:= True;
476 Warn_On_Ada_2012_Compatibility
:= True;
477 Warn_On_Assertion_Failure
:= True;
478 Warn_On_Assumed_Low_Bound
:= True;
479 Warn_On_Bad_Fixed_Value
:= True;
480 Warn_On_Biased_Representation
:= True;
481 Warn_On_Constant
:= True;
482 Warn_On_Export_Import
:= True;
483 Warn_On_Modified_Unread
:= True;
484 Warn_On_No_Value_Assigned
:= True;
485 Warn_On_Non_Local_Exception
:= True;
486 Warn_On_Object_Renames_Function
:= True;
487 Warn_On_Obsolescent_Feature
:= True;
488 Warn_On_Overlap
:= True;
489 Warn_On_Parameter_Order
:= True;
490 Warn_On_Questionable_Missing_Parens
:= True;
491 Warn_On_Redundant_Constructs
:= True;
492 Warn_On_Reverse_Bit_Order
:= True;
493 Warn_On_Suspicious_Contract
:= True;
494 Warn_On_Unchecked_Conversion
:= True;
495 Warn_On_Unrecognized_Pragma
:= True;
496 Warn_On_Unrepped_Components
:= True;
499 Address_Clause_Overlay_Warnings
:= False;
500 Check_Unreferenced
:= False;
501 Check_Unreferenced_Formals
:= False;
502 Check_Withs
:= False;
503 Constant_Condition_Warnings
:= False;
504 Elab_Warnings
:= False;
505 Implementation_Unit_Warnings
:= False;
506 Ineffective_Inline_Warnings
:= False;
507 List_Body_Required_Info
:= False;
508 List_Inherited_Aspects
:= False;
509 Warning_Doc_Switch
:= False;
510 Warn_On_Ada_2005_Compatibility
:= False;
511 Warn_On_Ada_2012_Compatibility
:= False;
512 Warn_On_All_Unread_Out_Parameters
:= False;
513 Warn_On_Assertion_Failure
:= False;
514 Warn_On_Assumed_Low_Bound
:= False;
515 Warn_On_Bad_Fixed_Value
:= False;
516 Warn_On_Biased_Representation
:= False;
517 Warn_On_Constant
:= False;
518 Warn_On_Deleted_Code
:= False;
519 Warn_On_Dereference
:= False;
520 Warn_On_Export_Import
:= False;
521 Warn_On_Hiding
:= False;
522 Warn_On_Modified_Unread
:= False;
523 Warn_On_No_Value_Assigned
:= False;
524 Warn_On_Non_Local_Exception
:= False;
525 Warn_On_Object_Renames_Function
:= False;
526 Warn_On_Obsolescent_Feature
:= False;
527 Warn_On_Overlap
:= False;
528 Warn_On_Overridden_Size
:= False;
529 Warn_On_Parameter_Order
:= False;
530 Warn_On_Record_Holes
:= False;
531 Warn_On_Questionable_Missing_Parens
:= False;
532 Warn_On_Redundant_Constructs
:= False;
533 Warn_On_Reverse_Bit_Order
:= False;
534 Warn_On_Standard_Redefinition
:= False;
535 Warn_On_Suspicious_Contract
:= False;
536 Warn_On_Suspicious_Modulus_Value
:= False;
537 Warn_On_Unchecked_Conversion
:= False;
538 Warn_On_Unordered_Enumeration_Type
:= False;
539 Warn_On_Unrecognized_Pragma
:= False;
540 Warn_On_Unrepped_Components
:= False;
541 Warn_On_Warnings_Off
:= False;
543 No_Warn_On_Non_Local_Exception
:= True;
546 Warn_On_Bad_Fixed_Value
:= True;
549 Warn_On_Bad_Fixed_Value
:= False;
552 Constant_Condition_Warnings
:= True;
555 Constant_Condition_Warnings
:= False;
558 Warn_On_Dereference
:= True;
561 Warn_On_Dereference
:= False;
564 Warning_Mode
:= Treat_As_Error
;
567 Check_Unreferenced_Formals
:= True;
570 Check_Unreferenced_Formals
:= False;
573 Warn_On_Unrecognized_Pragma
:= True;
576 Warn_On_Unrecognized_Pragma
:= False;
579 Warn_On_Hiding
:= True;
582 Warn_On_Hiding
:= False;
585 Implementation_Unit_Warnings
:= True;
588 Implementation_Unit_Warnings
:= False;
591 Warn_On_Obsolescent_Feature
:= True;
594 Warn_On_Obsolescent_Feature
:= False;
597 Warn_On_Constant
:= True;
600 Warn_On_Constant
:= False;
603 Elab_Warnings
:= True;
606 Elab_Warnings
:= False;
609 Warn_On_Modified_Unread
:= True;
612 Warn_On_Modified_Unread
:= False;
615 Warning_Mode
:= Normal
;
618 Address_Clause_Overlay_Warnings
:= True;
621 Address_Clause_Overlay_Warnings
:= False;
624 Ineffective_Inline_Warnings
:= True;
627 Ineffective_Inline_Warnings
:= False;
630 Warn_On_Questionable_Missing_Parens
:= True;
633 Warn_On_Questionable_Missing_Parens
:= False;
636 Warn_On_Redundant_Constructs
:= True;
639 Warn_On_Redundant_Constructs
:= False;
642 Warning_Mode
:= Suppress
;
645 Warn_On_Deleted_Code
:= True;
648 Warn_On_Deleted_Code
:= False;
651 Check_Unreferenced
:= True;
653 Check_Unreferenced_Formals
:= True;
656 Check_Unreferenced
:= False;
657 Check_Withs
:= False;
658 Check_Unreferenced_Formals
:= False;
661 Warn_On_No_Value_Assigned
:= True;
664 Warn_On_No_Value_Assigned
:= False;
667 Warn_On_Assumed_Low_Bound
:= True;
670 Warn_On_Assumed_Low_Bound
:= False;
673 Warn_On_Export_Import
:= True;
676 Warn_On_Export_Import
:= False;
679 Warn_On_Ada_2005_Compatibility
:= True;
680 Warn_On_Ada_2012_Compatibility
:= True;
683 Warn_On_Ada_2005_Compatibility
:= False;
684 Warn_On_Ada_2012_Compatibility
:= False;
687 Warn_On_Unchecked_Conversion
:= True;
690 Warn_On_Unchecked_Conversion
:= False;
693 if Ignore_Unrecognized_VWY_Switches
then
694 Write_Line
("unrecognized switch -gnatw" & C
& " ignored");
702 end Set_Warning_Switch
;