Message ID | 1511279156-23452-1-git-send-email-dmalcolm@redhat.com |
---|---|
State | New |
Headers | show |
Series | C: don't suggest names that came from earlier failures (PR c/83056) | expand |
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
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'" } */ +}