This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran, 4.2] Backport -fmax-errors to 4.2.
- From: Brooks Moses <brooks dot moses at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: fortran at gcc dot gnu dot org
- Date: Mon, 05 Mar 2007 01:09:47 -0800
- Subject: [patch, fortran, 4.2] Backport -fmax-errors to 4.2.
The attached patches backport my -fmax-errors patch to 4.2, along with
the documentation.
Currently regtesting on i686-pc-linux-gnu. Ok to commit, assuming it
passes?
-----------------------------------------------------------------
2007-03-05 Brooks Moses <brooks.moses@codesourcery.com>
* lang.opt: Add -fmax-errors= option.
* gfortran.h (gfc_option_t): Add max_errors element.
* options.c (gfc_init_options): Set max_errors default value
to 25.
(gfc_handle_options): Check -fmax_errors value, assign to
gfc_option.max_errors.
* error.c (gfc_increment_error_count): New function, which
also checks whether the error count exceeds max_errors.
(gfc_notify_std): Use it.
(gfc_error): Use it.
(gfc_error_now): Use it.
(gfc_error_check): Use it.
(gfc_warning): Reorder to match trunk.
* invoke.texi: Added documentation for -fmax-errors option.
-----------------------------------------------------------------
- Brooks
Index: invoke.texi
===================================================================
--- invoke.texi (revision 122539)
+++ invoke.texi (working copy)
@@ -126,7 +126,7 @@
@item Error and Warning Options
@xref{Error and Warning Options,,Options to Request or Suppress Errors
and Warnings}.
-@gccoptlist{
+@gccoptlist{-fmax-errors=@var{n} @gol
-fsyntax-only -pedantic -pedantic-errors @gol
-w -Wall -Waliasing -Wampersand -Wconversion -Wimplicit-interface @gol
-Wtabs -Wnonstd-intrinsics -Wsurprising -Wunderflow @gol
@@ -364,6 +364,15 @@
by GNU Fortran:
@table @gcctabopt
+@item -fmax-errors-@var{n}
+@cindex @code{-fmax-errors-}@var{n} option
+@cindex option, @code{-fmax-errors-}@var{n}
+@cindex errors, limiting
+Limits the maximum number of error messages to @var{n}, at which point
+GNU Fortran bails out rather than attempting to continue processing the
+source code. If @var{n} is 0, there is no limit on the number of error
+messages produced.
+
@item -fsyntax-only
@cindex @code{-fsyntax-only} option
@cindex option, @code{-fsyntax-only}
Index: lang.opt
===================================================================
--- lang.opt (revision 118614)
+++ lang.opt (working copy)
@@ -169,6 +169,10 @@
Fortran RejectNegative Joined UInteger
-ffree-line-length-<n> Use n as character line width in free mode
+fmax-errors=
+Fortran RejectNegative Joined UInteger
+-fmax-errors=<n> Maximum number of errors to report
+
fmax-identifier-length=
Fortran RejectNegative Joined UInteger
-fmax-identifier-length=<n> Maximum identifier length
Index: gfortran.h
===================================================================
--- gfortran.h (revision 118614)
+++ gfortran.h (working copy)
@@ -1629,6 +1629,7 @@
int warn_tabs;
int warn_underflow;
int warn_character_truncation;
+ int max_errors;
int flag_all_intrinsics;
int flag_default_double;
Index: options.c
===================================================================
--- options.c (revision 118614)
+++ options.c (working copy)
@@ -61,6 +61,7 @@
gfc_option.warn_surprising = 0;
gfc_option.warn_tabs = 1;
gfc_option.warn_underflow = 1;
+ gfc_option.max_errors = 25;
gfc_option.flag_all_intrinsics = 0;
gfc_option.flag_default_double = 0;
@@ -512,6 +513,10 @@
gfc_option.flag_implicit_none = value;
break;
+ case OPT_fmax_errors_:
+ gfc_option.max_errors = value;
+ break;
+
case OPT_fmax_stack_var_size_:
gfc_option.flag_max_stack_var_size = value;
break;
Index: error.c
===================================================================
--- error.c (revision 118541)
+++ error.c (working copy)
@@ -460,6 +460,18 @@
}
+/* Increment the number of errors, and check whether too many have
+ been printed. */
+
+static void
+gfc_increment_error_count (void)
+{
+ errors++;
+ if ((gfc_option.max_errors != 0) && (errors >= gfc_option.max_errors))
+ gfc_fatal_error ("Error count reached limit of %d.", gfc_option.max_errors);
+}
+
+
/* Issue a warning. */
void
@@ -475,12 +487,13 @@
cur_error_buffer = &warning_buffer;
va_start (argp, nocmsgid);
+ error_print (_("Warning:"), _(nocmsgid), argp);
+ va_end (argp);
+
+ error_char ('\0');
+
if (buffer_flag == 0)
warnings++;
- error_print (_("Warning:"), _(nocmsgid), argp);
- va_end (argp);
-
- error_char ('\0');
}
@@ -530,13 +542,6 @@
cur_error_buffer->flag = 1;
cur_error_buffer->index = 0;
- if (buffer_flag == 0)
- {
- if (warning)
- warnings++;
- else
- errors++;
- }
va_start (argp, nocmsgid);
if (warning)
error_print (_("Warning:"), _(nocmsgid), argp);
@@ -545,6 +550,15 @@
va_end (argp);
error_char ('\0');
+
+ if (buffer_flag == 0)
+ {
+ if (warning)
+ warnings++;
+ else
+ gfc_increment_error_count();
+ }
+
return warning ? SUCCESS : FAILURE;
}
@@ -615,12 +629,13 @@
cur_error_buffer = &error_buffer;
va_start (argp, nocmsgid);
- if (buffer_flag == 0)
- errors++;
error_print (_("Error:"), _(nocmsgid), argp);
va_end (argp);
error_char ('\0');
+
+ if (buffer_flag == 0)
+ gfc_increment_error_count();
}
@@ -638,13 +653,15 @@
i = buffer_flag;
buffer_flag = 0;
- errors++;
va_start (argp, nocmsgid);
error_print (_("Error:"), _(nocmsgid), argp);
va_end (argp);
error_char ('\0');
+
+ gfc_increment_error_count();
+
buffer_flag = i;
if (flag_fatal_errors)
@@ -711,11 +728,12 @@
if (error_buffer.flag)
{
- errors++;
if (error_buffer.message != NULL)
fputs (error_buffer.message, stderr);
error_buffer.flag = 0;
+ gfc_increment_error_count();
+
if (flag_fatal_errors)
exit (1);
}