From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26537 invoked by alias); 27 Jan 2016 18:52:10 -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 26441 invoked by uid 89); 27 Jan 2016 18:52:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=sk:opt_wun, sk:OPT_Wun, prototypes 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; Wed, 27 Jan 2016 18:52:08 +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 (Postfix) with ESMTPS id A37A28CF5D; Wed, 27 Jan 2016 18:52:06 +0000 (UTC) Received: from tucnak.zalov.cz ([10.3.113.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0RIq50h001872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 27 Jan 2016 13:52:06 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u0RIq2cO004908; Wed, 27 Jan 2016 19:52:02 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u0RIpx9r004907; Wed, 27 Jan 2016 19:51:59 +0100 Date: Wed, 27 Jan 2016 18:52:00 -0000 From: Jakub Jelinek To: Richard Biener Cc: "Joseph S. Myers" , Marek Polacek , Jason Merrill , Jan Hubicka , GCC Patches Subject: Re: [C PATCH] Fix -Wunused-function (PR debug/66869) Message-ID: <20160127185159.GT3017@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20160125203829.GP3017@tucnak.redhat.com> <20160126161813.GB3017@tucnak.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-01/txt/msg02151.txt.bz2 Hi! On Wed, Jan 27, 2016 at 11:17:18AM +0100, Richard Biener wrote: > No, simply warn and set TREE_NO_WARNING so cgraph doesn't warn again. This seems to work too, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-01-25 Jakub Jelinek PR debug/66869 * c-decl.c (c_write_global_declarations_1): Warn with warn_unused_function if static prototype without definition is not C_DECL_USED. * gcc.dg/pr66869.c: New test. --- gcc/c/c-decl.c.jj 2016-01-25 22:33:11.813025064 +0100 +++ gcc/c/c-decl.c 2016-01-27 13:03:15.896068387 +0100 @@ -10741,11 +10741,22 @@ c_write_global_declarations_1 (tree glob if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) == 0 && DECL_EXTERNAL (decl) - && !TREE_PUBLIC (decl) - && C_DECL_USED (decl)) + && !TREE_PUBLIC (decl)) { - pedwarn (input_location, 0, "%q+F used but never defined", decl); - TREE_NO_WARNING (decl) = 1; + if (C_DECL_USED (decl)) + { + pedwarn (input_location, 0, "%q+F used but never defined", decl); + TREE_NO_WARNING (decl) = 1; + } + /* For -Wunused-function warn about unused static prototypes. */ + else if (warn_unused_function + && ! DECL_ARTIFICIAL (decl) + && ! TREE_NO_WARNING (decl)) + { + warning (OPT_Wunused_function, + "%q+F declared % but never defined", decl); + TREE_NO_WARNING (decl) = 1; + } } wrapup_global_declaration_1 (decl); --- gcc/testsuite/gcc.dg/pr66869.c.jj 2016-01-27 12:59:46.997929005 +0100 +++ gcc/testsuite/gcc.dg/pr66869.c 2016-01-27 12:59:46.997929005 +0100 @@ -0,0 +1,6 @@ +/* PR debug/66869 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused-function" } */ + +static void test (void); /* { dg-warning "'test' declared 'static' but never defined" } */ +int i; Jakub