diff options
author | Nathan Sidwell <nathan@acm.org> | 2016-12-05 12:24:39 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2016-12-05 12:24:39 +0000 |
commit | d0ea9f0aa270f9791df42eb409e90c718575ad9a (patch) | |
tree | 63b942309e0e3faf9b2b19ff2be30494a2a4bbf1 /gcc/diagnostic.c | |
parent | fb5e7daea59060603a2e526cab4e35b32a8e9438 (diff) | |
download | gcc-d0ea9f0aa270f9791df42eb409e90c718575ad9a.zip gcc-d0ea9f0aa270f9791df42eb409e90c718575ad9a.tar.gz gcc-d0ea9f0aa270f9791df42eb409e90c718575ad9a.tar.bz2 |
diagnostic.c (diagnostic_check_max_errors): New, broken out of ...
gcc/
* diagnostic.c (diagnostic_check_max_errors): New, broken out of ...
(diagnostic_action_after_output): ... here.
(diagnostic_report_diagnostic): Call it for non-notes.
* diagnostic.h (struct diagnostic_context): Make max_errors signed
int.
(diagnostic_check_max_errors): Declare.
gcc/fortran/
* error.c (gfc_warning_check): Call diagnostic_check_max_errors.
(gfc_error_check): Likewise.
gcc/testsuite/
* c-c++-common/fmax_errors.c: Check notes after last error are
emitted.
From-SVN: r243254
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r-- | gcc/diagnostic.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 4278a10..c06d266 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -446,6 +446,31 @@ bt_err_callback (void *data ATTRIBUTE_UNUSED, const char *msg, int errnum) errnum == 0 ? "" : xstrerror (errnum)); } +/* Check if we've met the maximum error limit, and if so fatally exit + with a message. CONTEXT is the context to check, and FLUSH + indicates whether a diagnostic_finish call is needed. */ + +void +diagnostic_check_max_errors (diagnostic_context *context, bool flush) +{ + if (!context->max_errors) + return; + + int count = (diagnostic_kind_count (context, DK_ERROR) + + diagnostic_kind_count (context, DK_SORRY) + + diagnostic_kind_count (context, DK_WERROR)); + + if (count >= context->max_errors) + { + fnotice (stderr, + "compilation terminated due to -fmax-errors=%u.\n", + context->max_errors); + if (flush) + diagnostic_finish (context); + exit (FATAL_EXIT_CODE); + } +} + /* Take any action which is expected to happen after the diagnostic is written out. This function does not always return. */ void @@ -470,18 +495,6 @@ 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); - } break; case DK_ICE: @@ -890,6 +903,9 @@ diagnostic_report_diagnostic (diagnostic_context *context, return false; } + if (diagnostic->kind != DK_NOTE) + diagnostic_check_max_errors (context); + context->lock++; if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT) |