From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id C7C7B3858C74; Tue, 8 Mar 2022 20:43:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7C7B3858C74 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7544] c++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 768956c0d115766fe7e1168d420310182ae48d9f X-Git-Newrev: e480c3c06d20874fd7504bfdcca0b829f8000389 Message-Id: <20220308204303.C7C7B3858C74@sourceware.org> Date: Tue, 8 Mar 2022 20:43:03 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Mar 2022 20:43:03 -0000 https://gcc.gnu.org/g:e480c3c06d20874fd7504bfdcca0b829f8000389 commit r12-7544-ge480c3c06d20874fd7504bfdcca0b829f8000389 Author: Jakub Jelinek Date: Tue Mar 8 21:41:21 2022 +0100 c++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806] On the following testcase, we emit "did you mean '__dt '?" in the error message. "__dt " shows there because it is dtor_identifier, but we shouldn't suggest those to the user, they are purely internal and can't be really typed by the user because of the final space in it. 2022-03-08 Jakub Jelinek PR c++/104806 * search.cc (lookup_field_fuzzy_info::fuzzy_lookup_field): Ignore identifiers with space at the end. * g++.dg/spellcheck-pr104806.C: New test. Diff: --- gcc/cp/search.cc | 7 +++++++ gcc/testsuite/g++.dg/spellcheck-pr104806.C | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc index 00c669effad..2b8210408fb 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 00000000000..559e6019163 --- /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 }