aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2010-04-09 15:45:52 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2010-04-09 15:45:52 +0000
commitd0b8780d9f4b5b5b98063995671e44d01712fcf9 (patch)
tree33d66ffcfaeb98cc4bfe250d9a22829ba7fb153c
parentcb6addf4a64fca93edee920a0014b73afd80adb1 (diff)
downloadgcc-d0b8780d9f4b5b5b98063995671e44d01712fcf9.zip
gcc-d0b8780d9f4b5b5b98063995671e44d01712fcf9.tar.gz
gcc-d0b8780d9f4b5b5b98063995671e44d01712fcf9.tar.bz2
re PR other/42965 (no "warnings being treated as errors" for individual -Werror=x options)
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. From-SVN: r158168
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/diagnostic.c48
-rw-r--r--gcc/diagnostic.h3
-rw-r--r--gcc/testsuite/ChangeLog30
-rw-r--r--gcc/testsuite/g++.dg/cpp/warning-directive-2.C2
-rw-r--r--gcc/testsuite/g++.dg/warn/unused-result1-Werror.c1
-rw-r--r--gcc/testsuite/gcc.dg/Wdeclaration-after-statement-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/Werror-4.c6
-rw-r--r--gcc/testsuite/gcc.dg/Werror-6.c4
-rw-r--r--gcc/testsuite/gcc.dg/Werror-9.c17
-rw-r--r--gcc/testsuite/gcc.dg/Werror-implicit-function-declaration.c3
-rw-r--r--gcc/testsuite/gcc.dg/Wfatal.c1
-rw-r--r--gcc/testsuite/gcc.dg/Wpointer-arith.c1
-rw-r--r--gcc/testsuite/gcc.dg/Wswitch-enum-error.c2
-rw-r--r--gcc/testsuite/gcc.dg/Wswitch-error.c1
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-comments-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-undef-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warning-directive-2.c2
-rw-r--r--gcc/testsuite/gfortran.dg/warning-directive-2.F902
-rw-r--r--gcc/toplev.c1
31 files changed, 109 insertions, 57 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2b3338e..e596c93 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+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.
+
2010-04-09 Jason Merrill <jason@redhat.com>
PR c++/42623
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 791deac..5df458b 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++;
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index de76477..65e8c7f 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -69,7 +69,7 @@ struct diagnostic_context
/* True if we should display the "warnings are being tread as error"
message, usually displayed once per compiler run. */
- bool issue_warnings_are_errors_message;
+ bool some_warnings_are_errors;
/* True if it has been requested that warnings be treated as errors. */
bool warning_as_error_requested;
@@ -206,6 +206,7 @@ extern diagnostic_context *global_dc;
/* Diagnostic related functions. */
extern void diagnostic_initialize (diagnostic_context *);
+extern void diagnostic_finish (diagnostic_context *);
extern void diagnostic_report_current_module (diagnostic_context *);
extern void diagnostic_report_current_function (diagnostic_context *,
diagnostic_info *);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ea156f6..b41206a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,33 @@
+2010-04-09 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR 42965
+ * 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.
+
2010-04-09 Jason Merrill <jason@redhat.com>
PR c++/42623
diff --git a/gcc/testsuite/g++.dg/cpp/warning-directive-2.C b/gcc/testsuite/g++.dg/cpp/warning-directive-2.C
index abd6427..c2efc17 100644
--- a/gcc/testsuite/g++.dg/cpp/warning-directive-2.C
+++ b/gcc/testsuite/g++.dg/cpp/warning-directive-2.C
@@ -1,4 +1,4 @@
// { dg-do preprocess }
// { dg-options "-fdiagnostics-show-option -Werror=cpp" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#warning "Printed" // { dg-error "\"Printed\" .-Wcpp." }
diff --git a/gcc/testsuite/g++.dg/warn/unused-result1-Werror.c b/gcc/testsuite/g++.dg/warn/unused-result1-Werror.c
index 033d707..fc14469 100644
--- a/gcc/testsuite/g++.dg/warn/unused-result1-Werror.c
+++ b/gcc/testsuite/g++.dg/warn/unused-result1-Werror.c
@@ -1,5 +1,6 @@
// PR 40614
// { dg-options "-Werror=unused-result" }
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
class QByteArray {
public:
QByteArray(const QByteArray &);
diff --git a/gcc/testsuite/gcc.dg/Wdeclaration-after-statement-3.c b/gcc/testsuite/gcc.dg/Wdeclaration-after-statement-3.c
index 63b2bac..f001edf 100644
--- a/gcc/testsuite/gcc.dg/Wdeclaration-after-statement-3.c
+++ b/gcc/testsuite/gcc.dg/Wdeclaration-after-statement-3.c
@@ -1,7 +1,7 @@
/* PR 35058: -Werror= works only with some warnings. */
/* { dg-do compile } */
/* { dg-options "-std=c99 -pedantic -Werror=declaration-after-statement" } */
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
extern void abort (void);
extern void exit (int);
diff --git a/gcc/testsuite/gcc.dg/Werror-4.c b/gcc/testsuite/gcc.dg/Werror-4.c
index 272f123..73687be 100644
--- a/gcc/testsuite/gcc.dg/Werror-4.c
+++ b/gcc/testsuite/gcc.dg/Werror-4.c
@@ -1,17 +1,17 @@
/* { dg-do compile } */
/* { dg-options "-Wattributes" } */
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
/* Make sure the pragma enables the error. */
#pragma GCC diagnostic error "-Waddress"
-void __attribute__((dj)) bar() { } /* { dg-warning ".* attribute directive ignored" } */
+void __attribute__((dj)) bar() { } /* { dg-warning "attribute directive ignored" } */
int i;
void
foo ()
{
- if (&i) /* { dg-error ".* will always evaluate as 'true'" } */
+ if (&i) /* { dg-error "will always evaluate as 'true'" } */
grill ();
}
diff --git a/gcc/testsuite/gcc.dg/Werror-6.c b/gcc/testsuite/gcc.dg/Werror-6.c
index 2c37717..a99c13b 100644
--- a/gcc/testsuite/gcc.dg/Werror-6.c
+++ b/gcc/testsuite/gcc.dg/Werror-6.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-Wattributes -Werror=address" } */
-
-/* Make sure -Werror-foo emits an error and not a warning */
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
+/* Make sure -Werror=foo emits an error and not a warning */
void __attribute__((dj)) bar() { } /* { dg-warning ".* attribute directive ignored" } */
diff --git a/gcc/testsuite/gcc.dg/Werror-9.c b/gcc/testsuite/gcc.dg/Werror-9.c
deleted file mode 100644
index 8705114..0000000
--- a/gcc/testsuite/gcc.dg/Werror-9.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-Wattributes" } */
-
-/* Make sure #pragma can enable a warning as an error. */
-
-#pragma GCC diagnostic error "-Waddress"
-
-void __attribute__((dj)) bar() { } /* { dg-warning ".* attribute directive ignored" } */
-
-int i;
-
-void
-foo ()
-{
- if (&i) /* { dg-error ".* will always evaluate as 'true'" } */
- grill ();
-}
diff --git a/gcc/testsuite/gcc.dg/Werror-implicit-function-declaration.c b/gcc/testsuite/gcc.dg/Werror-implicit-function-declaration.c
index 05b8c02..3261fc0 100644
--- a/gcc/testsuite/gcc.dg/Werror-implicit-function-declaration.c
+++ b/gcc/testsuite/gcc.dg/Werror-implicit-function-declaration.c
@@ -1,6 +1,7 @@
+/* Test the legacy option -Werror-implicit-function-declaration */
/* { dg-do compile } */
/* { dg-options "-std=c89 -Werror-implicit-function-declaration" } */
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
void f(void)
{
puts("Hello"); /* { dg-error "implicit declaration of function" } */
diff --git a/gcc/testsuite/gcc.dg/Wfatal.c b/gcc/testsuite/gcc.dg/Wfatal.c
index 3a10100..7ac260b 100644
--- a/gcc/testsuite/gcc.dg/Wfatal.c
+++ b/gcc/testsuite/gcc.dg/Wfatal.c
@@ -5,6 +5,7 @@
int i = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
int k = 1 / 0; /* { dg-error "division by zero" } */
int j = INT_MIN - 1;
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
/* { dg-message "terminated due to -Wfatal-errors" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gcc.dg/Wpointer-arith.c b/gcc/testsuite/gcc.dg/Wpointer-arith.c
index d7a19079..2d5b0ce 100644
--- a/gcc/testsuite/gcc.dg/Wpointer-arith.c
+++ b/gcc/testsuite/gcc.dg/Wpointer-arith.c
@@ -8,3 +8,4 @@ void *test(){
if(a) a++; /* { dg-error "wrong type argument to increment" } */
return a+x; /* { dg-error "pointer of type" } */
}
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
diff --git a/gcc/testsuite/gcc.dg/Wswitch-enum-error.c b/gcc/testsuite/gcc.dg/Wswitch-enum-error.c
index 383a29fb..9926840 100644
--- a/gcc/testsuite/gcc.dg/Wswitch-enum-error.c
+++ b/gcc/testsuite/gcc.dg/Wswitch-enum-error.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-Werror=switch-enum -Wswitch" } */
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
enum e { e1, e2 };
int
diff --git a/gcc/testsuite/gcc.dg/Wswitch-error.c b/gcc/testsuite/gcc.dg/Wswitch-error.c
index 31e3295..2fcd1dd 100644
--- a/gcc/testsuite/gcc.dg/Wswitch-error.c
+++ b/gcc/testsuite/gcc.dg/Wswitch-error.c
@@ -61,3 +61,4 @@ foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el,
}
return 0;
}
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c b/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c
index 5a17f2b..107e6bf 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c
@@ -1,6 +1,6 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=comments" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
/* /* */ // { dg-error "\"\.\*\" within comment .-Wcomments." }
// \
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c b/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c
index 6bf7d55..91cad7c 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c
@@ -1,4 +1,4 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=c++-compat" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#define not ! // { dg-error "identifier \"not\" is a special operator name in C\\+\\+ .-Wc\\+\\+-compat." }
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c b/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c
index b9cfffb..600e2f6 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c
@@ -1,6 +1,6 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=deprecated" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#assert x(x) // { dg-error "#assert is a deprecated GCC extension .-Wdeprecated." }
#if #x(x) // { dg-error "assertions are a deprecated extension .-Wdeprecated." }
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c b/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c
index 11eb5fb..08fef13 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c
@@ -1,6 +1,6 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wtraditional -Werror=long-long" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#if 0LL // { dg-error "traditional C rejects the \"LL\" suffix .-Wlong-long." }
// { dg-error "use of C99 long long integer constant .-Wlong-long." "use long long" { target *-*-* } 4 }
#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c b/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c
index 31d33bb..38d3a98 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c
@@ -1,5 +1,5 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=multichar" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#if 'abc' // { dg-error "multi-character character constant .-Wmultichar." }
#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c b/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c
index 380c670..2040394 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c
@@ -1,5 +1,5 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -fextended-identifiers -Werror=normalized=" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
// { dg-prune-output ".*-Werror=normalized=: Set -Wnormalized=nfc.*" }
\u0F43 // { dg-error "`.U00000f43' is not in NFC .-Wnormalized=." }
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c b/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c
index 83cc3df..b943355 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c
@@ -1,6 +1,6 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=builtin-macro-redefined" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#ifndef __TIME__
#error "__TIME__ builtin is not defined"
// { dg-bogus "__TIME__ builtin is not defined" "no-time" { target *-*-* } 5 }
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c b/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c
index cb5f690..5203c28 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c
@@ -1,6 +1,6 @@
// { dg-do compile }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=traditional -Wno-deprecated -Wno-long-long" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#assert x(x) // { dg-error "suggest hiding #assert from traditional C with an indented # .-Wtraditional." }
#define X X // { dg-error "traditional C ignores #define with the # indented .-Wtraditional." }
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c
index a993e2a..586c363 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c
@@ -1,4 +1,4 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -trigraphs -Werror=trigraphs" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
??= // { dg-error "trigraph \\?\\?= converted to # .-Wtrigraphs." }
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c
index 240ae0f..ba0dd51 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c
@@ -1,4 +1,4 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=trigraphs" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
??= // { dg-error "trigraph \\?\\?= ignored, use -trigraphs to enable .-Wtrigraphs." }
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c b/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c
index 4eb80e0..c9f8731 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c
@@ -1,5 +1,5 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=undef" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#if x // { dg-error "\"x\" is not defined .-Wundef." }
#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c b/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c
index 58eeebf..4bd679c 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c
@@ -1,4 +1,4 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=unused-macros" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#define X X // { dg-error "macro \"X\" is not used .-Wunused-macros." }
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c b/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c
index f43d96a..8b6d165 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c
@@ -1,6 +1,6 @@
/* { dg-do preprocess } */
/* { dg-options "-ansi -fdiagnostics-show-option -pedantic -Werror=variadic-macros" } */
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#define F(...) X /* { dg-error "anonymous variadic macros were introduced in C99 .-Wvariadic-macros." } */
#define G(X...) X /* { dg-error "ISO C does not permit named variadic macros .-Wvariadic-macros." } */
diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c
index 0889803..753b84a 100644
--- a/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c
@@ -1,4 +1,4 @@
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=cpp" }
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#warning "Printed" // { dg-error "\"Printed\" .-Wcpp." }
diff --git a/gcc/testsuite/gfortran.dg/warning-directive-2.F90 b/gcc/testsuite/gfortran.dg/warning-directive-2.F90
index 75b78bf..5b40d69f 100644
--- a/gcc/testsuite/gfortran.dg/warning-directive-2.F90
+++ b/gcc/testsuite/gfortran.dg/warning-directive-2.F90
@@ -1,5 +1,5 @@
! { dg-do preprocess }
! { dg-options "-std=f95 -fdiagnostics-show-option -Werror=cpp" }
-
+! { dg-warning "some warnings being treated as errors" "" {target "*-*-*"} 0 }
#warning "Printed"
! { dg-error "\"Printed\" .-Wcpp." "" { target *-*-* } 4 }
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 798f0d4..996bd90 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2466,6 +2466,7 @@ toplev_main (int argc, char **argv)
if (warningcount || errorcount)
print_ignored_options ();
+ diagnostic_finish (global_dc);
/* Invoke registered plugin callbacks if any. */
invoke_plugin_callbacks (PLUGIN_FINISH, NULL);