https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67460
--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- Again a problem caused by buffering. Some warnings converted into error may get buffered and then discarded but that doesn't reset ->some_warnings_are_errors. However, we probably do not need this variable at all, since we now count explicitly how many warnings were converted into errors and this number is kept up to date for buffered diagnostics. I think this patch should fix it, but I have not tested it yet: Index: diagnostic.c =================================================================== --- diagnostic.c (revision 227395) +++ diagnostic.c (working copy) @@ -135,11 +135,10 @@ diagnostic_initialize (diagnostic_contex much more elaborated pretty-printer if they wish. */ context->printer = XNEW (pretty_printer); new (context->printer) pretty_printer (); memset (context->diagnostic_count, 0, sizeof context->diagnostic_count); - context->some_warnings_are_errors = false; context->warning_as_error_requested = false; context->n_opts = n_opts; context->classify_diagnostic = XNEWVEC (diagnostic_t, n_opts); for (i = 0; i < n_opts; i++) context->classify_diagnostic[i] = DK_UNSPECIFIED; @@ -202,11 +201,11 @@ diagnostic_color_init (diagnostic_contex void diagnostic_finish (diagnostic_context *context) { /* Some of the errors may actually have been warnings. */ - if (context->some_warnings_are_errors) + if (diagnostic_kind_count (context, DK_WERROR)) { /* -Werror was given. */ if (context->warning_as_error_requested) pp_verbatim (context->printer, _("%s: all warnings being treated as errors"), @@ -859,13 +858,10 @@ diagnostic_report_diagnostic (diagnostic warnings for ranges of source code. */ if (diagnostic->kind == DK_IGNORED) return false; } - if (orig_diag_kind == DK_WARNING && diagnostic->kind == DK_ERROR) - context->some_warnings_are_errors = true; - context->lock++; if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT) { #ifndef ENABLE_CHECKING Index: diagnostic.h =================================================================== --- diagnostic.h (revision 227395) +++ diagnostic.h (working copy) @@ -64,14 +64,10 @@ struct diagnostic_context pretty_printer *printer; /* The number of times we have issued diagnostics. */ int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND]; - /* True if we should display the "warnings are being tread as error" - message, usually displayed once per compiler run. */ - bool some_warnings_are_errors; - /* True if it has been requested that warnings be treated as errors. */ bool warning_as_error_requested; /* The number of option indexes that can be passed to warning() et al. */