* [PATCH] C: don't suggest names that came from earlier failures (PR c/83056)
@ 2017-11-21 15:51 David Malcolm
2017-11-21 15:56 ` Marek Polacek
0 siblings, 1 reply; 2+ messages in thread
From: David Malcolm @ 2017-11-21 15:51 UTC (permalink / raw)
To: gcc-patches; +Cc: David Malcolm
PR c/83056 reports an issue affecting trunk and gcc-7 in which
the C frontend's implementation of lookup_name_fuzzy uses undeclared
identifiers as suggestions when encountering subsequent undeclared
identifiers.
The fix is to filter out the names bound to error_mark_node
in lookup_name_fuzzy.
The C++ frontend is unaffected, as it already does this.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
OK for trunk and for gcc-7-branch?
gcc/c/ChangeLog:
PR c/83056
* c-decl.c (lookup_name_fuzzy): Don't suggest names that came from
earlier failed lookups.
gcc/testsuite/ChangeLog:
PR c/83056
* gcc.dg/spellcheck-pr83056.c: New test case.
---
gcc/c/c-decl.c | 2 ++
gcc/testsuite/gcc.dg/spellcheck-pr83056.c | 11 +++++++++++
2 files changed, 13 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/spellcheck-pr83056.c
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index e0a4dd1..9c3beab 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -4035,6 +4035,8 @@ lookup_name_fuzzy (tree name, enum lookup_name_fuzzy_kind kind, location_t loc)
{
if (!binding->id || binding->invisible)
continue;
+ if (binding->decl == error_mark_node)
+ continue;
/* Don't use bindings from implicitly declared functions,
as they were likely misspellings themselves. */
if (TREE_CODE (binding->decl) == FUNCTION_DECL)
diff --git a/gcc/testsuite/gcc.dg/spellcheck-pr83056.c b/gcc/testsuite/gcc.dg/spellcheck-pr83056.c
new file mode 100644
index 0000000..8b90887
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/spellcheck-pr83056.c
@@ -0,0 +1,11 @@
+enum { TYPE_A };
+
+/* Verify that the incorrect "TYPE_B" etc don't get re-used for
+ suggestions for the later incorrect values. */
+
+void pr83056(void)
+{
+ int b = TYPE_B; /* { dg-error "did you mean 'TYPE_A'" } */
+ int c = TYPE_C; /* { dg-error "did you mean 'TYPE_A'" } */
+ int d = TYPE_D; /* { dg-error "did you mean 'TYPE_A'" } */
+}
--
1.8.5.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] C: don't suggest names that came from earlier failures (PR c/83056)
2017-11-21 15:51 [PATCH] C: don't suggest names that came from earlier failures (PR c/83056) David Malcolm
@ 2017-11-21 15:56 ` Marek Polacek
0 siblings, 0 replies; 2+ messages in thread
From: Marek Polacek @ 2017-11-21 15:56 UTC (permalink / raw)
To: David Malcolm; +Cc: gcc-patches
On Tue, Nov 21, 2017 at 10:45:56AM -0500, David Malcolm wrote:
> PR c/83056 reports an issue affecting trunk and gcc-7 in which
> the C frontend's implementation of lookup_name_fuzzy uses undeclared
> identifiers as suggestions when encountering subsequent undeclared
> identifiers.
>
> The fix is to filter out the names bound to error_mark_node
> in lookup_name_fuzzy.
>
> The C++ frontend is unaffected, as it already does this.
>
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
>
> OK for trunk and for gcc-7-branch?
Ok, thanks.
Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-21 15:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-21 15:51 [PATCH] C: don't suggest names that came from earlier failures (PR c/83056) David Malcolm
2017-11-21 15:56 ` Marek Polacek
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).