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 v2 1/2] PR c/65403 - Ignore -Wno-error=<some-future-warning>


From: Manuel López-Ibáñez <manu@gcc.gnu.org>

* opts.c: Ignore -Wno-error=<some-future-warning> except if there are
other diagnostics.
---
 gcc/opts-common.c |  2 ++
 gcc/opts-global.c | 10 +++++++---
 gcc/opts.c        |  5 ++++-
 gcc/opts.h        |  2 ++
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index edbb3ac9b6d..36e06e2372a 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -26,6 +26,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "spellcheck.h"
 
+vec<const char *> ignored_wnoerror_options;
+
 static void prune_options (struct cl_decoded_option **, unsigned int *);
 
 /* An option that is undocumented, that takes a joined argument, and
diff --git a/gcc/opts-global.c b/gcc/opts-global.c
index a5e9ef0237a..bef020a4c46 100644
--- a/gcc/opts-global.c
+++ b/gcc/opts-global.c
@@ -132,12 +132,16 @@ print_ignored_options (void)
 {
   while (!ignored_options.is_empty ())
     {
-      const char *opt;
-
-      opt = ignored_options.pop ();
+      const char * opt = ignored_options.pop ();
       warning_at (UNKNOWN_LOCATION, 0,
 		  "unrecognized command line option %qs", opt);
     }
+  while (!ignored_wnoerror_options.is_empty ())
+    {
+      const char * opt = ignored_wnoerror_options.pop ();
+      warning_at (UNKNOWN_LOCATION, 0,
+		  "%<-Werror=%s%>: no option -W%s", opt, opt);
+    }
 }
 
 /* Handle an unknown option DECODED, returning true if an error should
diff --git a/gcc/opts.c b/gcc/opts.c
index 02f6b4656e1..492a50ba326 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -3087,7 +3087,10 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
   strcpy (new_option + 1, arg);
   option_index = find_opt (new_option, lang_mask);
   if (option_index == OPT_SPECIAL_unknown)
-    error_at (loc, "%<-Werror=%s%>: no option -%s", arg, new_option);
+    if (value)
+      error_at (loc, "%<-Werror=%s%>: no option -%s", arg, new_option);
+    else
+      ignored_wnoerror_options.safe_push (arg);
   else if (!(cl_options[option_index].flags & CL_WARNING))
     error_at (loc, "%<-Werror=%s%>: -%s is not an option that controls "
 	      "warnings", arg, new_option);
diff --git a/gcc/opts.h b/gcc/opts.h
index f14d9bcb896..b18504e0bc3 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -456,4 +456,6 @@ extern bool parse_and_check_align_values (const char *flag,
 					  bool report_error,
 					  location_t loc);
 
+extern vec<const char *> ignored_wnoerror_options;
+
 #endif
-- 
2.21.0


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