aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2016-12-05 12:24:39 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2016-12-05 12:24:39 +0000
commitd0ea9f0aa270f9791df42eb409e90c718575ad9a (patch)
tree63b942309e0e3faf9b2b19ff2be30494a2a4bbf1 /gcc
parentfb5e7daea59060603a2e526cab4e35b32a8e9438 (diff)
downloadgcc-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')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/diagnostic.c40
-rw-r--r--gcc/diagnostic.h3
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/error.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/fmax-errors.c14
7 files changed, 63 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ad903f9..9488b0f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2016-12-05 Nathan Sidwell <nathan@acm.org>
+
+ * 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.
+
2016-12-05 Cupertino Miranda <cmiranda@synopsys.com>
* config/arc/arc.h (STARTFILE_SPEC): Use default linux specs.
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)
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index ead4d2a..f3bb494 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -143,7 +143,7 @@ struct diagnostic_context
bool dc_warn_system_headers;
/* Maximum number of errors to report. */
- unsigned int max_errors;
+ 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
@@ -320,6 +320,7 @@ void default_diagnostic_start_span_fn (diagnostic_context *,
void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *);
void diagnostic_set_caret_max_width (diagnostic_context *context, int value);
void diagnostic_action_after_output (diagnostic_context *, diagnostic_t);
+void diagnostic_check_max_errors (diagnostic_context *, bool flush = false);
void diagnostic_file_cache_fini (void);
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 2c06b31..f1858ea 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2016-12-05 Nathan Sidwell <nathan@acm.org>
+
+ * error.c (gfc_warning_check): Call diagnostic_check_max_errors.
+ (gfc_error_check): Likewise.
+
2016-12-04 Janus Weil <janus@gcc.gnu.org>
PR fortran/78618
diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c
index 0fd8a4e..757f7e2 100644
--- a/gcc/fortran/error.c
+++ b/gcc/fortran/error.c
@@ -1226,6 +1226,7 @@ gfc_warning_check (void)
diagnostic_action_after_output (global_dc,
warningcount_buffered
? DK_WARNING : DK_ERROR);
+ diagnostic_check_max_errors (global_dc, true);
}
}
@@ -1370,6 +1371,7 @@ gfc_error_check (void)
gcc_assert (gfc_output_buffer_empty_p (pp_error_buffer));
pp->buffer = tmp_buffer;
diagnostic_action_after_output (global_dc, DK_ERROR);
+ diagnostic_check_max_errors (global_dc, true);
return true;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2fe40d0..c40ffd6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-12-05 Nathan Sidwell <nathan@acm.org>
+
+ * c-c++-common/fmax_errors.c: Check notes after last error are
+ emitted.
+
2016-12-04 James Greenhalgh <james.greenhalgh@arm.com>
PR rtl-optimization/78561
diff --git a/gcc/testsuite/c-c++-common/fmax-errors.c b/gcc/testsuite/c-c++-common/fmax-errors.c
index 1ef78eb..b44e238 100644
--- a/gcc/testsuite/c-c++-common/fmax-errors.c
+++ b/gcc/testsuite/c-c++-common/fmax-errors.c
@@ -1,11 +1,21 @@
/* PR c/44782 */
/* { dg-do compile } */
-/* { dg-options "-fmax-errors=3" } */
+/* { dg-options "-fmax-errors=3 -Wall" } */
void foo (unsigned int i, unsigned int j)
{
(i) (); /* { dg-error "" } */
(j) (); /* { dg-error "" } */
- (i+j) (); /* { dg-error "" } */
+
+ i + j; /* { dg-warning "" } */
+
+ (k) (); /* { dg-error "" } */
+ /* Make sure we see the notes related to the final error we emit. */
+ /* { dg-message "identifier" "" { target c } 12 } */
+
+ /* Warnings after the final error should not appear. */
+ i + j; /* no warning. */
+
(i*j) (); /* no error here due to -fmax-errors */
+
} /* { dg-prune-output "compilation terminated" } */