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
+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
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);
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
if (flag_fatal_errors)
{
fnotice (stderr, "compilation terminated due to -Wfatal-errors.\n");
+ diagnostic_finish (context);
exit (FATAL_EXIT_CODE);
}
break;
case DK_FATAL:
if (context->abort_on_error)
real_abort ();
-
+ diagnostic_finish (context);
fnotice (stderr, "compilation terminated.\n");
exit (FATAL_EXIT_CODE);
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
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;
&& diagnostic->kind == DK_WARNING)
{
diagnostic->kind = DK_ERROR;
- maybe_print_warnings_as_errors_message = true;
}
if (diagnostic->option_index)
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. */
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++;
/* 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;
/* 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 *);
+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
// { 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." }
// PR 40614
// { dg-options "-Werror=unused-result" }
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
class QByteArray {
public:
QByteArray(const QByteArray &);
/* 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);
/* { 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 ();
}
/* { 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" } */
+++ /dev/null
-/* { 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 ();
-}
+/* 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" } */
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 } */
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 } */
/* { dg-do compile } */
/* { dg-options "-Werror=switch-enum -Wswitch" } */
-
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
enum e { e1, e2 };
int
}
return 0;
}
+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
// { 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." }
// \
// { 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." }
// { 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." }
// { 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
// { 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
// { 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=." }
// { 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 }
// { 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." }
// { 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." }
// { 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." }
// { 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
// { 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." }
/* { 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." } */
// { 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." }
! { 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 }
if (warningcount || errorcount)
print_ignored_options ();
+ diagnostic_finish (global_dc);
/* Invoke registered plugin callbacks if any. */
invoke_plugin_callbacks (PLUGIN_FINISH, NULL);