+2018-02-07 David Malcolm <dmalcolm@redhat.com>
+
+ PR c++/81610
+ PR c++/80567
+ * name-lookup.c (suggest_rid_p): New function.
+ (lookup_name_fuzzy): Replace enum-rid-filtering logic with call to
+ suggest_rid_p.
+
2018-02-07 Jason Merrill <jason@redhat.com>
PR c++/84182 - ICE with captured lambda
cpp_hashnode *m_macro;
};
+/* Determine if it can ever make sense to offer RID as a suggestion for
+ a misspelling.
+
+ Subroutine of lookup_name_fuzzy. */
+
+static bool
+suggest_rid_p (enum rid rid)
+{
+ switch (rid)
+ {
+ /* Support suggesting function-like keywords. */
+ case RID_STATIC_ASSERT:
+ return true;
+
+ default:
+ /* Support suggesting the various decl-specifier words, to handle
+ e.g. "singed" vs "signed" typos. */
+ if (cp_keyword_starts_decl_specifier_p (rid))
+ return true;
+
+ /* Otherwise, don't offer it. This avoids suggesting e.g. "if"
+ and "do" for short misspellings, which are likely to lead to
+ nonsensical results. */
+ return false;
+ }
+}
/* Search for near-matches for NAME within the current bindings, and within
macro names, returning the best match as a const char *, or NULL if
{
const c_common_resword *resword = &c_common_reswords[i];
- if (kind == FUZZY_LOOKUP_TYPENAME)
- if (!cp_keyword_starts_decl_specifier_p (resword->rid))
- continue;
+ if (!suggest_rid_p (resword->rid))
+ continue;
tree resword_identifier = ridpointers [resword->rid];
if (!resword_identifier)
+2018-02-07 David Malcolm <dmalcolm@redhat.com>
+
+ PR c++/81610
+ PR c++/80567
+ * g++.dg/spellcheck-reswords.C: New test case.
+ * g++.dg/spellcheck-stdlib.C: Remove xfail from dg-bogus
+ suggestion of "if".
+
2018-02-07 Martin Liska <mliska@suse.cz>
PR c++/84059.
--- /dev/null
+void pr81610 (void *p)
+{
+ forget (p); // { dg-error "not declared" }
+ // { dg-bogus "'for'" "" { target *-*-*} .-1 }
+}
+
+void pr80567 (void *p)
+{
+ memset (p, 0, 4); // { dg-error "not declared" }
+ // { dg-bogus "'else'" "" { target *-*-*} .-1 }
+}
FILE *f; // { dg-error "'FILE' was not declared in this scope" }
// { dg-message "'FILE' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?" "" { target *-*-* } .-1 }
// { dg-error "'f' was not declared in this scope" "" { target *-*-* } .-2 }
- // { dg-bogus "suggested alternative: 'if'" "PR c++/80567" { xfail *-*-* } .-3 }
+ // { dg-bogus "suggested alternative: 'if'" "PR c++/80567" { target *-*-* } .-3 }
char buf[BUFSIZ]; // { dg-error "'BUFSIZ' was not declared" }
// { dg-message "'BUFSIZ' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?" "" { target *-*-* } .-1 }