diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index cc7bcf97e15bb3235a3e48cb9ce8c424e5cc3c5c..fe58ae8d6d1c604650fd3dec22a180e4fafe811b 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,25 @@
+2009-04-09  Robert Dewar  <dewar@adacore.com>
+
+	* binderr.adb, errout.adb, errutil.adb: New circuitry for handling
+	Maximum_Messages.
+	
+	* erroutc.adb, erroutc.ads (Warnings_Suppressed): Now tests global
+	warning status as well.
+	
+	* opt.ads (Maximum_Messages): New name for Maximum_Errors.
+	
+	* switch-b.adb, switch-c.adb: Change name Maximum_Errors to
+	Maximum_Messages.
+	
+	* bindusg.adb, usage.adb: Update line for -gnatm switch
+
+	* gnat_ugn.texi: Update documentation for -gnatmnn compiler switch and
+	-mnn binder switch.
+
+2009-04-09  Robert Dewar  <dewar@adacore.com>
+
+	* sem_ch10.adb: Minor reformatting.
+
 2009-04-09  Bob Duff  <duff@adacore.com>
 
 	* exp_ch11.adb (Expand_Exception_Handlers, Prepend_Call_To_Handler):
diff --git a/gcc/ada/binderr.adb b/gcc/ada/binderr.adb
index 4f90ee68f030e474b3da9259bb339c217aa27efd..830a2f177150a8f2f54feac5735ab809e3342b4c 100644
--- a/gcc/ada/binderr.adb
+++ b/gcc/ada/binderr.adb
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2007, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2008, 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- --
@@ -64,10 +64,24 @@ package body Binderr is
          Error_Msg_Output (Msg, Info => False);
       end if;
 
-      if Warnings_Detected + Errors_Detected > Maximum_Errors then
-         raise Unrecoverable_Error;
+      --  If too many warnings print message and then turn off warnings
+
+      if Warnings_Detected = Maximum_Messages then
+         Set_Standard_Error;
+         Write_Line ("maximum number of warnings reached");
+         Write_Line ("further warnings will be suppressed");
+         Set_Standard_Output;
+         Warning_Mode := Suppress;
       end if;
 
+      --  If too many errors print message and give fatal error
+
+      if Errors_Detected = Maximum_Messages then
+         Set_Standard_Error;
+         Write_Line ("fatal error: maximum number of errors exceeded");
+         Set_Standard_Output;
+         raise Unrecoverable_Error;
+      end if;
    end Error_Msg;
 
    --------------------
@@ -99,7 +113,7 @@ package body Binderr is
       Warning         : Boolean := False;
 
    begin
-      if Warnings_Detected + Errors_Detected > Maximum_Errors then
+      if Warnings_Detected + Errors_Detected > Maximum_Messages then
          Write_Str ("error: maximum errors exceeded");
          Write_Eol;
          return;
diff --git a/gcc/ada/bindusg.adb b/gcc/ada/bindusg.adb
index a70aaa9ee9687910b8b738f8bfe038dd44c6eea8..19d0c147b86af0b974ce382f638f61d9a2ee865a 100644
--- a/gcc/ada/bindusg.adb
+++ b/gcc/ada/bindusg.adb
@@ -142,7 +142,7 @@ package body Bindusg is
 
       --  Line for -m switch
 
-      Write_Line ("  -mnnn     Limit number of detected errors " &
+      Write_Line ("  -mnnn     Limit number of detected errors/warnings " &
                   "to nnn (1-999999)");
 
       --  Line for -M switch
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 6f122f6c27f4e1c0596166c135c4033aef4e4619..042488041b60677cd93f1fcc36933c43876a95a2 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -328,11 +328,20 @@ package body Errout is
          Warn_On_Instance := Is_Warning_Msg;
       end if;
 
-      --  Ignore warning message that is suppressed. Note that style
-      --  checks are not considered warning messages for this purpose
+      --  Ignore warning message that is suppressed for this location. Note
+      --  that style checks are not considered warning messages for this
+      --  purpose.
 
       if Is_Warning_Msg and then Warnings_Suppressed (Orig_Loc) then
          return;
+
+      --  For style messages, check too many messages so far
+
+      elsif Is_Style_Msg
+        and then Maximum_Messages /= 0
+        and then Warnings_Detected >= Maximum_Messages
+      then
+         return;
       end if;
 
       --  The idea at this stage is that we have two kinds of messages
@@ -1034,10 +1043,18 @@ package body Errout is
          end if;
       end if;
 
-      --  Terminate if max errors reached
+      --  If too many warnings turn off warnings
 
-      if Total_Errors_Detected + Warnings_Detected = Maximum_Errors then
-         raise Unrecoverable_Error;
+      if Maximum_Messages /= 0 then
+         if Warnings_Detected = Maximum_Messages then
+            Warning_Mode := Suppress;
+         end if;
+
+         --  If too many errors abandon compilation
+
+         if Total_Errors_Detected = Maximum_Messages then
+            raise Unrecoverable_Error;
+         end if;
       end if;
    end Error_Msg_Internal;
 
@@ -1556,13 +1573,21 @@ package body Errout is
 
       procedure Write_Max_Errors is
       begin
-         if Maximum_Errors /= 0
-           and then Total_Errors_Detected + Warnings_Detected = Maximum_Errors
-         then
-            Set_Standard_Error;
-            Write_Str ("fatal error: maximum errors reached");
-            Write_Eol;
-            Set_Standard_Output;
+         if Maximum_Messages /= 0 then
+            if Warnings_Detected >= Maximum_Messages then
+               Set_Standard_Error;
+               Write_Line ("maximum number of warnings output");
+               Write_Line ("any further warnings suppressed");
+               Set_Standard_Output;
+            end if;
+
+            --  If too many errors print message
+
+            if Total_Errors_Detected >= Maximum_Messages then
+               Set_Standard_Error;
+               Write_Line ("fatal error: maximum number of errors detected");
+               Set_Standard_Output;
+            end if;
          end if;
       end Write_Max_Errors;
 
diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb
index f255ac00e9e7436e935a7a8c9d185a6cb26085c4..a5d963f555de435a4bc0720d20bad2c79259b370 100644
--- a/gcc/ada/erroutc.adb
+++ b/gcc/ada/erroutc.adb
@@ -1340,6 +1340,10 @@ package body Erroutc is
 
    function Warnings_Suppressed (Loc : Source_Ptr) return Boolean is
    begin
+      if Warning_Mode = Suppress then
+         return True;
+      end if;
+
       --  Loop through table of ON/OFF warnings
 
       for J in Warnings.First .. Warnings.Last loop
diff --git a/gcc/ada/erroutc.ads b/gcc/ada/erroutc.ads
index ba212eeb42bbcadb0f56f95c3a8534c4549c8689..f2127deaa39747f21d9ff325a60db417a1118430 100644
--- a/gcc/ada/erroutc.ads
+++ b/gcc/ada/erroutc.ads
@@ -481,7 +481,8 @@ package Erroutc is
    --  Determines if given location is covered by a warnings off suppression
    --  range in the warnings table (or is suppressed by compilation option,
    --  which generates a warning range for the whole source file). This routine
-   --  only deals with the general ON/OFF case, not specific warnings
+   --  only deals with the general ON/OFF case, not specific warnings. True
+   --  is also returned if warnings are globally suppressed.
 
    function Warning_Specifically_Suppressed
      (Loc : Source_Ptr;
diff --git a/gcc/ada/errutil.adb b/gcc/ada/errutil.adb
index 222f73b503483d668a8ad5b515f6ac43253c9f54..480a35537a1035466694db705f5047a9b97d9b38 100644
--- a/gcc/ada/errutil.adb
+++ b/gcc/ada/errutil.adb
@@ -548,13 +548,18 @@ package body Errutil is
          Set_Standard_Output;
       end if;
 
-      if Maximum_Errors /= 0
-        and then Total_Errors_Detected + Warnings_Detected = Maximum_Errors
-      then
-         Set_Standard_Error;
-         Write_Str ("fatal error: maximum errors reached");
-         Write_Eol;
-         Set_Standard_Output;
+      if Maximum_Messages /= 0 then
+         if Warnings_Detected >= Maximum_Messages then
+            Set_Standard_Error;
+            Write_Line ("maximum number of warnings detected");
+            Warning_Mode := Suppress;
+         end if;
+
+         if Total_Errors_Detected >= Maximum_Messages then
+            Set_Standard_Error;
+            Write_Line ("fatal error: maximum errors reached");
+            Set_Standard_Output;
+         end if;
       end if;
 
       if Warning_Mode = Treat_As_Error then
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index 9b17e2c119acfaa2a63f2a85e4660714fa1117d9..7907023f4d4bfc788b096119046ca10d08fc6b8a 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -3995,9 +3995,13 @@ source output.
 @item -gnatm=@var{n}
 @cindex @option{-gnatm} (@command{gcc})
 Limit number of detected error or warning messages to @var{n}
-where @var{n} is in the range 1..999_999. The default setting if
-no switch is given is 9999. Compilation is terminated if this
-limit is exceeded. The equal sign here is optional.
+where @var{n} is in the range 1..999999. The default setting if
+no switch is given is 9999. If the number of warnings reaches this
+limit, then a message is output and further warnings are suppressed,
+but the compilation is continued. If the number of error messages
+reaches this limit, then a message is output and the compilation
+is abandoned. The equal sign here is optional. A value of zero
+means that no limit applies.
 
 @item -gnatn
 @cindex @option{-gnatn} (@command{gcc})
@@ -4488,16 +4492,25 @@ format message or full listing (which as usual is written to
 The @code{m} stands for maximum.
 @end ifclear
 @var{n} is a decimal integer in the
-range of 1 to 999 and limits the number of error messages to be
-generated. For example, using @option{-gnatm2} might yield
+range of 1 to 999999 and limits the number of error or warning
+messages to be generated. For example, using
+@option{-gnatm2} might yield
 
 @smallexample
 e.adb:3:04: Incorrect spelling of keyword "function"
 e.adb:5:35: missing ".."
-fatal error: maximum errors reached
+fatal error: maximum number of errors detected
 compilation abandoned
 @end smallexample
 
+@noindent
+The default setting if
+no switch is given is 9999. If the number of warnings reaches this
+limit, then a message is output and further warnings are suppressed,
+but the compilation is continued. If the number of error messages
+reaches this limit, then a message is output and the compilation
+is abandoned. A value of zero means that no limit applies.
+
 @noindent
 Note that the equal sign is optional, so the switches
 @option{-gnatm2} and @option{-gnatm=2} are equivalent.
@@ -7799,9 +7812,15 @@ supported on cross environments only.
 
 @item ^-m^/ERROR_LIMIT=^@var{n}
 @cindex @option{^-m^/ERROR_LIMIT^} (@command{gnatbind})
-Limit number of detected errors to @var{n}, where @var{n} is
-in the range 1..999_999. The default value if no switch is
-given is 9999. Binding is terminated if the limit is exceeded.
+Limit number of detected errors or warnings to @var{n}, where @var{n} is
+in the range 1..999999. The default value if no switch is
+given is 9999. If the number of warnings reaches this limit, then a
+message is output and further warnings are suppressed, the bind
+continues in this case. If the number of errors reaches this
+limit, then a message is output and the bind is abandoned.
+A value of zero means that no limit is enforced. The equal
+sign is optional.
+
 @ifset unw
 Furthermore, under Windows, the sources pointed to by the libraries path
 set in the registry are not searched for.
diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads
index 1aba6eb0d538ffe1e5f8cf0d452295b21c9b7fb0..3093d374f8f7e57016ef46e5484f0d6c71e71fcb 100644
--- a/gcc/ada/opt.ads
+++ b/gcc/ada/opt.ads
@@ -806,10 +806,11 @@ package Opt is
    --  File name of mapping between unit names, file names and path names.
    --  (given by switch -gnatem)
 
-   Maximum_Errors : Int := 9999;
+   Maximum_Messages : Int := 9999;
    --  GNAT, GNATBIND
-   --  Maximum default number of errors before compilation is terminated.
-   --  Can be overridden using -gnatm (GNAT) or -m (GNATBIND) switch.
+   --  Maximum default number of errors before compilation is terminated, or in
+   --  the case of GNAT, maximum number of warnings before further warnings are
+   --  suppressed. Can be overridden by -gnatm (GNAT) or -m (GNATBIND) switch.
 
    Maximum_File_Name_Length : Int;
    --  GNAT, GNATBIND
diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb
index 9e20de16836dc53718ad8e8ab4aaead8fa4feee5..a4a9254c78627c3c8d588752cc644b8861d62003 100644
--- a/gcc/ada/sem_ch10.adb
+++ b/gcc/ada/sem_ch10.adb
@@ -3369,7 +3369,7 @@ package body Sem_Ch10 is
                                                         N_Subprogram_Body,
                                                         N_Subunit)
          then
-            --  Current unit is private, of descendant of a private unit.
+            --  Current unit is private, of descendant of a private unit
 
             null;
 
diff --git a/gcc/ada/switch-b.adb b/gcc/ada/switch-b.adb
index 0d673b7daee1e268de72633309cac9a6d16434ba..e3e597bcadfb06c6b232137887ad838d93fa2b29 100644
--- a/gcc/ada/switch-b.adb
+++ b/gcc/ada/switch-b.adb
@@ -286,7 +286,7 @@ package body Switch.B is
             end if;
 
             Ptr := Ptr + 1;
-            Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors, C);
+            Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Messages, C);
 
          --  Processing for n switch
 
diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb
index ddd4859c2e21f55e0c4fe4ae89063cb0c2a84026..23b9551cea598b0509cab1528b6ca8612964fcdd 100644
--- a/gcc/ada/switch-c.adb
+++ b/gcc/ada/switch-c.adb
@@ -633,7 +633,7 @@ package body Switch.C is
                   Ptr := Ptr + 1;
                end if;
 
-               Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Errors, C);
+               Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C);
 
             --  Processing for n switch
 
diff --git a/gcc/ada/usage.adb b/gcc/ada/usage.adb
index e69695b04fb9ccb491ba9acb0770e9e9694dbbbd..55a3f49921ae423e6960ddb7a5dd44d07222ac94 100644
--- a/gcc/ada/usage.adb
+++ b/gcc/ada/usage.adb
@@ -261,7 +261,7 @@ begin
    --  Line for -gnatm switch
 
    Write_Switch_Char ("mnn");
-   Write_Line ("Limit number of detected errors to nn (1-999999)");
+   Write_Line ("Limit number of detected errors/warnings to nn (1-999999)");
 
    --  Line for -gnatn switch