This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Show dangerous warning when -Werror option is used


Command line option -Werror is dangerous as it could cause problems for
compiling applications in future. Once gcc introduces a new warning or
change logic for existing warnings then compilation of existing
application via gcc could throw a new warning.

As -Werror makes all warnings fatal, it makes applications not
compilable. -Werror makes sense only for specific gcc versions against
which was application tested to compile correctly.

Attached patch adds a new warning when -Werror command line option is
enabled. It warns user that usage of -Werror can be dangerous.

-- 
Pali Rohár
pali.rohar@gmail.com
--- gcc/opts.c	2016-03-17 16:11:35.000000000 +0100
+++ gcc/opts.c	2018-04-01 10:40:50.758086301 +0200
@@ -1773,6 +1773,10 @@ common_handle_option (struct gcc_options
 
     case OPT_Werror:
       dc->warning_as_error_requested = value;
+      if (value)
+	warning_at (loc, 0, "command line option %qs is dangerous; "
+		    "in future newly introduced non-fatal warnings "
+		    "can cause fatal errors", "-Werror");
       break;
 
     case OPT_Werror_:

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]