Commit 3f139fcf by Brooks Moses Committed by Brooks Moses

lang.opt: Add -fmax-errors= option.

* 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): Assign -fmax_errors value to
gfc_option.max_errors.
* error.c (gfc_increment_error_count): New function, which
also checks whether the error count exceeds max_errors.
(gfc_warning): Use it.
(gfc_warning_now): Use it.
(gfc_notify_std): Use it.
(gfc_error): Use it.
(gfc_error_now): Use it.
(gfc_error_check): Use it.

From-SVN: r118615
parent 350ff03f
2006-11-08 Brooks Moses <brooks.moses@codesourcery.com> 2006-11-08 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): Assign -fmax_errors value to
gfc_option.max_errors.
* error.c (gfc_increment_error_count): New function, which
also checks whether the error count exceeds max_errors.
(gfc_warning): Use it.
(gfc_warning_now): Use it.
(gfc_notify_std): Use it.
(gfc_error): Use it.
(gfc_error_now): Use it.
(gfc_error_check): Use it.
2006-11-08 Brooks Moses <brooks.moses@codesourcery.com>
* lang.opt: Remove non-working -qkind= option. * lang.opt: Remove non-working -qkind= option.
* gfortran.h (gfc_option_t): Remove q_kind member. * gfortran.h (gfc_option_t): Remove q_kind member.
* options.c (gfc_init_options): Remove q_kind initialization. * options.c (gfc_init_options): Remove q_kind initialization.
......
...@@ -460,6 +460,18 @@ error_printf (const char *nocmsgid, ...) ...@@ -460,6 +460,18 @@ error_printf (const char *nocmsgid, ...)
} }
/* 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. */ /* Issue a warning. */
void void
...@@ -475,17 +487,17 @@ gfc_warning (const char *nocmsgid, ...) ...@@ -475,17 +487,17 @@ gfc_warning (const char *nocmsgid, ...)
cur_error_buffer = &warning_buffer; cur_error_buffer = &warning_buffer;
va_start (argp, nocmsgid); va_start (argp, nocmsgid);
error_print (_("Warning:"), _(nocmsgid), argp);
va_end (argp);
error_char ('\0');
if (buffer_flag == 0) if (buffer_flag == 0)
{ {
warnings++; warnings++;
if (warnings_are_errors) if (warnings_are_errors)
errors++; gfc_increment_error_count();
} }
error_print (_("Warning:"), _(nocmsgid), argp);
va_end (argp);
error_char ('\0');
} }
...@@ -530,13 +542,6 @@ gfc_notify_std (int std, const char *nocmsgid, ...) ...@@ -530,13 +542,6 @@ gfc_notify_std (int std, const char *nocmsgid, ...)
cur_error_buffer->flag = 1; cur_error_buffer->flag = 1;
cur_error_buffer->index = 0; cur_error_buffer->index = 0;
if (buffer_flag == 0)
{
if (warning && !warnings_are_errors)
warnings++;
else
errors++;
}
va_start (argp, nocmsgid); va_start (argp, nocmsgid);
if (warning) if (warning)
error_print (_("Warning:"), _(nocmsgid), argp); error_print (_("Warning:"), _(nocmsgid), argp);
...@@ -545,6 +550,15 @@ gfc_notify_std (int std, const char *nocmsgid, ...) ...@@ -545,6 +550,15 @@ gfc_notify_std (int std, const char *nocmsgid, ...)
va_end (argp); va_end (argp);
error_char ('\0'); error_char ('\0');
if (buffer_flag == 0)
{
if (warning && !warnings_are_errors)
warnings++;
else
gfc_increment_error_count();
}
return (warning && !warnings_are_errors) ? SUCCESS : FAILURE; return (warning && !warnings_are_errors) ? SUCCESS : FAILURE;
} }
...@@ -564,7 +578,7 @@ gfc_warning_now (const char *nocmsgid, ...) ...@@ -564,7 +578,7 @@ gfc_warning_now (const char *nocmsgid, ...)
buffer_flag = 0; buffer_flag = 0;
warnings++; warnings++;
if (warnings_are_errors) if (warnings_are_errors)
errors++; gfc_increment_error_count();
va_start (argp, nocmsgid); va_start (argp, nocmsgid);
error_print (_("Warning:"), _(nocmsgid), argp); error_print (_("Warning:"), _(nocmsgid), argp);
...@@ -615,12 +629,13 @@ gfc_error (const char *nocmsgid, ...) ...@@ -615,12 +629,13 @@ gfc_error (const char *nocmsgid, ...)
cur_error_buffer = &error_buffer; cur_error_buffer = &error_buffer;
va_start (argp, nocmsgid); va_start (argp, nocmsgid);
if (buffer_flag == 0)
errors++;
error_print (_("Error:"), _(nocmsgid), argp); error_print (_("Error:"), _(nocmsgid), argp);
va_end (argp); va_end (argp);
error_char ('\0'); error_char ('\0');
if (buffer_flag == 0)
gfc_increment_error_count();
} }
...@@ -638,13 +653,15 @@ gfc_error_now (const char *nocmsgid, ...) ...@@ -638,13 +653,15 @@ gfc_error_now (const char *nocmsgid, ...)
i = buffer_flag; i = buffer_flag;
buffer_flag = 0; buffer_flag = 0;
errors++;
va_start (argp, nocmsgid); va_start (argp, nocmsgid);
error_print (_("Error:"), _(nocmsgid), argp); error_print (_("Error:"), _(nocmsgid), argp);
va_end (argp); va_end (argp);
error_char ('\0'); error_char ('\0');
gfc_increment_error_count();
buffer_flag = i; buffer_flag = i;
if (flag_fatal_errors) if (flag_fatal_errors)
...@@ -720,11 +737,12 @@ gfc_error_check (void) ...@@ -720,11 +737,12 @@ gfc_error_check (void)
if (error_buffer.flag) if (error_buffer.flag)
{ {
errors++;
if (error_buffer.message != NULL) if (error_buffer.message != NULL)
fputs (error_buffer.message, stderr); fputs (error_buffer.message, stderr);
error_buffer.flag = 0; error_buffer.flag = 0;
gfc_increment_error_count();
if (flag_fatal_errors) if (flag_fatal_errors)
exit (1); exit (1);
} }
......
...@@ -1629,6 +1629,7 @@ typedef struct ...@@ -1629,6 +1629,7 @@ typedef struct
int warn_surprising; int warn_surprising;
int warn_tabs; int warn_tabs;
int warn_underflow; int warn_underflow;
int max_errors;
int flag_all_intrinsics; int flag_all_intrinsics;
int flag_default_double; int flag_default_double;
......
...@@ -169,6 +169,10 @@ ffree-line-length- ...@@ -169,6 +169,10 @@ ffree-line-length-
Fortran RejectNegative Joined UInteger Fortran RejectNegative Joined UInteger
-ffree-line-length-<n> Use n as character line width in free mode -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= fmax-identifier-length=
Fortran RejectNegative Joined UInteger Fortran RejectNegative Joined UInteger
-fmax-identifier-length=<n> Maximum identifier length -fmax-identifier-length=<n> Maximum identifier length
......
...@@ -61,6 +61,7 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED, ...@@ -61,6 +61,7 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
gfc_option.warn_surprising = 0; gfc_option.warn_surprising = 0;
gfc_option.warn_tabs = 1; gfc_option.warn_tabs = 1;
gfc_option.warn_underflow = 1; gfc_option.warn_underflow = 1;
gfc_option.max_errors = 25;
gfc_option.flag_all_intrinsics = 0; gfc_option.flag_all_intrinsics = 0;
gfc_option.flag_default_double = 0; gfc_option.flag_default_double = 0;
...@@ -512,6 +513,10 @@ gfc_handle_option (size_t scode, const char *arg, int value) ...@@ -512,6 +513,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_option.flag_implicit_none = value; gfc_option.flag_implicit_none = value;
break; break;
case OPT_fmax_errors_:
gfc_option.max_errors = value;
break;
case OPT_fmax_stack_var_size_: case OPT_fmax_stack_var_size_:
gfc_option.flag_max_stack_var_size = value; gfc_option.flag_max_stack_var_size = value;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment