1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT COMPILER COMPONENTS                         --
4--                                                                          --
5--                               W A R N S W                                --
6--                                                                          --
7--                                 S p e c                                  --
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------------------------------------------------------------------------------
25
26--  This unit contains the routines used to handle setting of warning options
27
28package Warnsw is
29
30   -------------------
31   -- Warning Flags --
32   -------------------
33
34   --  These flags are activated or deactivated by -gnatw switches and control
35   --  whether warnings of a given class will be generated or not.
36
37   --  Note: most of these flags are still in opt, but the plan is to move them
38   --  here as time goes by. And in fact a really nice idea would be to put
39   --  them all in a Warn_Record so that they would be easy to save/restore.
40
41   Warn_On_Record_Holes : Boolean := False;
42   --  Warn when explicit record component clauses leave uncovered holes (gaps)
43   --  in a record layout. Off by default, set by -gnatw.h (but not -gnatwa).
44
45   Warn_On_Overridden_Size : Boolean := False;
46   --  Warn when explicit record component clause or array component_size
47   --  clause specifies a size that overrides a size for the typen which was
48   --  set with an explicit size clause. Off by default, modified by use of
49   --  -gnatw.s/.S, but not set by -gnatwa.
50
51   Warn_On_Standard_Redefinition : Boolean := False;
52   --  Warn when a program defines an identifier that matches a name in
53   --  Standard. Off by default, modified by use of -gnatw.k/.K, but not
54   --  affected by -gnatwa.
55
56   -----------------------------------
57   -- Saving and Restoring Warnings --
58   -----------------------------------
59
60   --  Type used to save and restore warnings
61
62   type Warning_Record is record
63      Address_Clause_Overlay_Warnings     : Boolean;
64      Check_Unreferenced                  : Boolean;
65      Check_Unreferenced_Formals          : Boolean;
66      Check_Withs                         : Boolean;
67      Constant_Condition_Warnings         : Boolean;
68      Elab_Info_Messages                  : Boolean;
69      Elab_Warnings                       : Boolean;
70      Implementation_Unit_Warnings        : Boolean;
71      Ineffective_Inline_Warnings         : Boolean;
72      List_Body_Required_Info             : Boolean;
73      List_Inherited_Aspects              : Boolean;
74      Warning_Doc_Switch                  : Boolean;
75      Warn_On_Ada_2005_Compatibility      : Boolean;
76      Warn_On_Ada_2012_Compatibility      : Boolean;
77      Warn_On_All_Unread_Out_Parameters   : Boolean;
78      Warn_On_Assertion_Failure           : Boolean;
79      Warn_On_Assumed_Low_Bound           : Boolean;
80      Warn_On_Atomic_Synchronization      : Boolean;
81      Warn_On_Bad_Fixed_Value             : Boolean;
82      Warn_On_Biased_Representation       : Boolean;
83      Warn_On_Constant                    : Boolean;
84      Warn_On_Deleted_Code                : Boolean;
85      Warn_On_Dereference                 : Boolean;
86      Warn_On_Export_Import               : Boolean;
87      Warn_On_Hiding                      : Boolean;
88      Warn_On_Modified_Unread             : Boolean;
89      Warn_On_No_Value_Assigned           : Boolean;
90      Warn_On_Non_Local_Exception         : Boolean;
91      Warn_On_Object_Renames_Function     : Boolean;
92      Warn_On_Obsolescent_Feature         : Boolean;
93      Warn_On_Overlap                     : Boolean;
94      Warn_On_Overridden_Size             : Boolean;
95      Warn_On_Parameter_Order             : Boolean;
96      Warn_On_Questionable_Missing_Parens : Boolean;
97      Warn_On_Record_Holes                : Boolean;
98      Warn_On_Redundant_Constructs        : Boolean;
99      Warn_On_Reverse_Bit_Order           : Boolean;
100      Warn_On_Standard_Redefinition       : Boolean;
101      Warn_On_Suspicious_Contract         : Boolean;
102      Warn_On_Unchecked_Conversion        : Boolean;
103      Warn_On_Unordered_Enumeration_Type  : Boolean;
104      Warn_On_Unrecognized_Pragma         : Boolean;
105      Warn_On_Unrepped_Components         : Boolean;
106      Warn_On_Warnings_Off                : Boolean;
107   end record;
108
109   function Save_Warnings return Warning_Record;
110   --  Returns current settingh of warnings
111
112   procedure Restore_Warnings (W : Warning_Record);
113   --  Restores current settings of warning flags from W
114
115   -----------------
116   -- Subprograms --
117   -----------------
118
119   function Set_Warning_Switch (C : Character) return Boolean;
120   --  This function sets the warning switch or switches corresponding to the
121   --  given character. It is used to process a -gnatw switch on the command
122   --  line, or a character in a string literal in pragma Warnings. Returns
123   --  True for valid warning character C, False for invalid character.
124
125   function Set_Dot_Warning_Switch (C : Character) return Boolean;
126   --  This function sets the warning switch or switches corresponding to the
127   --  given character preceded by a dot. Used to process a -gnatw. switch on
128   --  the command line or .C in a string literal in pragma Warnings. Returns
129   --  True for valid warning character C, False for invalid character.
130
131   procedure Set_GNAT_Mode_Warnings;
132   --  This is called in -gnatg mode to set the warnings for gnat mode. It is
133   --  also used to set the proper warning statuses for -gnatw.g. Note that
134   --  this set of warnings is disjoint from -gnatwa, it enables warnings that
135   --  are not included in -gnatwa, and it disables warnings that are included
136   --  in -gnatwa (such as Warn_On_Implementation_Units, which we clearly want
137   --  to be False for units built with -gnatg).
138
139end Warnsw;
140