From patchwork Sun Jul 20 10:38:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 371883 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 F100314008C for ; Sun, 20 Jul 2014 20:39:14 +1000 (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 :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=IyFpp891//LE84ql8yTtN3a2mGn391GBRgsioaLjNVyO4VqhfK +8os/w0ARXI2YOMzDgasU11S59+ayLSzhqMefpo0U2QeZliz35STczM4KysO9hnt +94zdZgz/1bgOHvEYgLLJGgOLDrrqT0+osE8rCXLlU84FRON/n4xX+6MY= 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:mime-version:content-type; s= default; bh=nPCRzfORBgGpoN0SjFXa0ajSWn8=; b=UtkLwLHdBjuDU/x5C6ET 8ZY49wbkSlgb2NaqHnImgqtuhjNKMQOl9ESZK5AL/46Efo8u/8r2B7QOSBcuCbmQ FzHNlxPMotjk2PxVNQEm5LoO/uK85DG7847tF9638DpTp/ywx/DScqBAbmTP8enu cSmFjyhKbZ+qjk2ewly8ZW0= Received: (qmail 26579 invoked by alias); 20 Jul 2014 10:39:07 -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 26087 invoked by uid 89); 20 Jul 2014 10:39:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 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; Sun, 20 Jul 2014 10:39:01 +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 s6KAcwJI028716 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 20 Jul 2014 06:38:58 -0400 Received: from redhat.com (ovpn-116-38.ams2.redhat.com [10.36.116.38]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6KActdp006322 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Sun, 20 Jul 2014 06:38:57 -0400 Date: Sun, 20 Jul 2014 12:38:54 +0200 From: Marek Polacek To: GCC Patches Cc: "Joseph S. Myers" Subject: [C PATCH] Better location for implicit_decl_warning (PR c/61852) Message-ID: <20140720103854.GB2287@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) implicit_decl_warning wasn't getting a location, so the column info was poor. It's easy to fix this up. Bootstrapped/regtested on x86_64-linux, applying to trunk. 2014-07-20 Marek Polacek PR c/61852 * c-decl.c (implicit_decl_warning): Add location_t parameter. Use it. (implicitly_declare): Pass location to implicit_decl_warning. * gcc.dg/pr61852.c: New test. Marek diff --git gcc/c/c-decl.c gcc/c/c-decl.c index 0ca2e0d..425fc58 100644 --- gcc/c/c-decl.c +++ gcc/c/c-decl.c @@ -2951,18 +2951,18 @@ pushdecl_top_level (tree x) } static void -implicit_decl_warning (tree id, tree olddecl) +implicit_decl_warning (location_t loc, tree id, tree olddecl) { if (warn_implicit_function_declaration) { bool warned; if (flag_isoc99) - warned = pedwarn (input_location, OPT_Wimplicit_function_declaration, + warned = pedwarn (loc, OPT_Wimplicit_function_declaration, "implicit declaration of function %qE", id); else - warned = warning (OPT_Wimplicit_function_declaration, - G_("implicit declaration of function %qE"), id); + warned = warning_at (loc, OPT_Wimplicit_function_declaration, + G_("implicit declaration of function %qE"), id); if (olddecl && warned) locate_old_decl (olddecl); } @@ -3015,7 +3015,7 @@ implicitly_declare (location_t loc, tree functionid) then recycle the old declaration but with the new type. */ if (!C_DECL_IMPLICIT (decl)) { - implicit_decl_warning (functionid, decl); + implicit_decl_warning (loc, functionid, decl); C_DECL_IMPLICIT (decl) = 1; } if (DECL_BUILT_IN (decl)) @@ -3052,7 +3052,7 @@ implicitly_declare (location_t loc, tree functionid) DECL_EXTERNAL (decl) = 1; TREE_PUBLIC (decl) = 1; C_DECL_IMPLICIT (decl) = 1; - implicit_decl_warning (functionid, 0); + implicit_decl_warning (loc, functionid, 0); asmspec_tree = maybe_apply_renaming_pragma (decl, /*asmname=*/NULL); if (asmspec_tree) set_user_assembler_name (decl, TREE_STRING_POINTER (asmspec_tree)); diff --git gcc/testsuite/gcc.dg/pr61852.c gcc/testsuite/gcc.dg/pr61852.c index e69de29..f488aca 100644 --- gcc/testsuite/gcc.dg/pr61852.c +++ gcc/testsuite/gcc.dg/pr61852.c @@ -0,0 +1,10 @@ +/* PR c/61852 */ +/* { dg-do compile } */ +/* { dg-options "-Wimplicit-function-declaration" } */ + +int +f (int a) +{ + int b = a + a + a + ff (a); /* { dg-warning "23:implicit declaration of function" } */ + return b; +}