diff options
author | Nathan Sidwell <nathan@acm.org> | 2016-10-14 20:32:03 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2016-10-14 20:32:03 +0000 |
commit | efc5aa6bc7c686b302c5d7fd7f65e3f6361961e1 (patch) | |
tree | fb0e8691c78ca666efcf1cc3698c8851e0960779 /gcc/diagnostic.c | |
parent | 983496febcc17e53d5596cff4d2cb1f1c16ebe19 (diff) |
diagnostic.c (diagnostic_action_after_output): Remove max error handling here ....
* diagnostic.c (diagnostic_action_after_output): Remove max error
handling here ....
(diagnostic_report_diagnostic): ... do it here instead.
testsuite/
* c-c++-common/fmax-errors.c: Make sure note is emitted.
From-SVN: r241186
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r-- | gcc/diagnostic.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 2304e14c761..24aceec558c 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -470,18 +470,8 @@ 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) - + diagnostic_kind_count (context, DK_WERROR)) - >= context->max_errors)) - { - fnotice (stderr, - "compilation terminated due to -fmax-errors=%u.\n", - context->max_errors); - diagnostic_finish (context); - exit (FATAL_EXIT_CODE); - } + /* -fmax-error handling is just before the next diagnostic is + emitted. */ break; case DK_ICE: @@ -834,9 +824,7 @@ diagnostic_report_diagnostic (diagnostic_context *context, -Wno-error=*. */ if (context->warning_as_error_requested && diagnostic->kind == DK_WARNING) - { - diagnostic->kind = DK_ERROR; - } + diagnostic->kind = DK_ERROR; if (diagnostic->option_index && diagnostic->option_index != permissive_error_option (context)) @@ -892,6 +880,25 @@ diagnostic_report_diagnostic (diagnostic_context *context, return false; } + if (diagnostic->kind != DK_NOTE && context->max_errors) + { + /* Check, before emitting the diagnostic, whether we would + exceed the limit. This way we will emit notes relevant to + the final emitted error. */ + int count = (diagnostic_kind_count (context, DK_ERROR) + + diagnostic_kind_count (context, DK_SORRY) + + diagnostic_kind_count (context, DK_WERROR)); + + if ((unsigned) count >= context->max_errors) + { + fnotice (stderr, + "compilation terminated due to -fmax-errors=%u.\n", + context->max_errors); + diagnostic_finish (context); + exit (FATAL_EXIT_CODE); + } + } + context->lock++; if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT) |