This implements the -gnateu switch which causes subsequent unrecognized
style (-gnaty), warning (-gnatw), and validity (-gnatV) switches to be
ignored generating a warning message only. This is useful when compiling
a set of sources developed with a later version of the compiler using an
earlier version of the compiler (of course this earlier version must
implement the -gnateu switch).

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

2013-10-14  Robert Dewar  <de...@adacore.com>

        * gnat_ugn.texi: Document -gnateu switch.
        * opt.ads (Ignore_Unrecognized_VWY_Switches): New switch.
        * stylesw.adb: Ignore unrecognized switch if
        Ignore_Unrecognized_VWY_Switches set.
        * switch-c.adb: Implement -gnateu (sets
        Ignore_Unrecognized_VWY_Switches).
        * validsw.adb: Ignore unrecognized switch if
        Ignore_Unrecognized_VWY_Switches set.
        * warnsw.adb: Ignore unrecognized switch if
        Ignore_Unrecognized_VWY_Switches set.

Index: switch-c.adb
===================================================================
--- switch-c.adb        (revision 203521)
+++ switch-c.adb        (working copy)
@@ -717,6 +717,12 @@
 
                      return;
 
+                  --  -gnateu (unrecognized y,V,w switches)
+
+                  when 'u' =>
+                     Ptr := Ptr + 1;
+                     Ignore_Unrecognized_VWY_Switches := True;
+
                   --  -gnateV (validity checks on parameters)
 
                   when 'V' =>
Index: gnat_ugn.texi
===================================================================
--- gnat_ugn.texi       (revision 203526)
+++ gnat_ugn.texi       (working copy)
@@ -3829,6 +3829,14 @@
 @cindex @option{-gnatet} (@command{gcc})
 Generate target dependent information.
 
+@item -gnateu
+@cindex @option{-gnateu} (@command{gcc})
+Ignore unrecognized validity, warning, and style switches that
+apppear after this switch is given. This may be useful when
+compiling sources developed on a later version of the compiler
+with an earlier version. Of course the earlier version must
+support this switch.
+
 @item ^-gnateV^/PARAMETER_VALIDITY_CHECK^
 @cindex @option{-gnateV} (@command{gcc})
 Check validity of subprogram parameters.
Index: warnsw.adb
===================================================================
--- warnsw.adb  (revision 203521)
+++ warnsw.adb  (working copy)
@@ -25,6 +25,7 @@
 
 with Err_Vars; use Err_Vars;
 with Opt;      use Opt;
+with Output;   use Output;
 
 package body Warnsw is
 
@@ -386,7 +387,11 @@
             No_Warn_On_Non_Local_Exception      := True;
 
          when others =>
-            return False;
+            if Ignore_Unrecognized_VWY_Switches then
+               Write_Line ("unrecognized switch -gnatw." & C & " ignored");
+            else
+               return False;
+            end if;
       end case;
 
       return True;
@@ -672,6 +677,11 @@
             Warn_On_Unchecked_Conversion        := False;
 
          when others =>
+            if Ignore_Unrecognized_VWY_Switches then
+               Write_Line ("unrecognized switch -gnatw" & C & " ignored");
+            else
+               return False;
+            end if;
             return False;
       end case;
 
Index: stylesw.adb
===================================================================
--- stylesw.adb (revision 203521)
+++ stylesw.adb (working copy)
@@ -25,6 +25,7 @@
 
 with Hostparm; use Hostparm;
 with Opt;      use Opt;
+with Output;   use Output;
 
 package body Stylesw is
 
@@ -466,9 +467,13 @@
                null;
 
             when others =>
-               Err_Col := Err_Col - 1;
-               Bad_Style_Switch ("invalid style switch: " & C);
-               return;
+               if Ignore_Unrecognized_VWY_Switches then
+                  Write_Line ("unrecognized switch -gnaty" & C & " ignored");
+               else
+                  Err_Col := Err_Col - 1;
+                  Bad_Style_Switch ("invalid style switch: " & C);
+                  return;
+               end if;
             end case;
 
          --  Turning switches off
@@ -571,9 +576,13 @@
                null;
 
             when others =>
-               Err_Col := Err_Col - 1;
-               Bad_Style_Switch ("invalid style switch: " & C);
-               return;
+               if Ignore_Unrecognized_VWY_Switches then
+                  Write_Line ("unrecognized switch -gnaty-" & C & " ignored");
+               else
+                  Err_Col := Err_Col - 1;
+                  Bad_Style_Switch ("invalid style switch: " & C);
+                  return;
+               end if;
             end case;
          end if;
       end loop;
Index: validsw.adb
===================================================================
--- validsw.adb (revision 203521)
+++ validsw.adb (working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2001-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 2001-2013, 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- --
@@ -23,7 +23,8 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with Opt; use Opt;
+with Opt;    use Opt;
+with Output; use Output;
 
 package body Validsw is
 
@@ -229,9 +230,14 @@
                null;
 
             when others =>
-               OK      := False;
-               Err_Col := J - 1;
-               return;
+               if Ignore_Unrecognized_VWY_Switches then
+                  Write_Line ("unrecognized switch -gnatV" & C & " ignored");
+               else
+                  OK      := False;
+                  Err_Col := J - 1;
+                  return;
+               end if;
+
          end case;
       end loop;
 
Index: opt.ads
===================================================================
--- opt.ads     (revision 203521)
+++ opt.ads     (working copy)
@@ -719,6 +719,12 @@
    --  Set True to ignore all Style_Checks pragmas. Can be set True by use
    --  of -gnateY.
 
+   Ignore_Unrecognized_VWY_Switches : Boolean := False;
+   --  GNAT
+   --  Set True to ignore unrecognized y, V, w switches. Can be set True
+   --  by use of -gnateu, causing subsequent unrecognized switches to result
+   --  in a warning rather than an error.
+
    Implementation_Unit_Warnings : Boolean := True;
    --  GNAT
    --  Set True to active warnings for use of implementation internal units.

Reply via email to