From patchwork Wed Nov 6 04:51:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 288718 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1DA6C2C00A3 for ; Wed, 6 Nov 2013 15:51:38 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject; q=dns; s=default; b=AZofiXvsf3ngW0G ruZkRKhQOTGiD6VOzdYB+vHFtRn0CqyWoNYCagvTsyiSgbYh43vGeN25sxuLEFbi tDisfkwZ9uMJ7S0w5nawjgNfcG858CqDb57+h8LidSf/bNDPqG253HNeQZE0F/Kx MVufBGkeK/P3SFH5P2us78JlkZQI= 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 :message-id:from:to:subject; s=default; bh=Gb+6Hi1Yt67uFj5Y0UN4R pWtLOE=; b=E7PoMtgTWwhBk3ZP6p8kRXoa2/vgw8hIBNncVPm90PLSwl+OVMVvN nBGKVjX2kZLWSg1Z5BAAeh7F2Mh80llMdlwz0fxTwSY0tqT0RuR5PymvJS+L5USo pqcMv6OmKFy1/xRs0uew1B89jJ4B0Q7vQLZtDEdVmI678mNrKHUxII= Received: (qmail 7874 invoked by alias); 6 Nov 2013 04:51:26 -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 7861 invoked by uid 89); 6 Nov 2013 04:51:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Nov 2013 04:51:24 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA64pGpg007653 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 5 Nov 2013 23:51:16 -0500 Received: from greed.delorie.com (ovpn-113-31.phx2.redhat.com [10.3.113.31]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rA64pF9u015400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 5 Nov 2013 23:51:16 -0500 Received: from greed.delorie.com (greed.delorie.com [127.0.0.1]) by greed.delorie.com (8.14.4/8.14.4) with ESMTP id rA64pCQj031841 for ; Tue, 5 Nov 2013 23:51:12 -0500 Received: (from dj@localhost) by greed.delorie.com (8.14.4/8.14.4/Submit) id rA64pCPq031840; Tue, 5 Nov 2013 23:51:12 -0500 Date: Tue, 5 Nov 2013 23:51:12 -0500 Message-Id: <201311060451.rA64pCPq031840@greed.delorie.com> From: DJ Delorie To: gcc-patches@gcc.gnu.org Subject: mismatched decls w/ both builtin and explicit decl X-IsSubscribed: yes Consider this source: extern char *index(const char *,int); static int index; "index" is a builtin as well, but because it's a builtin gcc skips the "previous declaration was here..." despite having *a* previous decl it could complain about. Note that newlib provides decls for many builtins (the decl above is from newlib), so this could be a common case. So I added a check for !C_DECL_DECLARED_BUILTIN (decl) which seems to specifically cover this case. Ok to apply? * c-decl.c (locate_old_decl): If a previous conflicting decl is both explicit and builtin, print the location of the explicit one. Index: c-decl.c =================================================================== --- c-decl.c (revision 204300) +++ c-decl.c (working copy) @@ -1630,13 +1630,14 @@ validate_proto_after_old_defn (tree newd /* Subroutine of diagnose_mismatched_decls. Report the location of DECL, first in a pair of mismatched declarations, using the diagnostic function DIAG. */ static void locate_old_decl (tree decl) { - if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl)) + if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl) + && !C_DECL_DECLARED_BUILTIN (decl)) ; else if (DECL_INITIAL (decl)) inform (input_location, "previous definition of %q+D was here", decl); else if (C_DECL_IMPLICIT (decl)) inform (input_location, "previous implicit declaration of %q+D was here", decl); else