* [PATCH] c++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806]
@ 2022-03-08 7:26 Jakub Jelinek
2022-03-08 9:23 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2022-03-08 7:26 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
Hi!
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.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2022-03-08 Jakub Jelinek <jakub@redhat.com>
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.
--- gcc/cp/search.cc.jj 2022-01-18 11:58:59.407984557 +0100
+++ gcc/cp/search.cc 2022-03-07 10:44:33.455673155 +0100
@@ -1275,6 +1275,13 @@ lookup_field_fuzzy_info::fuzzy_lookup_fi
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));
}
}
--- gcc/testsuite/g++.dg/spellcheck-pr104806.C.jj 2022-03-07 10:34:07.224499657 +0100
+++ gcc/testsuite/g++.dg/spellcheck-pr104806.C 2022-03-07 10:43:41.900399808 +0100
@@ -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 }
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] c++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806]
2022-03-08 7:26 [PATCH] c++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806] Jakub Jelinek
@ 2022-03-08 9:23 ` Richard Biener
2022-03-08 9:32 ` Jakub Jelinek
0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2022-03-08 9:23 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Jason Merrill, GCC Patches
On Tue, Mar 8, 2022 at 8:27 AM Jakub Jelinek via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi!
>
> 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.
Are those maybe also DECL_ARTIFICIAL?
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2022-03-08 Jakub Jelinek <jakub@redhat.com>
>
> 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.
>
> --- gcc/cp/search.cc.jj 2022-01-18 11:58:59.407984557 +0100
> +++ gcc/cp/search.cc 2022-03-07 10:44:33.455673155 +0100
> @@ -1275,6 +1275,13 @@ lookup_field_fuzzy_info::fuzzy_lookup_fi
> 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));
> }
> }
> --- gcc/testsuite/g++.dg/spellcheck-pr104806.C.jj 2022-03-07 10:34:07.224499657 +0100
> +++ gcc/testsuite/g++.dg/spellcheck-pr104806.C 2022-03-07 10:43:41.900399808 +0100
> @@ -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 }
>
> Jakub
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] c++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806]
2022-03-08 9:23 ` Richard Biener
@ 2022-03-08 9:32 ` Jakub Jelinek
2022-03-08 18:22 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2022-03-08 9:32 UTC (permalink / raw)
To: Richard Biener; +Cc: Jason Merrill, GCC Patches
On Tue, Mar 08, 2022 at 10:23:28AM +0100, Richard Biener wrote:
> On Tue, Mar 8, 2022 at 8:27 AM Jakub Jelinek via Gcc-patches
> > 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.
>
> Are those maybe also DECL_ARTIFICIAL?
You mean the FUNCTION_DECLs in the TYPE_FIELDS chain? No, they aren't.
> > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> >
> > 2022-03-08 Jakub Jelinek <jakub@redhat.com>
> >
> > 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.
> >
> > --- gcc/cp/search.cc.jj 2022-01-18 11:58:59.407984557 +0100
> > +++ gcc/cp/search.cc 2022-03-07 10:44:33.455673155 +0100
> > @@ -1275,6 +1275,13 @@ lookup_field_fuzzy_info::fuzzy_lookup_fi
> > 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));
> > }
> > }
> > --- gcc/testsuite/g++.dg/spellcheck-pr104806.C.jj 2022-03-07 10:34:07.224499657 +0100
> > +++ gcc/testsuite/g++.dg/spellcheck-pr104806.C 2022-03-07 10:43:41.900399808 +0100
> > @@ -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 }
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] c++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806]
2022-03-08 9:32 ` Jakub Jelinek
@ 2022-03-08 18:22 ` Jason Merrill
0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2022-03-08 18:22 UTC (permalink / raw)
To: Jakub Jelinek, Richard Biener; +Cc: GCC Patches
On 3/8/22 05:32, Jakub Jelinek wrote:
> On Tue, Mar 08, 2022 at 10:23:28AM +0100, Richard Biener wrote:
>> On Tue, Mar 8, 2022 at 8:27 AM Jakub Jelinek via Gcc-patches
>>> 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.
>>
>> Are those maybe also DECL_ARTIFICIAL?
>
> You mean the FUNCTION_DECLs in the TYPE_FIELDS chain? No, they aren't.
These identifiers should have various IDENTIFIER_KIND_BIT_? set, but it
certainly makes sense to ignore all identifiers with spaces in them.
The patch is OK.
>>> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>>>
>>> 2022-03-08 Jakub Jelinek <jakub@redhat.com>
>>>
>>> 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.
>>>
>>> --- gcc/cp/search.cc.jj 2022-01-18 11:58:59.407984557 +0100
>>> +++ gcc/cp/search.cc 2022-03-07 10:44:33.455673155 +0100
>>> @@ -1275,6 +1275,13 @@ lookup_field_fuzzy_info::fuzzy_lookup_fi
>>> 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));
>>> }
>>> }
>>> --- gcc/testsuite/g++.dg/spellcheck-pr104806.C.jj 2022-03-07 10:34:07.224499657 +0100
>>> +++ gcc/testsuite/g++.dg/spellcheck-pr104806.C 2022-03-07 10:43:41.900399808 +0100
>>> @@ -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 }
>
> Jakub
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-08 18:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 7:26 [PATCH] c++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806] Jakub Jelinek
2022-03-08 9:23 ` Richard Biener
2022-03-08 9:32 ` Jakub Jelinek
2022-03-08 18:22 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).