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]

Re: [PATCH][stage1] Add option suggestion for -Werror=foo and corresponding pragma.


On 3/5/19 7:14 AM, Martin Liška wrote:
Hi.

The patch extends option suggestion for both -Werror and corresponding
pragram.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed after stage1 opens?
Thanks,
Martin

gcc/ChangeLog:

2019-03-05  Martin Liska  <mliska@suse.cz>

	* opts.c (enable_warning_as_error): Provide hints
	for unknown options.

gcc/c-family/ChangeLog:

2019-03-05  Martin Liska  <mliska@suse.cz>

	* c-pragma.c (handle_pragma_diagnostic): Provide hints
	for unknown options.

gcc/testsuite/ChangeLog:

2019-03-05  Martin Liska  <mliska@suse.cz>

	* gcc.dg/Werror-13.c: Add new tests for it.
	* gcc.dg/pragma-diag-6.c: Likewise.
---
  gcc/c-family/c-pragma.c              | 13 +++++++++++--
  gcc/opts.c                           | 17 ++++++++++++++---
  gcc/testsuite/gcc.dg/Werror-13.c     | 12 +++++++-----
  gcc/testsuite/gcc.dg/pragma-diag-6.c |  3 +++
  4 files changed, 35 insertions(+), 10 deletions(-)

Nice cleanup!

@@ -804,8 +805,16 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
   unsigned int option_index = find_opt (option_string + 1, lang_mask);
   if (option_index == OPT_SPECIAL_unknown)
     {
-      warning_at (loc, OPT_Wpragmas,
-		  "unknown option after %<#pragma GCC diagnostic%> kind");
+      option_proposer op;
+      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);

The "did you mean..." part is missing a question mark at the end.

Martin


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