+ /* If the user requested that warnings be treated as errors, so be
+ it. Note that we do this before the next block so that
+ individual warnings can be overridden back to warnings with
+ -Wno-error=*. */
+ if (context->warning_as_error_requested
+ && diagnostic->kind == DK_WARNING)
+ {
+ diagnostic->kind = DK_ERROR;
+ maybe_print_warnings_as_errors_message = true;
+ }
+
+ if (diagnostic->option_index)
+ {
+ /* This tests if the user provided the appropriate -Wfoo or
+ -Wno-foo option. */
+ if (! option_enabled (diagnostic->option_index))
+ return false;
+ /* This tests if the user provided the appropriate -Werror=foo
+ option. */
+ if (context->classify_diagnostic[diagnostic->option_index] != DK_UNSPECIFIED)
+ {
+ diagnostic->kind = context->classify_diagnostic[diagnostic->option_index];
+ maybe_print_warnings_as_errors_message = false;
+ }
+ /* This allows for future extensions, like temporarily disabling
+ warnings for ranges of source code. */
+ if (diagnostic->kind == DK_IGNORED)
+ return false;
+ }
+
+ /* If we changed the kind due to -Werror, and didn't override it, we
+ need to print this message. */
+ if (context->issue_warnings_are_errors_message
+ && maybe_print_warnings_as_errors_message)
+ {
+ pp_verbatim (context->printer,
+ "%s: warnings being treated as errors\n", progname);
+ context->issue_warnings_are_errors_message = false;
+ }
+
+ context->lock++;
+
+ if (diagnostic->kind == DK_ICE && plugins_active_p ())
+ {
+ fnotice (stderr, "*** WARNING *** there are active plugins, do not report"
+ " this as a bug unless you can reproduce it without enabling"
+ " any plugins.\n");
+ dump_active_plugins (stderr);
+ }
+
+ if (diagnostic->kind == DK_ICE)
+ {
+#ifndef ENABLE_CHECKING
+ /* When not checking, ICEs are converted to fatal errors when an
+ error has already occurred. This is counteracted by
+ abort_on_error. */
+ if ((diagnostic_kind_count (context, DK_ERROR) > 0
+ || diagnostic_kind_count (context, DK_SORRY) > 0)
+ && !context->abort_on_error)
+ {
+ expanded_location s = expand_location (diagnostic->location);
+ fnotice (stderr, "%s:%d: confused by earlier errors, bailing out\n",
+ s.file, s.line);
+ exit (ICE_EXIT_CODE);
+ }
+#endif
+ if (context->internal_error)
+ (*context->internal_error) (diagnostic->message.format_spec,
+ diagnostic->message.args_ptr);
+ }
+ ++diagnostic_kind_count (context, diagnostic->kind);
+
+ saved_format_spec = diagnostic->message.format_spec;
+ if (context->show_option_requested && diagnostic->option_index)
+ diagnostic->message.format_spec
+ = ACONCAT ((diagnostic->message.format_spec,
+ " [", cl_options[diagnostic->option_index].opt_text, "]", NULL));
+
+ diagnostic->message.locus = &diagnostic->location;
+ diagnostic->message.abstract_origin = &diagnostic->abstract_origin;
+ diagnostic->abstract_origin = NULL;
+ pp_format (context->printer, &diagnostic->message);
+ (*diagnostic_starter (context)) (context, diagnostic);
+ pp_output_formatted_text (context->printer);
+ (*diagnostic_finalizer (context)) (context, diagnostic);
+ pp_flush (context->printer);
+ diagnostic_action_after_output (context, diagnostic);
+ diagnostic->message.format_spec = saved_format_spec;
+ diagnostic->abstract_origin = NULL;
+