summaryrefslogtreecommitdiff
path: root/gcc/diagnostic.c
diff options
context:
space:
mode:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2010-04-09 15:45:52 +0000
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2010-04-09 15:45:52 +0000
commit543725f3e0125e211ea53f275146ca2de3101cc1 (patch)
tree33d66ffcfaeb98cc4bfe250d9a22829ba7fb153c /gcc/diagnostic.c
parent9c719c74a549d518bc38965e0a48f78d3d02adf0 (diff)
downloadgcc-543725f3e0125e211ea53f275146ca2de3101cc1.tar.gz
2010-04-09 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR 42965 * diagnostic.c (diagnostic_initialize): Initialize some_warnings_are_errors. (diagnostic_finish): New. (diagnostic_action_after_output): Call it before exiting. (diagnostic_report_diagnostic): Do not print message here. Set some_warnings_are_errors. * diagnostic.h (diagnostic_context): Delete issue_warnings_are_errors_message. Add some_warnings_are_errors. (diagnostic_finish): Declare. * toplev.c (toplev_main): Call it before exit. testsuite/ * gcc.dg/Werror-6.c: Adjust. * gcc.dg/Werror-implicit-function-declaration.c: Likewise. * gcc.dg/Werror-4.c: Likewise. * gcc.dg/Wdeclaration-after-statement-3.c: Likewise. * gcc.dg/Wswitch-enum-error.c: Likewise. * gcc.dg/Wpointer-arith.c: Likewise. * gcc.dg/Wfatal.c: Likewise. * gcc.dg/Wswitch-error.c: Likewise. * g++.dg/warn/unused-result1-Werror.c: Likewise. * gcc.dg/Werror-9.c: Delete. Duplicate of Werror-4.c. * gcc.dg/cpp/warn-undef-2.c: Likewise. * gcc.dg/cpp/warn-traditional-2.c: Likewise. * gcc.dg/cpp/warn-comments-2.c: Likewise. * gcc.dg/cpp/warn-variadic-2.c: Likewise. * gcc.dg/cpp/warning-directive-2.c: Likewise. * gcc.dg/cpp/warn-long-long-2.c: Likewise. * gcc.dg/cpp/warn-deprecated-2.c: Likewise. * gcc.dg/cpp/warn-multichar-2.c: Likewise. * gcc.dg/cpp/warn-normalized-3.c: Likewise. * gcc.dg/cpp/warn-cxx-compat-2.c: Likewise. * gcc.dg/cpp/warn-trigraphs-3.c: Likewise. * gcc.dg/cpp/warn-unused-macros-2.c: Likewise. * gcc.dg/cpp/warn-trigraphs-4.c: Likewise. * gcc.dg/cpp/warn-redefined-2.c: Likewise. * g++.dg/cpp/warning-directive-2.C: Likewise. * gfortran.dg/warning-directive-2.F90: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158168 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r--gcc/diagnostic.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 791deacd636..5df458b465e 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -97,7 +97,7 @@ diagnostic_initialize (diagnostic_context *context)
context->printer->wrapping.rule = DIAGNOSTICS_SHOW_PREFIX_ONCE;
memset (context->diagnostic_count, 0, sizeof context->diagnostic_count);
- context->issue_warnings_are_errors_message = true;
+ context->some_warnings_are_errors = false;
context->warning_as_error_requested = false;
memset (context->classify_diagnostic, DK_UNSPECIFIED,
sizeof context->classify_diagnostic);
@@ -112,6 +112,28 @@ diagnostic_initialize (diagnostic_context *context)
context->inhibit_notes_p = false;
}
+/* Do any cleaning up required after the last diagnostic is emitted. */
+
+void
+diagnostic_finish (diagnostic_context *context)
+{
+ /* Some of the errors may actually have been warnings. */
+ if (context->some_warnings_are_errors)
+ {
+ /* -Werror was given. */
+ if (context->warning_as_error_requested)
+ pp_verbatim (context->printer,
+ _("%s: all warnings being treated as errors\n"),
+ progname);
+ /* At least one -Werror= was given. */
+ else
+ pp_verbatim (context->printer,
+ _("%s: some warnings being treated as errors\n"),
+ progname);
+ pp_flush (context->printer);
+ }
+}
+
/* Initialize DIAGNOSTIC, where the message MSG has already been
translated. */
void
@@ -184,6 +206,7 @@ diagnostic_action_after_output (diagnostic_context *context,
if (flag_fatal_errors)
{
fnotice (stderr, "compilation terminated due to -Wfatal-errors.\n");
+ diagnostic_finish (context);
exit (FATAL_EXIT_CODE);
}
break;
@@ -200,7 +223,7 @@ diagnostic_action_after_output (diagnostic_context *context,
case DK_FATAL:
if (context->abort_on_error)
real_abort ();
-
+ diagnostic_finish (context);
fnotice (stderr, "compilation terminated.\n");
exit (FATAL_EXIT_CODE);
@@ -309,7 +332,7 @@ diagnostic_report_diagnostic (diagnostic_context *context,
diagnostic_info *diagnostic)
{
location_t location = diagnostic->location;
- bool maybe_print_warnings_as_errors_message = false;
+ diagnostic_t orig_diag_kind = diagnostic->kind;
const char *saved_format_spec;
/* Give preference to being able to inhibit warnings, before they
@@ -319,7 +342,11 @@ diagnostic_report_diagnostic (diagnostic_context *context,
return false;
if (diagnostic->kind == DK_PEDWARN)
- diagnostic->kind = pedantic_warning_kind ();
+ {
+ diagnostic->kind = pedantic_warning_kind ();
+ /* We do this to avoid giving the message for -pedantic-errors. */
+ orig_diag_kind = diagnostic->kind;
+ }
if (diagnostic->kind == DK_NOTE && context->inhibit_notes_p)
return false;
@@ -343,7 +370,6 @@ diagnostic_report_diagnostic (diagnostic_context *context,
&& diagnostic->kind == DK_WARNING)
{
diagnostic->kind = DK_ERROR;
- maybe_print_warnings_as_errors_message = true;
}
if (diagnostic->option_index)
@@ -357,7 +383,6 @@ diagnostic_report_diagnostic (diagnostic_context *context,
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. */
@@ -365,15 +390,8 @@ diagnostic_report_diagnostic (diagnostic_context *context,
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;
- }
+ if (orig_diag_kind == DK_WARNING && diagnostic->kind == DK_ERROR)
+ context->some_warnings_are_errors = true;
context->lock++;