@@ -42,4 +42,6 @@ DEFINE_DIAGNOSTIC_KIND (DK_DEBUG, "debug
prefix does not matter. */
DEFINE_DIAGNOSTIC_KIND (DK_PEDWARN, "pedwarn: ")
DEFINE_DIAGNOSTIC_KIND (DK_PERMERROR, "permerror: ")
-
+/* This one is just for counting DK_WARNING promoted to DK_ERROR
+ due to -Werror and -Werror=warning. */
+DEFINE_DIAGNOSTIC_KIND (DK_WERROR, "error: ")
@@ -240,6 +240,8 @@ extern diagnostic_context *global_dc;
#define errorcount diagnostic_kind_count (global_dc, DK_ERROR)
/* Similarly, but for warnings. */
#define warningcount diagnostic_kind_count (global_dc, DK_WARNING)
+/* Similarly, but for warnings promoted to errors. */
+#define werrorcount diagnostic_kind_count (global_dc, DK_WERROR)
/* Similarly, but for sorrys. */
#define sorrycount diagnostic_kind_count (global_dc, DK_SORRY)
@@ -729,7 +729,10 @@ diagnostic_report_diagnostic (diagnostic
diagnostic->message.format_spec,
diagnostic->message.args_ptr);
}
- ++diagnostic_kind_count (context, diagnostic->kind);
+ if (diagnostic->kind == DK_ERROR && orig_diag_kind == DK_WARNING)
+ ++diagnostic_kind_count (context, DK_WERROR);
+ else
+ ++diagnostic_kind_count (context, diagnostic->kind);
saved_format_spec = diagnostic->message.format_spec;
if (context->show_option_requested)
@@ -1951,7 +1951,7 @@ toplev_main (int argc, char **argv)
if (!exit_after_options)
do_compile ();
- if (warningcount || errorcount)
+ if (warningcount || errorcount || werrorcount)
print_ignored_options ();
diagnostic_finish (global_dc);
@@ -1960,7 +1960,7 @@ toplev_main (int argc, char **argv)
finalize_plugins ();
location_adhoc_data_fini (line_table);
- if (seen_error ())
+ if (seen_error () || werrorcount)
return (FATAL_EXIT_CODE);
return (SUCCESS_EXIT_CODE);
@@ -5597,12 +5597,12 @@ convert_nontype_argument (tree type, tre
{
if (complain & tf_error)
{
- int errs = errorcount, warns = warningcount;
+ int errs = errorcount, warns = warningcount + werrorcount;
if (processing_template_decl
&& !require_potential_constant_expression (expr))
return NULL_TREE;
expr = cxx_constant_value (expr);
- if (errorcount > errs || warningcount > warns)
+ if (errorcount > errs || warningcount + werrorcount > warns)
inform (EXPR_LOC_OR_HERE (expr),
"in template argument for type %qT ", type);
if (expr == error_mark_node)
@@ -5709,12 +5709,12 @@ build_temp (tree expr, tree type, int fl
int savew, savee;
vec<tree, va_gc> *args;
- savew = warningcount, savee = errorcount;
+ savew = warningcount + werrorcount, savee = errorcount;
args = make_tree_vector_single (expr);
expr = build_special_member_call (NULL_TREE, complete_ctor_identifier,
&args, type, flags, complain);
release_tree_vector (args);
- if (warningcount > savew)
+ if (warningcount + werrorcount > savew)
*diagnostic_kind = DK_WARNING;
else if (errorcount > savee)
*diagnostic_kind = DK_ERROR;
@@ -750,7 +750,7 @@ synthesize_method (tree fndecl)
tree stmt;
location_t save_input_location = input_location;
int error_count = errorcount;
- int warning_count = warningcount;
+ int warning_count = warningcount + werrorcount;
/* Reset the source location, we might have been previously
deferred, and thus have saved where we were first needed. */
@@ -812,7 +812,7 @@ synthesize_method (tree fndecl)
pop_deferring_access_checks ();
- if (error_count != errorcount || warning_count != warningcount)
+ if (error_count != errorcount || warning_count != warningcount + werrorcount)
inform (input_location, "synthesized method %qD first required here ",
fndecl);
}
@@ -7967,11 +7967,11 @@ convert_for_initialization (tree exp, tr
int savew = 0, savee = 0;
if (fndecl)
- savew = warningcount, savee = errorcount;
+ savew = warningcount + werrorcount, savee = errorcount;
rhs = initialize_reference (type, rhs, flags, complain);
if (fndecl)
{
- if (warningcount > savew)
+ if (warningcount + werrorcount > savew)
warning (0, "in passing argument %P of %q+D", parmnum, fndecl);
else if (errorcount > savee)
error ("in passing argument %P of %q+D", parmnum, fndecl);