From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3743 invoked by alias); 27 Jan 2016 10:17:22 -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 3721 invoked by uid 89); 27 Jan 2016 10:17:21 -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_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yk0-f176.google.com Received: from mail-yk0-f176.google.com (HELO mail-yk0-f176.google.com) (209.85.160.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 27 Jan 2016 10:17:20 +0000 Received: by mail-yk0-f176.google.com with SMTP id y137so11968336yka.2 for ; Wed, 27 Jan 2016 02:17:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=bMfEdmxAvO7GwqxwZudU0eifHPR5wwp1blJzOr/DZu0=; b=HQ8vgzpqrpyLfbJNGwzGSHhNTIGqQl0JidCLoGR2JrHiiMFpg8QTw86vfn5WOk16iu lonO9+sXfix0V6H8BYBTpqNCral2NWlKiBCitoe24ZBpdTxZyCJu66u9cuCP0rfmcB7M m2Wv8Y/YBD7dRk057UWs7crbnek1OguqRRxAFB3BxBUj1NqTIcTPOFnzUB1zpQx1xFeU JTyYO3x1Vs+JxCqWCzvHlyPp1yPiE5hUfms5pdL/ILfWU8M+1Ebrf/Byz8NmHjQinBX6 uiMJ8DCMvOFCTRwx2FM2DKcS1cjJFmcHY+lAfbfVghnu7E0sCf6IzQvaaVXXcXhxC40q 5/lw== X-Gm-Message-State: AG10YOSGaSKMJjpeun8hbnTbRKJSChrcqUj0+o1KGKg/6dZyT5xFL3C4QR87s3ecX9GT6EAoHx0bWoCKXr9pBQ== MIME-Version: 1.0 X-Received: by 10.129.145.22 with SMTP id i22mr13565759ywg.5.1453889838328; Wed, 27 Jan 2016 02:17:18 -0800 (PST) Received: by 10.37.202.82 with HTTP; Wed, 27 Jan 2016 02:17:18 -0800 (PST) In-Reply-To: <20160126161813.GB3017@tucnak.redhat.com> References: <20160125203829.GP3017@tucnak.redhat.com> <20160126161813.GB3017@tucnak.redhat.com> Date: Wed, 27 Jan 2016 10:17:00 -0000 Message-ID: Subject: Re: [C PATCH] Fix -Wunused-function (PR debug/66869) From: Richard Biener To: Jakub Jelinek Cc: "Joseph S. Myers" , Marek Polacek , Jason Merrill , Jan Hubicka , GCC Patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-01/txt/msg02094.txt.bz2 On Tue, Jan 26, 2016 at 5:18 PM, Jakub Jelinek wrote: > 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. No, simply warn and set TREE_NO_WARNING so cgraph doesn't warn again. Richard. > Jakub