aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@codesourcery.com>2010-11-12 03:38:15 +0000
committerNathan Froyd <froydnj@gcc.gnu.org>2010-11-12 03:38:15 +0000
commit3a789837f5cc67590765e2a2a7c4afed7730d405 (patch)
treec56e28b52155f9b2ee4a677a9f4053bfc8c50f83 /gcc
parentf03d897af30c62fe6e8e53c582cebefb1c35cd25 (diff)
downloadgcc-3a789837f5cc67590765e2a2a7c4afed7730d405.zip
gcc-3a789837f5cc67590765e2a2a7c4afed7730d405.tar.gz
gcc-3a789837f5cc67590765e2a2a7c4afed7730d405.tar.bz2
re PR c/44782 (implement -ferror-limit=)
gcc/ 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. From-SVN: r166644
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/common.opt4
-rw-r--r--gcc/diagnostic.c12
-rw-r--r--gcc/diagnostic.h3
-rw-r--r--gcc/doc/invoke.texi12
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/lang.opt4
-rw-r--r--gcc/fortran/options.c8
-rw-r--r--gcc/opts.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/fmax-errors.c11
11 files changed, 73 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1f4b09e..b26c6e2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+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.
diff --git a/gcc/common.opt b/gcc/common.opt
index 85eaa37..d9006ee 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1170,6 +1170,10 @@ fmath-errno
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
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 40ddc23..d297cdd 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -109,6 +109,7 @@ diagnostic_initialize (diagnostic_context *context, int n_opts)
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;
@@ -219,6 +220,17 @@ diagnostic_action_after_output (diagnostic_context *context,
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);
+ }
break;
case DK_ICE:
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 99671c6..8074354 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -128,6 +128,9 @@ struct diagnostic_context
/* 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:
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index f2deda3..1a658ac 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -229,7 +229,8 @@ Objective-C and Objective-C++ Dialects}.
@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
@@ -2775,6 +2776,15 @@ warnings but control the kinds of diagnostics produced by GCC.
@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.
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 41a5bef..55e5058 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+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
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index 6088730..371b71d 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -438,10 +438,6 @@ fmax-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
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index ee17037..dd54a7d 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -273,6 +273,10 @@ gfc_post_options (const char **pfilename)
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)
{
@@ -760,10 +764,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
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;
diff --git a/gcc/opts.c b/gcc/opts.c
index f5f60b5..f42ac53 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -2155,6 +2155,10 @@ common_handle_option (struct gcc_options *opts,
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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ef7278f..e67a296 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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.
diff --git a/gcc/testsuite/c-c++-common/fmax-errors.c b/gcc/testsuite/c-c++-common/fmax-errors.c
new file mode 100644
index 0000000..1ef78eb
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/fmax-errors.c
@@ -0,0 +1,11 @@
+/* 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" } */