PR c/44782
* common.opt (fmax-errors=): New option.
* opts.c (common_handle_option) [OPT_fmax_errors_]: Handle it.
* diagnostic.h (struct diagnostic_context): Add max_errors field.
* diagnostic.c (diagnostic_initialize): Initialize it.
(diagnostic_action_after_output): Exit if more than max_errors
have been output.
* doc/invoke.texi (Warning Options): Add -fmax-errors.
(-fmax-errors): Document.
gcc/fortran/
PR c/44782
* options.c (gfc_post_options): Initialize gfc_option.max_errors.
(gfc_handle_option) [OPT_fmax_errors_]: Remove.
* lang.opt (fmax-errors=): Remove.
gcc/testsuite/
PR c/44782
* c-c++-common/fmax-errors.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166644
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-11-11 Nathan Froyd <froydnj@codesourcery.com>
+
+ PR c/44782
+ * common.opt (fmax-errors=): New option.
+ * opts.c (common_handle_option) [OPT_fmax_errors_]: Handle it.
+ * diagnostic.h (struct diagnostic_context): Add max_errors field.
+ * diagnostic.c (diagnostic_initialize): Initialize it.
+ (diagnostic_action_after_output): Exit if more than max_errors
+ have been output.
+ * doc/invoke.texi (Warning Options): Add -fmax-errors.
+ (-fmax-errors): Document.
+
2010-11-11 Richard Henderson <rth@redhat.com>
* optabs.c (init_optabs): Init {fma,fms,fnma,fnms}_optab properly.
2010-11-11 Richard Henderson <rth@redhat.com>
* optabs.c (init_optabs): Init {fma,fms,fnma,fnms}_optab properly.
Common Report Var(flag_errno_math) Init(1) Optimization
Set errno after built-in math functions
Common Report Var(flag_errno_math) Init(1) Optimization
Set errno after built-in math functions
+fmax-errors=
+Common Joined RejectNegative UInteger Var(flag_max_errors)
+-fmax-errors=<number> Maximum number of errors to report
+
fmem-report
Common Report Var(mem_report)
Report on permanent memory allocation
fmem-report
Common Report Var(mem_report)
Report on permanent memory allocation
context->fatal_errors = false;
context->dc_inhibit_warnings = false;
context->dc_warn_system_headers = false;
context->fatal_errors = false;
context->dc_inhibit_warnings = false;
context->dc_warn_system_headers = false;
+ context->max_errors = 0;
context->internal_error = NULL;
diagnostic_starter (context) = default_diagnostic_starter;
diagnostic_finalizer (context) = default_diagnostic_finalizer;
context->internal_error = NULL;
diagnostic_starter (context) = default_diagnostic_starter;
diagnostic_finalizer (context) = default_diagnostic_finalizer;
diagnostic_finish (context);
exit (FATAL_EXIT_CODE);
}
diagnostic_finish (context);
exit (FATAL_EXIT_CODE);
}
+ if (context->max_errors != 0
+ && ((unsigned) (diagnostic_kind_count (context, DK_ERROR)
+ + diagnostic_kind_count (context, DK_SORRY))
+ >= context->max_errors))
+ {
+ fnotice (stderr,
+ "compilation terminated due to -fmax-errors=%u.\n",
+ context->max_errors);
+ diagnostic_finish (context);
+ exit (FATAL_EXIT_CODE);
+ }
/* True if warnings should be given in system headers. */
bool dc_warn_system_headers;
/* True if warnings should be given in system headers. */
bool dc_warn_system_headers;
+ /* Maximum number of errors to report. */
+ unsigned int max_errors;
+
/* This function is called before any message is printed out. It is
responsible for preparing message prefix and such. For example, it
might say:
/* This function is called before any message is printed out. It is
responsible for preparing message prefix and such. For example, it
might say:
@item Warning Options
@xref{Warning Options,,Options to Request or Suppress Warnings}.
@item Warning Options
@xref{Warning Options,,Options to Request or Suppress Warnings}.
-@gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol
+@gccoptlist{-fsyntax-only fmax-errors=@var{n} -pedantic @gol
+-pedantic-errors @gol
-w -Wextra -Wall -Waddress -Waggregate-return -Warray-bounds @gol
-Wno-attributes -Wno-builtin-macro-redefined @gol
-Wc++-compat -Wc++0x-compat -Wcast-align -Wcast-qual @gol
-w -Wextra -Wall -Waddress -Waggregate-return -Warray-bounds @gol
-Wno-attributes -Wno-builtin-macro-redefined @gol
-Wc++-compat -Wc++0x-compat -Wcast-align -Wcast-qual @gol
@opindex fsyntax-only
Check the code for syntax errors, but don't do anything beyond that.
@opindex fsyntax-only
Check the code for syntax errors, but don't do anything beyond that.
+@item -fmax-errors=@var{n}
+@opindex fmax-errors
+Limits the maximum number of error messages to @var{n}, at which point
+GCC bails out rather than attempting to continue processing the source
+code. If @var{n} is 0 (the default), there is no limit on the number
+of error messages produced. If @option{-Wfatal-errors} is also
+specified, then @option{-Wfatal-errors} takes precedence over this
+option.
+
@item -w
@opindex w
Inhibit all warning messages.
@item -w
@opindex w
Inhibit all warning messages.
+2010-11-11 Nathan Froyd <froydnj@codesourcery.com>
+
+ PR c/44782
+ * options.c (gfc_post_options): Initialize gfc_option.max_errors.
+ (gfc_handle_option) [OPT_fmax_errors_]: Remove.
+ * lang.opt (fmax-errors=): Remove.
+
2010-11-11 Steven G. Kargl <kargl@gcc.gnu.org>
* symbol.c (verify_bind_c_derived_type): Accept BIND(C) on an empty
2010-11-11 Steven G. Kargl <kargl@gcc.gnu.org>
* symbol.c (verify_bind_c_derived_type): Accept BIND(C) on an empty
Fortran RejectNegative Joined UInteger
-fmax-array-constructor=<n> Maximum number of objects in an array constructor
Fortran RejectNegative Joined UInteger
-fmax-array-constructor=<n> Maximum number of objects in an array constructor
-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
fmax-identifier-length=
Fortran RejectNegative Joined UInteger
-fmax-identifier-length=<n> Maximum identifier length
if (flag_compare_debug)
gfc_option.dump_fortran_original = 0;
if (flag_compare_debug)
gfc_option.dump_fortran_original = 0;
+ /* Make -fmax-errors visible to gfortran's diagnostic machinery. */
+ if (global_options_set.x_flag_max_errors)
+ gfc_option.max_errors = flag_max_errors;
+
/* Verify the input file name. */
if (!filename || strcmp (filename, "-") == 0)
{
/* Verify the input file name. */
if (!filename || strcmp (filename, "-") == 0)
{
gfc_option.flag_max_array_constructor = value > 65535 ? value : 65535;
break;
gfc_option.flag_max_array_constructor = value > 65535 ? value : 65535;
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;
case OPT_fmax_stack_var_size_:
gfc_option.flag_max_stack_var_size = value;
break;
dc->dc_inhibit_warnings = true;
break;
dc->dc_inhibit_warnings = true;
break;
+ case OPT_fmax_errors_:
+ dc->max_errors = value;
+ break;
+
case OPT_fuse_linker_plugin:
/* No-op. Used by the driver and passed to us because it starts with f.*/
break;
case OPT_fuse_linker_plugin:
/* No-op. Used by the driver and passed to us because it starts with f.*/
break;
+2010-11-11 Nathan Froyd <froydnj@codesourcery.com>
+
+ PR c/44782
+ * c-c++-common/fmax-errors.c: New test.
+
2010-11-11 Richard Henderson <rth@redhat.com>
* gcc.target/i386/sse-24.c: Use -ffp-contract.
2010-11-11 Richard Henderson <rth@redhat.com>
* gcc.target/i386/sse-24.c: Use -ffp-contract.
--- /dev/null
+/* PR c/44782 */
+/* { dg-do compile } */
+/* { dg-options "-fmax-errors=3" } */
+
+void foo (unsigned int i, unsigned int j)
+{
+ (i) (); /* { dg-error "" } */
+ (j) (); /* { dg-error "" } */
+ (i+j) (); /* { dg-error "" } */
+ (i*j) (); /* no error here due to -fmax-errors */
+} /* { dg-prune-output "compilation terminated" } */