* [PATCH] Do not suggest -fsanitize=all (PR driver/78863).
@ 2016-12-21 9:40 Martin Liška
2016-12-21 10:05 ` Jakub Jelinek
0 siblings, 1 reply; 7+ messages in thread
From: Martin Liška @ 2016-12-21 9:40 UTC (permalink / raw)
To: GCC Patches; +Cc: David Malcolm
[-- Attachment #1: Type: text/plain, Size: 247 bytes --]
As mentioned in the PR, we should not suggest option that is not allowed.
Fixed by explicit removal of suggestions that are not acceptable.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
Ready to be installed?
Martin
[-- Attachment #2: 0001-Do-not-suggest-fsanitize-all-PR-driver-78863.patch --]
[-- Type: text/x-patch, Size: 3217 bytes --]
From 1a2d5614e9a0515659f50b457ef031c1f80f4a7c Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 20 Dec 2016 12:16:02 +0100
Subject: [PATCH] Do not suggest -fsanitize=all (PR driver/78863).
gcc/ChangeLog:
2016-12-20 Martin Liska <mliska@suse.cz>
PR driver/78863
* gcc.c (driver::build_option_suggestions): Call
remove_misspelling_candidate for -fsanitize=all.
* opts-common.c (remove_misspelling_candidate): New function.
* opts.h (remove_misspelling_candidate): Likewise.
gcc/testsuite/ChangeLog:
2016-12-20 Martin Liska <mliska@suse.cz>
PR driver/78863
* gcc.dg/spellcheck-options-13.c: New test.
---
gcc/gcc.c | 4 ++++
gcc/opts-common.c | 17 +++++++++++++++++
gcc/opts.h | 2 ++
gcc/testsuite/gcc.dg/spellcheck-options-13.c | 5 +++++
4 files changed, 28 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/spellcheck-options-13.c
diff --git a/gcc/gcc.c b/gcc/gcc.c
index f78acd68606..1240e8a176b 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -7748,6 +7748,10 @@ driver::build_option_suggestions (void)
break;
}
}
+
+ /* PR driver/78863: skip -fsanitize=all. */
+ remove_misspelling_candidate (m_option_suggestions, "fsanitize=all");
+ remove_misspelling_candidate (m_option_suggestions, "-sanitize=all");
}
/* Helper function for driver::handle_unrecognized_options.
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index e9d1c20a1f3..d5d81de8a5f 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -413,6 +413,23 @@ add_misspelling_candidates (auto_vec<char *> *candidates,
}
}
+/* Helper function for gcc.c's driver which removes OPT_TEXT from
+ list of CANDIDATES. */
+
+void
+remove_misspelling_candidate (auto_vec<char *> *candidates,
+ const char *opt_text)
+{
+ for (unsigned i = 0; i < candidates->length (); i++)
+ {
+ if (strcmp ((*candidates)[i], opt_text) == 0)
+ {
+ candidates->ordered_remove (i);
+ return;
+ }
+ }
+}
+
/* Decode the switch beginning at ARGV for the language indicated by
LANG_MASK (including CL_COMMON and CL_TARGET if applicable), into
the structure *DECODED. Returns the number of switches
diff --git a/gcc/opts.h b/gcc/opts.h
index b3e64353c8a..052aa54cee4 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -420,6 +420,8 @@ extern const struct sanitizer_opts_s
extern void add_misspelling_candidates (auto_vec<char *> *candidates,
const struct cl_option *option,
const char *base_option);
+extern void remove_misspelling_candidate (auto_vec<char *> *candidates,
+ const char *opt_text);
extern const char *candidates_list_and_hint (const char *arg, char *&str,
const auto_vec <const char *> &
candidates);
diff --git a/gcc/testsuite/gcc.dg/spellcheck-options-13.c b/gcc/testsuite/gcc.dg/spellcheck-options-13.c
new file mode 100644
index 00000000000..19b63af565b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/spellcheck-options-13.c
@@ -0,0 +1,5 @@
+/* PR driver/78863. */
+
+/* { dg-do compile } */
+/* { dg-options "-fsanitize" } */
+/* { dg-error "unrecognized command line option .-fsanitize..$" "" { target *-*-* } 0 } */
--
2.11.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do not suggest -fsanitize=all (PR driver/78863).
2016-12-21 9:40 [PATCH] Do not suggest -fsanitize=all (PR driver/78863) Martin Liška
@ 2016-12-21 10:05 ` Jakub Jelinek
2016-12-21 10:22 ` Martin Liška
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2016-12-21 10:05 UTC (permalink / raw)
To: Martin Liška; +Cc: GCC Patches, David Malcolm
On Wed, Dec 21, 2016 at 10:34:13AM +0100, Martin Liška wrote:
> As mentioned in the PR, we should not suggest option that is not allowed.
> Fixed by explicit removal of suggestions that are not acceptable.
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?
Wouldn't it be better not to register those? Like (untested):
--- gcc/gcc.c.jj 2016-11-14 19:57:10.000000000 +0100
+++ gcc/gcc.c 2016-12-21 10:58:29.739873850 +0100
@@ -7733,6 +7733,17 @@ driver::build_option_suggestions (void)
{
for (int j = 0; sanitizer_opts[j].name != NULL; ++j)
{
+ struct cl_option optb;
+ /* -fsanitize=all is not valid, only -fno-sanitize=all.
+ So don't register the positive misspelling candidates
+ for it. */
+ if (sanitizer_opts[j].flag == ~0U && i == OPT_fsanitize_)
+ {
+ optb = *option;
+ optb.opt_text = opt_text = "-fno-sanitize=";
+ optb.cl_reject_negative = true;
+ option = &optb;
+ }
/* Get one arg at a time e.g. "-fsanitize=address". */
char *with_arg = concat (opt_text,
sanitizer_opts[j].name,
Jakub
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do not suggest -fsanitize=all (PR driver/78863).
2016-12-21 10:05 ` Jakub Jelinek
@ 2016-12-21 10:22 ` Martin Liška
2016-12-21 10:33 ` Jakub Jelinek
0 siblings, 1 reply; 7+ messages in thread
From: Martin Liška @ 2016-12-21 10:22 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches, David Malcolm
[-- Attachment #1: Type: text/plain, Size: 1419 bytes --]
On 12/21/2016 11:00 AM, Jakub Jelinek wrote:
> On Wed, Dec 21, 2016 at 10:34:13AM +0100, Martin Liška wrote:
>> As mentioned in the PR, we should not suggest option that is not allowed.
>> Fixed by explicit removal of suggestions that are not acceptable.
>>
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>
>> Ready to be installed?
>
> Wouldn't it be better not to register those? Like (untested):
>
> --- gcc/gcc.c.jj 2016-11-14 19:57:10.000000000 +0100
> +++ gcc/gcc.c 2016-12-21 10:58:29.739873850 +0100
> @@ -7733,6 +7733,17 @@ driver::build_option_suggestions (void)
> {
> for (int j = 0; sanitizer_opts[j].name != NULL; ++j)
> {
> + struct cl_option optb;
> + /* -fsanitize=all is not valid, only -fno-sanitize=all.
> + So don't register the positive misspelling candidates
> + for it. */
> + if (sanitizer_opts[j].flag == ~0U && i == OPT_fsanitize_)
> + {
> + optb = *option;
> + optb.opt_text = opt_text = "-fno-sanitize=";
> + optb.cl_reject_negative = true;
> + option = &optb;
> + }
> /* Get one arg at a time e.g. "-fsanitize=address". */
> char *with_arg = concat (opt_text,
> sanitizer_opts[j].name,
>
>
> Jakub
>
I like your approach!
make check -k -j10 RUNTESTFLAGS="dg.exp=spellcheck-options-*" works fine.
Am I install the patch after it survives proper regression tests?
Thanks,
Martin
[-- Attachment #2: 0001-Do-not-suggest-fsanitize-all-PR-driver-78863-v2.patch --]
[-- Type: text/x-patch, Size: 1954 bytes --]
From 2533c19b4bbd2d9900b043973b504be07343d05c Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 20 Dec 2016 12:16:02 +0100
Subject: [PATCH] Do not suggest -fsanitize=all (PR driver/78863).
gcc/ChangeLog:
2016-12-20 Jakub Jelinek <jakub@redhat.com>
Martin Liska <mliska@suse.cz>
PR driver/78863
* gcc.c (driver::build_option_suggestions): Do not add
-fsanitize=all as a suggestion candidate.
gcc/testsuite/ChangeLog:
2016-12-20 Martin Liska <mliska@suse.cz>
PR driver/78863
* gcc.dg/spellcheck-options-13.c: New test.
---
gcc/gcc.c | 11 +++++++++++
gcc/testsuite/gcc.dg/spellcheck-options-13.c | 5 +++++
2 files changed, 16 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/spellcheck-options-13.c
diff --git a/gcc/gcc.c b/gcc/gcc.c
index f78acd68606..69089484340 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -7733,6 +7733,17 @@ driver::build_option_suggestions (void)
{
for (int j = 0; sanitizer_opts[j].name != NULL; ++j)
{
+ struct cl_option optb;
+ /* -fsanitize=all is not valid, only -fno-sanitize=all.
+ So don't register the positive misspelling candidates
+ for it. */
+ if (sanitizer_opts[j].flag == ~0U && i == OPT_fsanitize_)
+ {
+ optb = *option;
+ optb.opt_text = opt_text = "-fno-sanitize=";
+ optb.cl_reject_negative = true;
+ option = &optb;
+ }
/* Get one arg at a time e.g. "-fsanitize=address". */
char *with_arg = concat (opt_text,
sanitizer_opts[j].name,
diff --git a/gcc/testsuite/gcc.dg/spellcheck-options-13.c b/gcc/testsuite/gcc.dg/spellcheck-options-13.c
new file mode 100644
index 00000000000..19b63af565b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/spellcheck-options-13.c
@@ -0,0 +1,5 @@
+/* PR driver/78863. */
+
+/* { dg-do compile } */
+/* { dg-options "-fsanitize" } */
+/* { dg-error "unrecognized command line option .-fsanitize..$" "" { target *-*-* } 0 } */
--
2.11.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do not suggest -fsanitize=all (PR driver/78863).
2016-12-21 10:22 ` Martin Liška
@ 2016-12-21 10:33 ` Jakub Jelinek
2016-12-21 15:05 ` Martin Liška
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2016-12-21 10:33 UTC (permalink / raw)
To: Martin Liška; +Cc: GCC Patches, David Malcolm
On Wed, Dec 21, 2016 at 11:20:33AM +0100, Martin Liška wrote:
> I like your approach!
> make check -k -j10 RUNTESTFLAGS="dg.exp=spellcheck-options-*" works fine.
>
> Am I install the patch after it survives proper regression tests?
Ok.
Also, only related, seems we have misspelling candidates for cases like
-fsanitiz=ell
but not for -fsanitize=ell
(i.e. when the option is actually correct, just the argument to it (or part
of it) is misspelled). It would need to be done probably in
parse_sanitizer_options when we diagnose it:
if (! found && complain)
error_at (loc, "unrecognized argument to -fsanitize%s= option: %q.*s",
code == OPT_fsanitize_ ? "" : "-recover", (int) len, p);
go through sanitizer_opts again in that case, add candidates (that are
valid for the particular option), and if there is a hint, add the hint to
this message.
Jakub
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do not suggest -fsanitize=all (PR driver/78863).
2016-12-21 10:33 ` Jakub Jelinek
@ 2016-12-21 15:05 ` Martin Liška
2017-01-02 12:52 ` Martin Liška
0 siblings, 1 reply; 7+ messages in thread
From: Martin Liška @ 2016-12-21 15:05 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches, David Malcolm
On 12/21/2016 11:28 AM, Jakub Jelinek wrote:
> On Wed, Dec 21, 2016 at 11:20:33AM +0100, Martin Liška wrote:
>> I like your approach!
>> make check -k -j10 RUNTESTFLAGS="dg.exp=spellcheck-options-*" works fine.
>>
>> Am I install the patch after it survives proper regression tests?
>
> Ok.
>
> Also, only related, seems we have misspelling candidates for cases like
> -fsanitiz=ell
> but not for -fsanitize=ell
> (i.e. when the option is actually correct, just the argument to it (or part
> of it) is misspelled). It would need to be done probably in
> parse_sanitizer_options when we diagnose it:
> if (! found && complain)
> error_at (loc, "unrecognized argument to -fsanitize%s= option: %q.*s",
> code == OPT_fsanitize_ ? "" : "-recover", (int) len, p);
> go through sanitizer_opts again in that case, add candidates (that are
> valid for the particular option), and if there is a hint, add the hint to
> this message.
>
> Jakub
>
These look very similar to what I reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78877.
I've just added your case to the PR.
I'm going to install the patch.
M.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do not suggest -fsanitize=all (PR driver/78863).
2016-12-21 15:05 ` Martin Liška
@ 2017-01-02 12:52 ` Martin Liška
2017-01-02 12:55 ` Jakub Jelinek
0 siblings, 1 reply; 7+ messages in thread
From: Martin Liška @ 2017-01-02 12:52 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches, David Malcolm
On 12/21/2016 04:03 PM, Martin Liška wrote:
> On 12/21/2016 11:28 AM, Jakub Jelinek wrote:
>> On Wed, Dec 21, 2016 at 11:20:33AM +0100, Martin Liška wrote:
>>> I like your approach!
>>> make check -k -j10 RUNTESTFLAGS="dg.exp=spellcheck-options-*" works fine.
>>>
>>> Am I install the patch after it survives proper regression tests?
>>
>> Ok.
>>
>> Also, only related, seems we have misspelling candidates for cases like
>> -fsanitiz=ell
>> but not for -fsanitize=ell
>> (i.e. when the option is actually correct, just the argument to it (or part
>> of it) is misspelled). It would need to be done probably in
>> parse_sanitizer_options when we diagnose it:
>> if (! found && complain)
>> error_at (loc, "unrecognized argument to -fsanitize%s= option: %q.*s",
>> code == OPT_fsanitize_ ? "" : "-recover", (int) len, p);
>> go through sanitizer_opts again in that case, add candidates (that are
>> valid for the particular option), and if there is a hint, add the hint to
>> this message.
>>
>> Jakub
>>
>
> These look very similar to what I reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78877.
> I've just added your case to the PR.
>
> I'm going to install the patch.
>
> M.
>
Is it fine to install the patch to gcc-6 branch?
Thanks,
Martin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Do not suggest -fsanitize=all (PR driver/78863).
2017-01-02 12:52 ` Martin Liška
@ 2017-01-02 12:55 ` Jakub Jelinek
0 siblings, 0 replies; 7+ messages in thread
From: Jakub Jelinek @ 2017-01-02 12:55 UTC (permalink / raw)
To: Martin Liška; +Cc: GCC Patches, David Malcolm
On Mon, Jan 02, 2017 at 01:52:22PM +0100, Martin Liška wrote:
> Is it fine to install the patch to gcc-6 branch?
Ok.
Jakub
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-01-02 12:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-21 9:40 [PATCH] Do not suggest -fsanitize=all (PR driver/78863) Martin Liška
2016-12-21 10:05 ` Jakub Jelinek
2016-12-21 10:22 ` Martin Liška
2016-12-21 10:33 ` Jakub Jelinek
2016-12-21 15:05 ` Martin Liška
2017-01-02 12:52 ` Martin Liška
2017-01-02 12:55 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).