Hi,
I was having a look to this long standing, and unconfirmed, PR:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36778
and the rationale makes sense to me. What do you think, shall we have
-Wfatal-warnings too, together with -Wfatal-errors?
AFAICS, the patch would be rather trivial, little more than the
attached, modulo a few tests and a few lines of documentation...
Thanks!
Paolo.
Index: diagnostic.c
===================================================================
--- diagnostic.c (revision 179406)
+++ diagnostic.c (working copy)
@@ -1,6 +1,6 @@
/* Language-independent diagnostic subroutines for the GNU Compiler Collection
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
- 2009, 2010 Free Software Foundation, Inc.
+ 2009, 2010, 2011 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <g...@codesourcery.com>
This file is part of GCC.
@@ -107,6 +107,7 @@ diagnostic_initialize (diagnostic_context *context
context->permissive = false;
context->opt_permissive = 0;
context->fatal_errors = false;
+ context->fatal_warnings = false;
context->dc_inhibit_warnings = false;
context->dc_warn_system_headers = false;
context->max_errors = 0;
@@ -207,7 +208,15 @@ diagnostic_action_after_output (diagnostic_context
case DK_DEBUG:
case DK_NOTE:
case DK_ANACHRONISM:
+ break;
+
case DK_WARNING:
+ if (context->fatal_warnings)
+ {
+ fnotice (stderr, "compilation terminated due to -Wfatal-warnings.\n");
+ diagnostic_finish (context);
+ exit (FATAL_EXIT_CODE);
+ }
break;
case DK_ERROR:
Index: diagnostic.h
===================================================================
--- diagnostic.h (revision 179406)
+++ diagnostic.h (working copy)
@@ -1,6 +1,6 @@
/* Various declarations for language-independent diagnostics subroutines.
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
- 2010, Free Software Foundation, Inc.
+ 2010, 2011 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <g...@codesourcery.com>
This file is part of GCC.
@@ -122,6 +122,9 @@ struct diagnostic_context
/* True if errors are fatal. */
bool fatal_errors;
+ /* True if warnings are fatal. */
+ bool fatal_warnings;
+
/* True if all warnings should be disabled. */
bool dc_inhibit_warnings;
Index: opts.c
===================================================================
--- opts.c (revision 179406)
+++ opts.c (working copy)
@@ -1433,6 +1433,10 @@ common_handle_option (struct gcc_options *opts,
dc->fatal_errors = value;
break;
+ case OPT_Wfatal_warnings:
+ dc->fatal_warnings = value;
+ break;
+
case OPT_Wframe_larger_than_:
opts->x_frame_larger_than_size = value;
opts->x_warn_frame_larger_than = value != -1;
Index: fortran/error.c
===================================================================
--- fortran/error.c (revision 179406)
+++ fortran/error.c (working copy)
@@ -833,6 +833,9 @@ gfc_warning_now (const char *gmsgid, ...)
gfc_increment_error_count();
buffer_flag = i;
+
+ if (flag_fatal_warnings)
+ exit (FATAL_EXIT_CODE);
}
@@ -857,6 +860,9 @@ gfc_warning_check (void)
if (warning_buffer.message != NULL)
fputs (warning_buffer.message, stderr);
warning_buffer.flag = 0;
+
+ if (flag_fatal_warnings)
+ exit (FATAL_EXIT_CODE);
}
}
Index: common.opt
===================================================================
--- common.opt (revision 179406)
+++ common.opt (working copy)
@@ -539,6 +539,10 @@ Wfatal-errors
Common Var(flag_fatal_errors)
Exit on the first error occurred
+Wfatal-warnings
+Common Var(flag_fatal_warnings)
+Exit on the first warning occurred
+
Wframe-larger-than=
Common RejectNegative Joined UInteger
-Wframe-larger-than=<number> Warn if a function's stack frame requires more
than <number> bytes