Commit 5bcc5a3b by Martin Liska Committed by Martin Liska

Add option suggestion for -Werror=foo and corresponding pragma.

2019-04-30  Martin Liska  <mliska@suse.cz>

	* opts.c (enable_warning_as_error): Provide hints
	for unknown options.
2019-04-30  Martin Liska  <mliska@suse.cz>

	* c-pragma.c (handle_pragma_diagnostic): Provide hints
	for unknown options.
2019-04-30  Martin Liska  <mliska@suse.cz>

	* gcc.dg/Werror-13.c: Add new tests for it.
	* gcc.dg/pragma-diag-6.c: Likewise.

From-SVN: r270693
parent 44bf4743
2019-04-30 Martin Liska <mliska@suse.cz> 2019-04-30 Martin Liska <mliska@suse.cz>
* opts.c (enable_warning_as_error): Provide hints
for unknown options.
2019-04-30 Martin Liska <mliska@suse.cz>
PR debug/90288 PR debug/90288
* doc/invoke.texi: Add missing dash for gas-locview-support * doc/invoke.texi: Add missing dash for gas-locview-support
and gno-as-locview-support. and gno-as-locview-support.
......
2019-04-30 Martin Liska <mliska@suse.cz>
* c-pragma.c (handle_pragma_diagnostic): Provide hints
for unknown options.
2019-04-26 Richard Sandiford <richard.sandiford@arm.com> 2019-04-26 Richard Sandiford <richard.sandiford@arm.com>
* c-warn.c (strict_aliasing_warning): Apply COMPLETE_TYPE_P to * c-warn.c (strict_aliasing_warning): Apply COMPLETE_TYPE_P to
......
...@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "c-pragma.h" #include "c-pragma.h"
#include "opts.h" #include "opts.h"
#include "plugin.h" #include "plugin.h"
#include "opt-suggestions.h"
#define GCC_BAD(gmsgid) \ #define GCC_BAD(gmsgid) \
do { warning (OPT_Wpragmas, gmsgid); return; } while (0) do { warning (OPT_Wpragmas, gmsgid); return; } while (0)
...@@ -804,8 +805,16 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy)) ...@@ -804,8 +805,16 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
unsigned int option_index = find_opt (option_string + 1, lang_mask); unsigned int option_index = find_opt (option_string + 1, lang_mask);
if (option_index == OPT_SPECIAL_unknown) if (option_index == OPT_SPECIAL_unknown)
{ {
warning_at (loc, OPT_Wpragmas, option_proposer op;
"unknown option after %<#pragma GCC diagnostic%> kind"); const char *hint = op.suggest_option (option_string + 1);
if (hint)
warning_at (loc, OPT_Wpragmas,
"unknown option after %<#pragma GCC diagnostic%> kind;"
" did you mean %<-%s%>", hint);
else
warning_at (loc, OPT_Wpragmas,
"unknown option after %<#pragma GCC diagnostic%> kind");
return; return;
} }
else if (!(cl_options[option_index].flags & CL_WARNING)) else if (!(cl_options[option_index].flags & CL_WARNING))
......
...@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "insn-attr-common.h" #include "insn-attr-common.h"
#include "common/common-target.h" #include "common/common-target.h"
#include "spellcheck.h" #include "spellcheck.h"
#include "opt-suggestions.h"
static void set_Wstrict_aliasing (struct gcc_options *opts, int onoff); static void set_Wstrict_aliasing (struct gcc_options *opts, int onoff);
...@@ -3088,10 +3089,20 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask, ...@@ -3088,10 +3089,20 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
strcpy (new_option + 1, arg); strcpy (new_option + 1, arg);
option_index = find_opt (new_option, lang_mask); option_index = find_opt (new_option, lang_mask);
if (option_index == OPT_SPECIAL_unknown) if (option_index == OPT_SPECIAL_unknown)
error_at (loc, "%<-Werror=%s%>: no option -%s", arg, new_option); {
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 if (!(cl_options[option_index].flags & CL_WARNING)) else if (!(cl_options[option_index].flags & CL_WARNING))
error_at (loc, "%<-Werror=%s%>: -%s is not an option that controls " error_at (loc, "%<-Werror=%s%>: %<-%s%> is not an option that "
"warnings", arg, new_option); "controls warnings", arg, new_option);
else else
{ {
const diagnostic_t kind = value ? DK_ERROR : DK_WARNING; const diagnostic_t kind = value ? DK_ERROR : DK_WARNING;
......
2019-04-30 Martin Liska <mliska@suse.cz>
* gcc.dg/Werror-13.c: Add new tests for it.
* gcc.dg/pragma-diag-6.c: Likewise.
2019-04-30 Jakub Jelinek <jakub@redhat.com> 2019-04-30 Jakub Jelinek <jakub@redhat.com>
PR target/89093 PR target/89093
......
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-Werror=error -Werror=p, -Werror=l, -Werror=fatal-errors" } */ /* { dg-options "-Werror=error -Werror=p, -Werror=l, -Werror=fatal-errors -Werror=vla2 -Wno-error=misleading-indentation2" } */
/* { dg-error "-Wp, is not an option that controls warnings" "" { target *-*-* } 0 } */ /* { dg-error "'-Wp,' is not an option that controls warnings" "" { target *-*-* } 0 } */
/* { dg-error "-Wl, is not an option that controls warnings" "" { target *-*-* } 0 } */ /* { dg-error "'-Wl,' is not an option that controls warnings" "" { target *-*-* } 0 } */
/* { dg-error "-Werror is not an option that controls warnings" "" { target *-*-* } 0 } */ /* { 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 "'-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 } */
int i; int i;
...@@ -2,4 +2,7 @@ ...@@ -2,4 +2,7 @@
#pragma GCC diagnostic error "-Wnoexcept" /* { dg-warning "is valid for C../ObjC.. but not for C" } */ #pragma GCC diagnostic error "-Wnoexcept" /* { dg-warning "is valid for C../ObjC.. but not for C" } */
#pragma GCC diagnostic error "-fstrict-aliasing" /* { dg-warning "not an option that controls warnings" } */ #pragma GCC diagnostic error "-fstrict-aliasing" /* { dg-warning "not an option that controls warnings" } */
#pragma GCC diagnostic error "-Werror" /* { dg-warning "not an option that controls warnings" } */ #pragma GCC diagnostic error "-Werror" /* { dg-warning "not an option that controls warnings" } */
#pragma GCC diagnostic error "-Wvla2" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind; did you mean '-Wvla'" } */
#pragma GCC diagnostic error "-Walla" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind; did you mean '-Wall'" } */
#pragma GCC diagnostic warning "-Walla" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind; did you mean '-Wall'" } */
int i; int i;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment