diff mbox series

[Ada] No room for new warning switches

Message ID 20170908133142.GA87409@adacore.com
State New
Headers show
Series [Ada] No room for new warning switches | expand

Commit Message

Arnaud Charlet Sept. 8, 2017, 1:31 p.m. UTC
This patch adds machinary to create new warning flags using the underscore
"_" prefix. This is necessary because all letters of the alphabet and letters
prefixed with a dot "." are used already.

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

2017-09-08  Justin Squirek  <squirek@adacore.com>

	* switch-c.adb (Scan_Front_End_Switches): Add new warning switch
	case to handle underscore flags.
	* warnsw.adb, warnsw.ads (Set_Underscore_Warning_Switch): Create
	new procedure to handle underscores.
diff mbox series

Patch

Index: switch-c.adb
===================================================================
--- switch-c.adb	(revision 251892)
+++ switch-c.adb	(working copy)
@@ -1268,8 +1268,20 @@ 
                         Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
                      end if;
 
-                     --  Normal case, no dot
+                  --  Case of underscore switch
 
+                  elsif C = '_' and then Ptr < Max then
+                     Ptr := Ptr + 1;
+                     C := Switch_Chars (Ptr);
+
+                     if Set_Underscore_Warning_Switch (C) then
+                        Store_Compilation_Switch ("-gnatw_" & C);
+                     else
+                        Bad_Switch ("-gnatw_" & Switch_Chars (Ptr .. Max));
+                     end if;
+
+                  --  Normal case, no dot
+
                   else
                      if Set_Warning_Switch (C) then
                         Store_Compilation_Switch ("-gnatw" & C);
Index: warnsw.adb
===================================================================
--- warnsw.adb	(revision 251892)
+++ warnsw.adb	(working copy)
@@ -471,6 +471,24 @@ 
       return True;
    end Set_Dot_Warning_Switch;
 
+   -----------------------------------
+   -- Set_Underscore_Warning_Switch --
+   -----------------------------------
+
+   function Set_Underscore_Warning_Switch (C : Character) return Boolean is
+   begin
+      case C is
+         when others =>
+            if Ignore_Unrecognized_VWY_Switches then
+               Write_Line ("unrecognized switch -gnatw_" & C & " ignored");
+            else
+               return False;
+            end if;
+      end case;
+
+      return True;
+   end Set_Underscore_Warning_Switch;
+
    ----------------------------
    -- Set_GNAT_Mode_Warnings --
    ----------------------------
Index: warnsw.ads
===================================================================
--- warnsw.ads	(revision 251892)
+++ warnsw.ads	(working copy)
@@ -147,6 +147,13 @@ 
    --  the command line or .C in a string literal in pragma Warnings. Returns
    --  True for valid warning character C, False for invalid character.
 
+   function Set_Underscore_Warning_Switch (C : Character) return Boolean;
+   --  This function sets the warning switch or switches corresponding to the
+   --  given character preceded by an underscore. Used to process a -gnatw_
+   --  switch on the command line or _C in a string literal in pragma Warnings.
+   --  Returns True for valid warnings character C, False for invalid
+   --  character.
+
    procedure Set_GNAT_Mode_Warnings;
    --  This is called in -gnatg mode to set the warnings for gnat mode. It is
    --  also used to set the proper warning statuses for -gnatw.g. Note that