diff mbox

[Ada] Clearer documentation of -gnatw.g and -gnatyg switches

Message ID 20140521110533.GA10428@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet May 21, 2014, 11:05 a.m. UTC
This patch provides more precise documentation of the GNAT mode warning
switch -gnatw.g and the GNAT mode style switch -gnatyg, in both the users
guide and the usage information. Documentation change only, no test needed.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-05-21  Robert Dewar  <dewar@adacore.com>

	* gnat_ugn.texi: Clearly document -gnatw.g (GNAT warnings).
	Clearly document -gnatyg (GNAT style switches).
	* usage.adb: Add line line for -gnatw.g (GNAT warnings) More
	detail for line for -gnatyg (GNAT style switches) -gnatw.d/D is
	available for VMS after all.
	* warnsw.adb: Reorganize to eliminate duplicated code
	(Restore_Warnings): Add a couple of missing entries
	(Save_Warnings): Add a couple of missing entries.
	* warnsw.ads: Add missing entries to Warning_Record (not clear
	what the impact is).
diff mbox

Patch

Index: usage.adb
===================================================================
--- usage.adb	(revision 210687)
+++ usage.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                B o d y                                   --
 --                                                                          --
---          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2014, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -121,8 +121,8 @@ 
    Write_Eol;
 
    --  Individual lines for switches. Write_Switch_Char outputs fourteen
-   --  characters, so the remaining message is allowed to be a maximum
-   --  of 65 characters to be comfortable in an 80 character window.
+   --  characters, so the remaining message is allowed to be a maximum of
+   --  65 characters to be comfortable in an 80 character window.
 
    --  Line for -gnata switch
 
@@ -494,16 +494,8 @@ 
    Write_Line ("        .C*  turn off warnings for unrepped components");
    Write_Line ("        d    turn on warnings for implicit dereference");
    Write_Line ("        D*   turn off warnings for implicit dereference");
-
-   --  Switches -gnatw.d/w.D not available on VMS
-
-   if not OpenVMS_On_Target then
-      Write_Line
-        ("        .d   turn on tagging of warnings with -gnatw switch");
-      Write_Line
-        ("        .D*  turn off tagging of warnings with -gnatw switch");
-   end if;
-
+   Write_Line ("        .d   turn on tagging of warnings with -gnatw switch");
+   Write_Line ("        .D*  turn off tagging of warnings with -gnatw switch");
    Write_Line ("        e    treat all warnings (but not info) as errors");
    Write_Line ("        .e   turn on every optional info/warning " &
                                                   "(no exceptions)");
@@ -511,6 +503,7 @@ 
    Write_Line ("        F*   turn off warnings for unreferenced formal");
    Write_Line ("        g*+  turn on warnings for unrecognized pragma");
    Write_Line ("        G    turn off warnings for unrecognized pragma");
+   Write_Line ("        .g   turn on GNAT warnings, same as Aao.sI.C.V.X");
    Write_Line ("        h    turn on warnings for hiding declarations");
    Write_Line ("        H*   turn off warnings for hiding declarations");
    Write_Line ("        .h   turn on warnings for holes in records");
@@ -640,7 +633,7 @@ 
    Write_Line ("        d    check no DOS line terminators");
    Write_Line ("        e    check end/exit labels present");
    Write_Line ("        f    check no form feeds/vertical tabs in source");
-   Write_Line ("        g    check standard GNAT style rules");
+   Write_Line ("        g    check standard GNAT style rules, same as ydISux");
    Write_Line ("        h    check no horizontal tabs in source");
    Write_Line ("        i    check if-then layout");
    Write_Line ("        I    check mode in");
Index: gnat_ugn.texi
===================================================================
--- gnat_ugn.texi	(revision 210691)
+++ gnat_ugn.texi	(working copy)
@@ -4018,7 +4018,7 @@ 
 applications programs, it is intended only for use by the compiler
 and its run-time library. For documentation, see the GNAT sources.
 Note that @option{^-gnatg^/GNAT_INTERNAL^} implies
-@option{^-gnatwae^/WARNINGS=ALL,ERRORS^} and
+@option{^-gnatw.ge^/WARNINGS=GNAT,ERRORS^} and
 @option{^-gnatyg^/STYLE_CHECKS=GNAT^}
 so that all standard warnings and all standard style options are turned on.
 All warnings and style messages are treated as errors.
@@ -5167,6 +5167,14 @@ 
 @cindex @option{-gnatwG} (@command{gcc})
 This switch suppresses warnings for unrecognized pragmas.
 
+@item -gnatw.g
+@emph{Warnings used for GNAT sources}
+@cindex @option{-gnatw.g} (@command{gcc})
+This switch sets the warning categories that are used by the standard
+GNAT style. Currently this is equivalent to
+@option{-gnatwAao.sI.C.V.X}
+but more warnings may be added in the future without advanced notice.
+
 @item -gnatwh
 @emph{Activate warnings on hiding.}
 @cindex @option{-gnatwh} (@command{gcc})
@@ -6381,7 +6389,9 @@ 
 @emph{GNAT style mode.}
 The set of style check switches is set to match that used by the GNAT sources.
 This may be useful when developing code that is eventually intended to be
-incorporated into GNAT. For further details, see GNAT sources.
+incorporated into GNAT. Currently this is equivalent to @option{-gnatwydISux})
+but additional style switches may be added to this set in the future without
+advance notice.
 
 @item ^h^HTABS^
 @emph{No horizontal tabs.}
Index: warnsw.adb
===================================================================
--- warnsw.adb	(revision 210687)
+++ warnsw.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1999-2013, Free Software Foundation, Inc.         --
+--          Copyright (C) 1999-2014, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -29,6 +29,65 @@ 
 
 package body Warnsw is
 
+   --  Local Subprograms
+
+   procedure All_Warnings (Setting : Boolean);
+   --  Sets all warnings off if Setting = False, and on if Setting = True
+
+   procedure WA_Warnings;
+   --  Turn on all warnings set by -gnatwa (also used by -gnatw.g)
+
+   ------------------
+   -- All_Warnings --
+   ------------------
+
+   procedure All_Warnings (Setting : Boolean) is
+   begin
+      Address_Clause_Overlay_Warnings     := Setting;
+      Check_Unreferenced                  := Setting;
+      Check_Unreferenced_Formals          := Setting;
+      Check_Withs                         := Setting;
+      Constant_Condition_Warnings         := Setting;
+      Elab_Warnings                       := Setting;
+      Implementation_Unit_Warnings        := Setting;
+      Ineffective_Inline_Warnings         := Setting;
+      List_Body_Required_Info             := Setting;
+      List_Inherited_Aspects              := Setting;
+      Warn_On_Ada_2005_Compatibility      := Setting;
+      Warn_On_Ada_2012_Compatibility      := Setting;
+      Warn_On_All_Unread_Out_Parameters   := Setting;
+      Warn_On_Assertion_Failure           := Setting;
+      Warn_On_Assumed_Low_Bound           := Setting;
+      Warn_On_Atomic_Synchronization      := Setting;
+      Warn_On_Bad_Fixed_Value             := Setting;
+      Warn_On_Biased_Representation       := Setting;
+      Warn_On_Constant                    := Setting;
+      Warn_On_Deleted_Code                := Setting;
+      Warn_On_Dereference                 := Setting;
+      Warn_On_Export_Import               := Setting;
+      Warn_On_Hiding                      := Setting;
+      Warn_On_Modified_Unread             := Setting;
+      Warn_On_No_Value_Assigned           := Setting;
+      Warn_On_Non_Local_Exception         := Setting;
+      Warn_On_Object_Renames_Function     := Setting;
+      Warn_On_Obsolescent_Feature         := Setting;
+      Warn_On_Overlap                     := Setting;
+      Warn_On_Overridden_Size             := Setting;
+      Warn_On_Parameter_Order             := Setting;
+      Warn_On_Questionable_Missing_Parens := Setting;
+      Warn_On_Record_Holes                := Setting;
+      Warn_On_Redundant_Constructs        := Setting;
+      Warn_On_Reverse_Bit_Order           := Setting;
+      Warn_On_Standard_Redefinition       := Setting;
+      Warn_On_Suspicious_Contract         := Setting;
+      Warn_On_Suspicious_Modulus_Value    := Setting;
+      Warn_On_Unchecked_Conversion        := Setting;
+      Warn_On_Unordered_Enumeration_Type  := Setting;
+      Warn_On_Unrecognized_Pragma         := Setting;
+      Warn_On_Unrepped_Components         := Setting;
+      Warn_On_Warnings_Off                := Setting;
+   end All_Warnings;
+
    ----------------------
    -- Restore_Warnings --
    ----------------------
@@ -57,6 +116,8 @@ 
         W.List_Body_Required_Info;
       List_Inherited_Aspects              :=
         W.List_Inherited_Aspects;
+      No_Warn_On_Non_Local_Exception      :=
+        W.No_Warn_On_Non_Local_Exception;
       Warning_Doc_Switch                  :=
         W.Warning_Doc_Switch;
       Warn_On_Ada_2005_Compatibility      :=
@@ -155,6 +216,8 @@ 
         List_Body_Required_Info;
       W.List_Inherited_Aspects              :=
         List_Inherited_Aspects;
+      W.No_Warn_On_Non_Local_Exception      :=
+        No_Warn_On_Non_Local_Exception;
       W.Warning_Doc_Switch                  :=
         Warning_Doc_Switch;
       W.Warn_On_Ada_2005_Compatibility      :=
@@ -221,7 +284,6 @@ 
         Warn_On_Unrepped_Components;
       W.Warn_On_Warnings_Off                :=
         Warn_On_Warnings_Off;
-
       return W;
    end Save_Warnings;
 
@@ -257,48 +319,7 @@ 
             Warning_Doc_Switch                  := False;
 
          when 'e' =>
-            Address_Clause_Overlay_Warnings     := True;
-            Check_Unreferenced                  := True;
-            Check_Unreferenced_Formals          := True;
-            Check_Withs                         := True;
-            Constant_Condition_Warnings         := True;
-            Elab_Warnings                       := True;
-            Implementation_Unit_Warnings        := True;
-            Ineffective_Inline_Warnings         := True;
-            List_Body_Required_Info             := True;
-            List_Inherited_Aspects              := True;
-            Warn_On_Ada_2005_Compatibility      := True;
-            Warn_On_Ada_2012_Compatibility      := True;
-            Warn_On_All_Unread_Out_Parameters   := True;
-            Warn_On_Assertion_Failure           := True;
-            Warn_On_Assumed_Low_Bound           := True;
-            Warn_On_Atomic_Synchronization      := True;
-            Warn_On_Bad_Fixed_Value             := True;
-            Warn_On_Biased_Representation       := True;
-            Warn_On_Constant                    := True;
-            Warn_On_Deleted_Code                := True;
-            Warn_On_Dereference                 := True;
-            Warn_On_Export_Import               := True;
-            Warn_On_Hiding                      := True;
-            Warn_On_Modified_Unread             := True;
-            Warn_On_No_Value_Assigned           := True;
-            Warn_On_Non_Local_Exception         := True;
-            Warn_On_Object_Renames_Function     := True;
-            Warn_On_Obsolescent_Feature         := True;
-            Warn_On_Overlap                     := True;
-            Warn_On_Overridden_Size             := True;
-            Warn_On_Parameter_Order             := True;
-            Warn_On_Questionable_Missing_Parens := True;
-            Warn_On_Record_Holes                := True;
-            Warn_On_Redundant_Constructs        := True;
-            Warn_On_Reverse_Bit_Order           := True;
-            Warn_On_Standard_Redefinition       := True;
-            Warn_On_Suspicious_Contract         := True;
-            Warn_On_Unchecked_Conversion        := True;
-            Warn_On_Unordered_Enumeration_Type  := True;
-            Warn_On_Unrecognized_Pragma         := True;
-            Warn_On_Unrepped_Components         := True;
-            Warn_On_Warnings_Off                := True;
+            All_Warnings (True);
 
          when 'g' =>
             Set_GNAT_Mode_Warnings;
@@ -417,48 +438,23 @@ 
 
    procedure Set_GNAT_Mode_Warnings is
    begin
+      --  Set -gnatwa warnings and no others
+
+      All_Warnings (False);
+      WA_Warnings;
+
+      --  These warnings are added to the -gnatwa set
+
       Address_Clause_Overlay_Warnings     := True;
-      Check_Unreferenced                  := True;
-      Check_Unreferenced_Formals          := True;
-      Check_Withs                         := True;
-      Constant_Condition_Warnings         := True;
-      Elab_Warnings                       := False;
+      Warn_On_Overridden_Size             := True;
+
+      --  These warnings are removed from the -gnatwa set
+
       Implementation_Unit_Warnings        := False;
-      Ineffective_Inline_Warnings         := True;
-      List_Body_Required_Info             := False;
-      List_Inherited_Aspects              := False;
-      Warning_Doc_Switch                  := False;
-      Warn_On_Ada_2005_Compatibility      := True;
-      Warn_On_Ada_2012_Compatibility      := True;
-      Warn_On_All_Unread_Out_Parameters   := False;
-      Warn_On_Assertion_Failure           := True;
-      Warn_On_Assumed_Low_Bound           := True;
-      Warn_On_Atomic_Synchronization      := False;
-      Warn_On_Bad_Fixed_Value             := True;
-      Warn_On_Biased_Representation       := True;
-      Warn_On_Constant                    := True;
-      Warn_On_Deleted_Code                := False;
-      Warn_On_Dereference                 := False;
-      Warn_On_Export_Import               := True;
-      Warn_On_Hiding                      := False;
-      Warn_On_Modified_Unread             := True;
-      Warn_On_No_Value_Assigned           := True;
       Warn_On_Non_Local_Exception         := False;
-      Warn_On_Object_Renames_Function     := True;
-      Warn_On_Obsolescent_Feature         := True;
-      Warn_On_Overlap                     := True;
-      Warn_On_Overridden_Size             := True;
-      Warn_On_Parameter_Order             := True;
-      Warn_On_Questionable_Missing_Parens := True;
-      Warn_On_Record_Holes                := False;
-      Warn_On_Redundant_Constructs        := True;
+      No_Warn_On_Non_Local_Exception      := True;
       Warn_On_Reverse_Bit_Order           := False;
-      Warn_On_Suspicious_Contract         := True;
-      Warn_On_Unchecked_Conversion        := True;
-      Warn_On_Unordered_Enumeration_Type  := False;
-      Warn_On_Unrecognized_Pragma         := True;
       Warn_On_Unrepped_Components         := False;
-      Warn_On_Warnings_Off                := False;
    end Set_GNAT_Mode_Warnings;
 
    ------------------------
@@ -469,80 +465,10 @@ 
    begin
       case C is
          when 'a' =>
-            Check_Unreferenced                  := True;
-            Check_Unreferenced_Formals          := True;
-            Check_Withs                         := True;
-            Constant_Condition_Warnings         := True;
-            Implementation_Unit_Warnings        := True;
-            Ineffective_Inline_Warnings         := True;
-            Warn_On_Ada_2005_Compatibility      := True;
-            Warn_On_Ada_2012_Compatibility      := True;
-            Warn_On_Assertion_Failure           := True;
-            Warn_On_Assumed_Low_Bound           := True;
-            Warn_On_Bad_Fixed_Value             := True;
-            Warn_On_Biased_Representation       := True;
-            Warn_On_Constant                    := True;
-            Warn_On_Export_Import               := True;
-            Warn_On_Modified_Unread             := True;
-            Warn_On_No_Value_Assigned           := True;
-            Warn_On_Non_Local_Exception         := True;
-            Warn_On_Object_Renames_Function     := True;
-            Warn_On_Obsolescent_Feature         := True;
-            Warn_On_Overlap                     := True;
-            Warn_On_Parameter_Order             := True;
-            Warn_On_Questionable_Missing_Parens := True;
-            Warn_On_Redundant_Constructs        := True;
-            Warn_On_Reverse_Bit_Order           := True;
-            Warn_On_Suspicious_Contract         := True;
-            Warn_On_Unchecked_Conversion        := True;
-            Warn_On_Unrecognized_Pragma         := True;
-            Warn_On_Unrepped_Components         := True;
+            WA_Warnings;
 
          when 'A' =>
-            Address_Clause_Overlay_Warnings     := False;
-            Check_Unreferenced                  := False;
-            Check_Unreferenced_Formals          := False;
-            Check_Withs                         := False;
-            Constant_Condition_Warnings         := False;
-            Elab_Warnings                       := False;
-            Implementation_Unit_Warnings        := False;
-            Ineffective_Inline_Warnings         := False;
-            List_Body_Required_Info             := False;
-            List_Inherited_Aspects              := False;
-            Warning_Doc_Switch                  := False;
-            Warn_On_Ada_2005_Compatibility      := False;
-            Warn_On_Ada_2012_Compatibility      := False;
-            Warn_On_All_Unread_Out_Parameters   := False;
-            Warn_On_Assertion_Failure           := False;
-            Warn_On_Assumed_Low_Bound           := False;
-            Warn_On_Bad_Fixed_Value             := False;
-            Warn_On_Biased_Representation       := False;
-            Warn_On_Constant                    := False;
-            Warn_On_Deleted_Code                := False;
-            Warn_On_Dereference                 := False;
-            Warn_On_Export_Import               := False;
-            Warn_On_Hiding                      := False;
-            Warn_On_Modified_Unread             := False;
-            Warn_On_No_Value_Assigned           := False;
-            Warn_On_Non_Local_Exception         := False;
-            Warn_On_Object_Renames_Function     := False;
-            Warn_On_Obsolescent_Feature         := False;
-            Warn_On_Overlap                     := False;
-            Warn_On_Overridden_Size             := False;
-            Warn_On_Parameter_Order             := False;
-            Warn_On_Record_Holes                := False;
-            Warn_On_Questionable_Missing_Parens := False;
-            Warn_On_Redundant_Constructs        := False;
-            Warn_On_Reverse_Bit_Order           := False;
-            Warn_On_Standard_Redefinition       := False;
-            Warn_On_Suspicious_Contract         := False;
-            Warn_On_Suspicious_Modulus_Value    := False;
-            Warn_On_Unchecked_Conversion        := False;
-            Warn_On_Unordered_Enumeration_Type  := False;
-            Warn_On_Unrecognized_Pragma         := False;
-            Warn_On_Unrepped_Components         := False;
-            Warn_On_Warnings_Off                := False;
-
+            All_Warnings (False);
             No_Warn_On_Non_Local_Exception      := True;
 
          when 'b' =>
@@ -704,4 +630,40 @@ 
       return True;
    end Set_Warning_Switch;
 
+   -----------------
+   -- WA_Warnings --
+   -----------------
+
+   procedure WA_Warnings is
+   begin
+      Check_Unreferenced                  := True;
+      Check_Unreferenced_Formals          := True;
+      Check_Withs                         := True;
+      Constant_Condition_Warnings         := True;
+      Implementation_Unit_Warnings        := True;
+      Ineffective_Inline_Warnings         := True;
+      Warn_On_Ada_2005_Compatibility      := True;
+      Warn_On_Ada_2012_Compatibility      := True;
+      Warn_On_Assertion_Failure           := True;
+      Warn_On_Assumed_Low_Bound           := True;
+      Warn_On_Bad_Fixed_Value             := True;
+      Warn_On_Biased_Representation       := True;
+      Warn_On_Constant                    := True;
+      Warn_On_Export_Import               := True;
+      Warn_On_Modified_Unread             := True;
+      Warn_On_No_Value_Assigned           := True;
+      Warn_On_Non_Local_Exception         := True;
+      Warn_On_Object_Renames_Function     := True;
+      Warn_On_Obsolescent_Feature         := True;
+      Warn_On_Overlap                     := True;
+      Warn_On_Parameter_Order             := True;
+      Warn_On_Questionable_Missing_Parens := True;
+      Warn_On_Redundant_Constructs        := True;
+      Warn_On_Reverse_Bit_Order           := True;
+      Warn_On_Suspicious_Contract         := True;
+      Warn_On_Unchecked_Conversion        := True;
+      Warn_On_Unrecognized_Pragma         := True;
+      Warn_On_Unrepped_Components         := True;
+   end WA_Warnings;
+
 end Warnsw;
Index: warnsw.ads
===================================================================
--- warnsw.ads	(revision 210687)
+++ warnsw.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1999-2013, Free Software Foundation, Inc.         --
+--          Copyright (C) 1999-2014, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -71,6 +71,7 @@ 
       Ineffective_Inline_Warnings         : Boolean;
       List_Body_Required_Info             : Boolean;
       List_Inherited_Aspects              : Boolean;
+      No_Warn_On_Non_Local_Exception      : Boolean;
       Warning_Doc_Switch                  : Boolean;
       Warn_On_Ada_2005_Compatibility      : Boolean;
       Warn_On_Ada_2012_Compatibility      : Boolean;
@@ -99,6 +100,7 @@ 
       Warn_On_Reverse_Bit_Order           : Boolean;
       Warn_On_Standard_Redefinition       : Boolean;
       Warn_On_Suspicious_Contract         : Boolean;
+      Warn_On_Suspicious_Modulus_Value    : Boolean;
       Warn_On_Unchecked_Conversion        : Boolean;
       Warn_On_Unordered_Enumeration_Type  : Boolean;
       Warn_On_Unrecognized_Pragma         : Boolean;