diff options
author | Nathan Froyd <froydnj@codesourcery.com> | 2010-11-12 03:38:15 +0000 |
---|---|---|
committer | Nathan Froyd <froydnj@gcc.gnu.org> | 2010-11-12 03:38:15 +0000 |
commit | 3a789837f5cc67590765e2a2a7c4afed7730d405 (patch) | |
tree | c56e28b52155f9b2ee4a677a9f4053bfc8c50f83 /gcc/diagnostic.c | |
parent | f03d897af30c62fe6e8e53c582cebefb1c35cd25 (diff) | |
download | gcc-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/diagnostic.c')
-rw-r--r-- | gcc/diagnostic.c | 12 |
1 files changed, 12 insertions, 0 deletions
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: |