From patchwork Thu Jul 14 14:50:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 648421 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rqzCH0zRSz9sDG for ; Fri, 15 Jul 2016 00:50:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=O0z7ziHu; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=fr4icVuEALyvgBvYmtZnInGj6lUTG quM7x1ybG5t5R73FmFGR/MZdQyI82dpQIY45LTpCh44vgmin8hh9DwDyqoyMh1HV eo9/fcEbqxD0XeotqesylPx7WHFtYfKudZeV/8yqdeqaSSMnbH0F5GHBhvzi1MIK tF2qK95PsrKQJ0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=9Sf+R21/BLr5lJgbQ4Qkg8X9pjI=; b=O0z 7ziHuoGrP1HYBpJWuVAGZTHnG5HeIqD/Nebqp2rEQimxJK7PY84foYK081ErjZxZ 77nVpiOLdnVz6KIRhRrT89OFxq8yEsBhhlCH05SjUzt8PPBlLRclURVvkhTjWblu SJgft9eDW9tSTtkyloI+PnTNSA594i8Aa6i3oMTg= Received: (qmail 65401 invoked by alias); 14 Jul 2016 14:50:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 65386 invoked by uid 89); 14 Jul 2016 14:50:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=anticipated, carg, dg-warning, dgwarning 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 14 Jul 2016 14:50:23 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 33BC6D6843; Thu, 14 Jul 2016 14:50:21 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-98.brq.redhat.com [10.40.204.98]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6EEoJGa012012 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 14 Jul 2016 10:50:20 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u6EEoHxm027966; Thu, 14 Jul 2016 16:50:18 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u6EEoG0J027965; Thu, 14 Jul 2016 16:50:16 +0200 Date: Thu, 14 Jul 2016 16:50:16 +0200 From: Jakub Jelinek To: "Joseph S. Myers" , Marek Polacek , David Malcolm Cc: gcc-patches@gcc.gnu.org Subject: [C PATCH] Ignore invisible bindings for misspelling hints (PR c/71858) Message-ID: <20160714145016.GE7387@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi! As mentioned in the PR, anticipated decls should be ignored from fuzzy lookups, unless the corresponding decl is declared first. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-07-13 Jakub Jelinek PR c/71858 * c-decl.c (lookup_name_fuzzy): Ignore binding->invisible. * gcc.dg/spellcheck-identifiers.c (snprintf): Declare. * gcc.dg/spellcheck-identifiers-2.c: New test. * gcc.dg/diagnostic-token-ranges.c (nanl): Declare. * c-c++-common/attributes-1.c: Adjust dg-prune-output. Jakub --- gcc/c/c-decl.c.jj 2016-06-24 12:59:22.000000000 +0200 +++ gcc/c/c-decl.c 2016-07-13 22:40:23.410658411 +0200 @@ -4021,7 +4021,7 @@ lookup_name_fuzzy (tree name, enum looku for (c_scope *scope = current_scope; scope; scope = scope->outer) for (c_binding *binding = scope->bindings; binding; binding = binding->prev) { - if (!binding->id) + if (!binding->id || binding->invisible) continue; /* Don't use bindings from implicitly declared functions, as they were likely misspellings themselves. */ --- gcc/testsuite/gcc.dg/spellcheck-identifiers.c.jj 2016-06-24 12:59:12.000000000 +0200 +++ gcc/testsuite/gcc.dg/spellcheck-identifiers.c 2016-07-14 10:03:36.147466813 +0200 @@ -121,7 +121,7 @@ test_6 (enum foo f) } } -/* Verify that we offer names of builtins as suggestions. */ +int snprintf (char *, __SIZE_TYPE__, const char *, ...); void test_7 (int i, int j) --- gcc/testsuite/gcc.dg/spellcheck-identifiers-2.c.jj 2016-07-14 09:44:16.351537449 +0200 +++ gcc/testsuite/gcc.dg/spellcheck-identifiers-2.c 2016-07-14 10:02:21.965426567 +0200 @@ -0,0 +1,33 @@ +/* PR c/71858 */ +/* Make sure anticipated builtins are not considered before they are declared. */ +/* { dg-do compile } */ +/* { dg-options "-Wimplicit-function-declaration -fdiagnostics-show-caret" } */ + +int sscafn (const char *, const char *, ...); + +int +test_1 (const char *p) +{ + int i; + return ssacnf (p, "%d", &i); /* { dg-warning "10: implicit declaration of function .ssacnf.; did you mean .sscafn.?" } */ + /* { dg-begin-multiline-output "" } + return ssacnf (p, "%d", &i); + ^~~~~~ + sscafn + { dg-end-multiline-output "" } */ +} + +int scafn (const char *, ...); +int scanf (const char *, ...); + +int +test_2 (void) +{ + int i; + return sacnf ("%d", &i); /* { dg-warning "10: implicit declaration of function .sacnf.; did you mean .scanf.?" } */ + /* { dg-begin-multiline-output "" } + return sacnf ("%d", &i); + ^~~~~ + scanf + { dg-end-multiline-output "" } */ +} --- gcc/testsuite/gcc.dg/diagnostic-token-ranges.c.jj 2016-06-24 12:59:12.000000000 +0200 +++ gcc/testsuite/gcc.dg/diagnostic-token-ranges.c 2016-07-14 11:06:23.013803011 +0200 @@ -2,6 +2,8 @@ /* Verify that various diagnostics show source code ranges. */ +long double nanl (const char *); + /* These ones merely use token ranges; they don't use tree ranges. */ void undeclared_identifier (void) --- gcc/testsuite/c-c++-common/attributes-1.c.jj 2016-06-23 14:31:57.000000000 +0200 +++ gcc/testsuite/c-c++-common/attributes-1.c 2016-07-14 14:51:34.871006659 +0200 @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-prune-output "undeclared here \\(not in a function\\); did you mean .carg..|\[^\n\r\]* was not declared in this scope" } */ +/* { dg-prune-output "undeclared here \\(not in a function\\); did you mean .char..|\[^\n\r\]* was not declared in this scope" } */ void* my_calloc(unsigned, unsigned) __attribute__((alloc_size(1,bar))); /* { dg-warning "outside range" } */ void* my_realloc(void*, unsigned) __attribute__((alloc_size(bar))); /* { dg-warning "outside range" } */