Hi.
The patch enhances option suggestion for options that expect
an argument.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
gcc/ChangeLog:
2019-03-29 Martin Liska <[email protected]>
PR driver/89861
* opt-suggestions.c (option_proposer::build_option_suggestions):
Add variant without any argument in order to provide better
hints.
gcc/testsuite/ChangeLog:
2019-03-29 Martin Liska <[email protected]>
PR driver/89861
* gcc.dg/spellcheck-options-18.c: New test.
* gcc.dg/spellcheck-options-19.c: New test.
* gcc.dg/spellcheck-options-20.c: New test.
* gcc.dg/spellcheck-options-13.c: Adjust expected output.
* gcc.dg/completion-2.c: Add one variant with no argument.
---
gcc/opt-suggestions.c | 8 ++++++++
gcc/testsuite/gcc.dg/completion-2.c | 1 +
gcc/testsuite/gcc.dg/spellcheck-options-13.c | 2 +-
gcc/testsuite/gcc.dg/spellcheck-options-18.c | 3 +++
gcc/testsuite/gcc.dg/spellcheck-options-19.c | 3 +++
gcc/testsuite/gcc.dg/spellcheck-options-20.c | 3 +++
6 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/spellcheck-options-18.c
create mode 100644 gcc/testsuite/gcc.dg/spellcheck-options-19.c
create mode 100644 gcc/testsuite/gcc.dg/spellcheck-options-20.c
diff --git a/gcc/opt-suggestions.c b/gcc/opt-suggestions.c
index c14c29d3083..415dcc9fc45 100644
--- a/gcc/opt-suggestions.c
+++ b/gcc/opt-suggestions.c
@@ -134,6 +134,10 @@ option_proposer::build_option_suggestions (const char *prefix)
with_arg);
free (with_arg);
}
+
+ /* Add also variant without an option argument. */
+ add_misspelling_candidates (m_option_suggestions, option,
+ opt_text);
}
else
{
@@ -172,6 +176,10 @@ option_proposer::build_option_suggestions (const char *prefix)
"-fsanitize=address"
rather than to "-Wframe-address" (PR driver/69265). */
{
+ /* Add also variant without an option argument. */
+ add_misspelling_candidates (m_option_suggestions, option,
+ opt_text);
+
for (int j = 0; sanitizer_opts[j].name != NULL; ++j)
{
struct cl_option optb;
diff --git a/gcc/testsuite/gcc.dg/completion-2.c b/gcc/testsuite/gcc.dg/completion-2.c
index ac7508591de..166bfdc1424 100644
--- a/gcc/testsuite/gcc.dg/completion-2.c
+++ b/gcc/testsuite/gcc.dg/completion-2.c
@@ -7,4 +7,5 @@
-flto-partition=max
-flto-partition=none
-flto-partition=one
+-flto-partition=
{ dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/spellcheck-options-13.c b/gcc/testsuite/gcc.dg/spellcheck-options-13.c
index 19b63af565b..0d00642d87e 100644
--- a/gcc/testsuite/gcc.dg/spellcheck-options-13.c
+++ b/gcc/testsuite/gcc.dg/spellcheck-options-13.c
@@ -2,4 +2,4 @@
/* { dg-do compile } */
/* { dg-options "-fsanitize" } */
-/* { dg-error "unrecognized command line option .-fsanitize..$" "" { target *-*-* } 0 } */
+/* { dg-error "unrecognized command line option '-fsanitize'; did you mean '-fsanitize='?" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gcc.dg/spellcheck-options-18.c b/gcc/testsuite/gcc.dg/spellcheck-options-18.c
new file mode 100644
index 00000000000..387d04e3743
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/spellcheck-options-18.c
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "-fprofile-update" } */
+/* { dg-error "unrecognized command line option '-fprofile-update'; did you mean '-fprofile-update='?" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gcc.dg/spellcheck-options-19.c b/gcc/testsuite/gcc.dg/spellcheck-options-19.c
new file mode 100644
index 00000000000..5a104763993
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/spellcheck-options-19.c
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-sanitize" } */
+/* { dg-error "unrecognized command line option '-fno-sanitize'; did you mean '-fno-sanitize='?" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gcc.dg/spellcheck-options-20.c b/gcc/testsuite/gcc.dg/spellcheck-options-20.c
new file mode 100644
index 00000000000..dfc6149e023
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/spellcheck-options-20.c
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "-Walloc-size-larger-than" } */
+/* { dg-error "unrecognized command line option '-Walloc-size-larger-than'; did you mean '-Walloc-size-larger-than='?" "" { target *-*-* } 0 } */