aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2017-11-21 21:59:53 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2017-11-21 21:59:53 +0000
commitd4300cc6eae1503d95eb70865f8a82adab7e552d (patch)
tree376083f6cff4bc91793837fc6b29d03e9e4916c5
parent6f9b7472a38a355e1e37d0fa35d399e693726559 (diff)
downloadgcc-d4300cc6eae1503d95eb70865f8a82adab7e552d.zip
gcc-d4300cc6eae1503d95eb70865f8a82adab7e552d.tar.gz
gcc-d4300cc6eae1503d95eb70865f8a82adab7e552d.tar.bz2
C: don't suggest names that came from earlier failures (PR c/83056)
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. 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. From-SVN: r255038
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-decl.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/spellcheck-pr83056.c11
4 files changed, 24 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index a2773b0..a4dc563 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-21 David Malcolm <dmalcolm@redhat.com>
+
+ PR c/83056
+ * c-decl.c (lookup_name_fuzzy): Don't suggest names that came from
+ earlier failed lookups.
+
2017-11-21 Marc Glisse <marc.glisse@inria.fr>
* c-fold.c (c_fully_fold_internal): Handle POINTER_DIFF_EXPR.
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/ChangeLog b/gcc/testsuite/ChangeLog
index 0d86a86..b3e371e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-11-21 David Malcolm <dmalcolm@redhat.com>
+
+ PR c/83056
+ * gcc.dg/spellcheck-pr83056.c: New test case.
+
2017-11-21 Martin Sebor <msebor@redhat.com>
PR tree-optimization/82945
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'" } */
+}