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


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

	* opts-common.c (ignored_wnoerror_options): New global variable.
	* opts-global.c (print_ignored_options): Ignore
	-Wno-error=<some-future-warning> except if there are other
	diagnostics.
	* opts.c (enable_warning_as_error): Record ignored -Wno-error
	options.
	* opts.h (ignored_wnoerror_options): Declare.
	* gcc.dg/Werror-13.c: Don't expect hints for
	-Wno-error=<some-future-warning>.
---
 gcc/opts-common.c                |  2 ++
 gcc/opts-global.c                | 10 +++++++---
 gcc/opts.c                       | 21 +++++++++++++--------
 gcc/opts.h                       |  2 ++
 gcc/testsuite/gcc.dg/Werror-13.c |  2 +-
 5 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index e2a315ba229..86e518bdd2b 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 7c5bd16c7ea..b4b4576e450 100644
--- a/gcc/opts-global.c
+++ b/gcc/opts-global.c
@@ -136,12 +136,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,
+		  "%<-Wno-error=%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 bb0d8b5e7db..a78e5cf1949 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -3175,15 +3175,20 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
   option_index = find_opt (new_option, lang_mask);
   if (option_index == OPT_SPECIAL_unknown)
     {
-      option_proposer op;
-      const char *hint = op.suggest_option (new_option);
-      if (hint)
-	error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>;"
-		  " did you mean %<-%s%>?", value ? "" : "no-",
-		  arg, new_option, hint);
+      if (value)
+	{
+	  option_proposer op;
+	  const char *hint = op.suggest_option (new_option);
+	  if (hint)
+	    error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>;"
+		      " did you mean %<-%s%>?", value ? "" : "no-",
+		      arg, new_option, hint);
+	  else
+	    error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>",
+		      value ? "" : "no-", arg, new_option);
+	}
       else
-	error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>",
-		  value ? "" : "no-", arg, new_option);
+	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 "
diff --git a/gcc/opts.h b/gcc/opts.h
index 47223229388..ac281aef540 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -461,4 +461,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
diff --git a/gcc/testsuite/gcc.dg/Werror-13.c b/gcc/testsuite/gcc.dg/Werror-13.c
index 3a02b7ea2b5..7c2bf6836ed 100644
--- a/gcc/testsuite/gcc.dg/Werror-13.c
+++ b/gcc/testsuite/gcc.dg/Werror-13.c
@@ -5,6 +5,6 @@
 /* { dg-error "'-Werror' is not an option that controls warnings" "" { target *-*-* } 0 } */
 /* { dg-error "'-Wfatal-errors' is not an option that controls warnings" "" { target *-*-* } 0 } */
 /* { dg-error "'-Werror=vla2': no option '-Wvla2'; did you mean '-Wvla." "" { target *-*-* } 0 } */
-/* { dg-error "'-Wno-error=misleading-indentation2': no option '-Wmisleading-indentation2'; did you mean '-Wmisleading-indentation'" "" { target *-*-* } 0 } */
+/* { dg-warning "'-Wno-error=misleading-indentation2': no option '-Wmisleading-indentation2'" "" { target *-*-* } 0 } */
 
 int i;
-- 
2.23.0


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