On 3/18/19 8:46 PM, Alex Henrie wrote:
From: Manuel López-Ibáñez <m...@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..0b2550a4855 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,
+ "-Wno-error=%s: no option -W%s", opt, opt);
Please remember to quote the command line options in the message
(same as in the error below):
+ }
}
/* Handle an unknown option DECODED, returning true if an error should
diff --git a/gcc/opts.c b/gcc/opts.c
index 3161e0b6753..4fa79306e30 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -3079,7 +3079,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);
^^^^^^^^^^^^^^
Like that.
Thanks
Martin
+ 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