From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44283 invoked by alias); 26 Jan 2016 16:18:23 -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 44272 invoked by uid 89); 26 Jan 2016 16:18:22 -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=Hx-languages-length:1402, Err, 08pm, 08PM 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; Tue, 26 Jan 2016 16:18:22 +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 EE6F68F013; Tue, 26 Jan 2016 16:18:20 +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 u0QGIJQg007803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 26 Jan 2016 11:18:20 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u0QGIGKr032346; Tue, 26 Jan 2016 17:18:17 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u0QGIDHN032345; Tue, 26 Jan 2016 17:18:13 +0100 Date: Tue, 26 Jan 2016 16:18: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: <20160126161813.GB3017@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20160125203829.GP3017@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/msg02003.txt.bz2 On Tue, Jan 26, 2016 at 04:21:08PM +0100, Richard Biener wrote: > > --- gcc/c/c-decl.c.jj 2016-01-21 00:41:47.000000000 +0100 > > +++ gcc/c/c-decl.c 2016-01-25 16:36:31.973504082 +0100 > > @@ -10741,11 +10741,19 @@ 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 push the unused statics into cgraph, > > + so that check_global_declaration emits the warning. */ > > + else if (warn_unused_function > > + && ! DECL_ARTIFICIAL (decl) > > + && ! TREE_NO_WARNING (decl)) > > + cgraph_node::get_create (decl); > > Err, so why not warn here directly? You mean check if it has a cgraph node (i.e. get instead of get_create) and if it doesn't, warn? What I'm worried in that case is that it might have a cgraph node created later on for whatever reason and that we'll get double warning (from here and from cgraphunit.c (check_global_declaration)). I can try it though. Jakub