@@ -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
@@ -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);
+ }
}
/* Handle an unknown option DECODED, returning true if an error should
@@ -3095,15 +3095,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 "
@@ -460,4 +460,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
@@ -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;
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(-)