This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Improve handling of max limit on messages


This patch improves the handling of the maximum limit on messages
(set by -gnatmnn for GNAT, or -mnn for the binder). The limit now
applies separately to warnings. If the maximum number of warnings
is generated, then a message is output and further warnings are
suppressed, but the compilation continues. If the maximum number
of errors is reached, compilation is terminated with an appropriate
error message.

The following examples show the new approach in action. These
are all compiled with -gnatwa -gnatl -gnatm3

     1. procedure too_many_errors is
     2.    a, b : integer;
     3. begin
     4.    b := 0;
     5.    a := b / b;
                  |
        >>> warning: division by zero
        >>> warning: "Constraint_Error" will be raised at run time

     6.    m := 3;
           |
        >>> "m" is undefined

     7.    n := 3;
           |
        >>> "n" is undefined

     8.    o := 3;
           |
        >>> "o" is undefined

     9.    p := 3;
    10.    q := 3;
    11. end;

 11 lines: 3 errors, 2 warnings
fatal error: maximum number of errors detected
compilation abandoned

     1. procedure too_many_warnings is
     2.    a, b, c, d, e, f : Integer;
           1  2  3
        >>> warning: variable "a" is never read and never assigned
        >>> warning: variable "b" is never read and never assigned
        >>> warning: variable "c" is never read and never assigned

     3. begin
     4.    null;
     5. end;

 5 lines: No errors, 3 warnings
maximum number of warnings output
any further warnings suppressed

     1. procedure too_many_errors_warnings is
     2.    a, b : integer;
     3. begin
     4.    b := 0;
     5.    a := b / b;
                  |
        >>> warning: division by zero
        >>> warning: "Constraint_Error" will be raised at run time

     6.    a := b / b;
                  |
        >>> warning: division by zero

     7.    a := b / b;
     8.    a := b / b;
     9.    a := b / b;
    10.    m := 3;
           |
        >>> "m" is undefined

    11.    n := 3;
           |
        >>> "n" is undefined

    12.    o := 3;
           |
        >>> "o" is undefined

    13.    p := 3;
    14.    q := 3;
    15. end;

 15 lines: 3 errors, 3 warnings
maximum number of warnings output
any further warnings suppressed
fatal error: maximum number of errors detected
compilation abandoned

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

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.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]