diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc index 00c669effad44fda4a7283dab56101ef24aceeee..2b8210408fbb26b59aec346e351fe77176930fd0 100644 --- a/gcc/cp/search.cc +++ b/gcc/cp/search.cc @@ -1275,6 +1275,13 @@ lookup_field_fuzzy_info::fuzzy_lookup_field (tree type) if (is_lambda_ignored_entity (field)) continue; + /* Ignore special identifiers with space at the end like cdtor or + conversion op identifiers. */ + if (TREE_CODE (DECL_NAME (field)) == IDENTIFIER_NODE) + if (unsigned int len = IDENTIFIER_LENGTH (DECL_NAME (field))) + if (IDENTIFIER_POINTER (DECL_NAME (field))[len - 1] == ' ') + continue; + m_candidates.safe_push (DECL_NAME (field)); } } diff --git a/gcc/testsuite/g++.dg/spellcheck-pr104806.C b/gcc/testsuite/g++.dg/spellcheck-pr104806.C new file mode 100644 index 0000000000000000000000000000000000000000..559e60191633c04f029c660e4d0883d5e9762770 --- /dev/null +++ b/gcc/testsuite/g++.dg/spellcheck-pr104806.C @@ -0,0 +1,5 @@ +// PR c++/104806 + +struct S {}; +int main() { S s; s.__d; } // { dg-bogus "'struct S' has no member named '__d'; did you mean '__\[a-z]* '" } + // { dg-error "'struct S' has no member named '__d'" "" { target *-*-* } .-1 }