aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts-common.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-06-30 14:28:50 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-06-30 14:28:50 +0000
commit603107fbb0da3acb1ce296dfef1a592a6451c0b4 (patch)
tree40d1bc99d4ff173785ae8b7f061698acb8a05f26 /gcc/opts-common.c
parent72fb6bae83446096e467e3713e8e40b2433f8220 (diff)
downloadgcc-603107fbb0da3acb1ce296dfef1a592a6451c0b4.zip
gcc-603107fbb0da3acb1ce296dfef1a592a6451c0b4.tar.gz
gcc-603107fbb0da3acb1ce296dfef1a592a6451c0b4.tar.bz2
Fix bogus option suggestions for RejectNegative options (PR driver/71651)
gcc/ChangeLog: PR driver/71651 * gcc.c (driver::build_option_suggestions): Pass "option" to add_misspelling_candidates. * opts-common.c (add_misspelling_candidates): Add "option" param; use it to avoid adding negated forms for options marked with RejectNegative. * opts.h (add_misspelling_candidates): Add "option" param. gcc/testsuite/ChangeLog: PR driver/71651 * gcc.dg/spellcheck-options-12.c: New test case. From-SVN: r237880
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r--gcc/opts-common.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 4e1ef49..8634b52 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -374,8 +374,9 @@ static const struct option_map option_map[] =
to specific options. We want to do the reverse: to find all the ways
that a user could validly spell an option.
- Given valid OPT_TEXT (with a leading dash), add it and all of its valid
- variant spellings to CANDIDATES, each without a leading dash.
+ Given valid OPT_TEXT (with a leading dash) for OPTION, add it and all
+ of its valid variant spellings to CANDIDATES, each without a leading
+ dash.
For example, given "-Wabi-tag", the following are added to CANDIDATES:
"Wabi-tag"
@@ -387,9 +388,11 @@ static const struct option_map option_map[] =
void
add_misspelling_candidates (auto_vec<char *> *candidates,
+ const struct cl_option *option,
const char *opt_text)
{
gcc_assert (candidates);
+ gcc_assert (option);
gcc_assert (opt_text);
candidates->safe_push (xstrdup (opt_text + 1));
for (unsigned i = 0; i < ARRAY_SIZE (option_map); i++)
@@ -398,6 +401,9 @@ add_misspelling_candidates (auto_vec<char *> *candidates,
const char *new_prefix = option_map[i].new_prefix;
size_t new_prefix_len = strlen (new_prefix);
+ if (option->cl_reject_negative && option_map[i].negated)
+ continue;
+
if (strncmp (opt_text, new_prefix, new_prefix_len) == 0)
{
char *alternative = concat (opt0 + 1, opt_text + new_prefix_len,