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
@@ -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.
@@ -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
@@ -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);
new file mode 100644
@@ -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