From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10152 invoked by alias); 21 Nov 2017 15:43:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 9737 invoked by uid 89); 21 Nov 2017 15:43:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Nov 2017 15:43:43 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 12D6380C15 for ; Tue, 21 Nov 2017 15:43:42 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-13.phx2.redhat.com [10.3.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11C2A60BE5; Tue, 21 Nov 2017 15:43:40 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH] C: don't suggest names that came from earlier failures (PR c/83056) Date: Tue, 21 Nov 2017 15:51:00 -0000 Message-Id: <1511279156-23452-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg01909.txt.bz2 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