From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72782 invoked by alias); 23 Feb 2016 08:27:01 -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 72755 invoked by uid 89); 23 Feb 2016 08:27:00 -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=involves, randomly 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, 23 Feb 2016 08:26:59 +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 4188E1E36; Tue, 23 Feb 2016 08:26:58 +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 u1N8Qu95028908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 23 Feb 2016 03:26:57 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u1N8Qsex001291; Tue, 23 Feb 2016 09:26:54 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u1N8QqxT001290; Tue, 23 Feb 2016 09:26:52 +0100 Date: Tue, 23 Feb 2016 08:27:00 -0000 From: Jakub Jelinek To: Mark Wielaard Cc: "H.J. Lu" , Jeff Law , GCC Patches , Bernd Schmidt , Martin Sebor , Steve Ellcey , Manuel =?iso-8859-1?B?TPNwZXotSWLh8WV6?= Subject: Re: [PATCH] PR28901 Add two levels for -Wunused-const-variable. Message-ID: <20160223082652.GV3017@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <5603E4D3.4050806@redhat.com> <1456018952-25270-1-git-send-email-mjw@redhat.com> <56CB5A34.8030301@redhat.com> <20160222224312.GK2586@blokker.redhat.com> <1456214140.7770.101.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1456214140.7770.101.camel@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg01539.txt.bz2 On Tue, Feb 23, 2016 at 08:55:40AM +0100, Mark Wielaard wrote: > On Mon, 2016-02-22 at 19:20 -0800, H.J. Lu wrote: > > It caused: > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69911 > > Apologies. Apparently main_input_filename can be NULL. I am not entirely > sure when that happens. Or how I failed to see that test failure. I > think I didn't have java enabled, causing libffi to be skipped. > > I am testing this patch that skips the test in that case: Are you sure that is the problem? I think it doesn't hurt to check for non-NULL main_input_filename, perhaps some non-c-family languages might not set it, and this is in generic code, but at least on the gcc.target/i386/iamcu/test_passing_structs.c testcase and on one randomly selected libffi testcase I see the ICE from completely different reason - what is NULL is DECL_SOURCE_FILE (decl). decl is e.g. unit size align 8 symtab 0 alias set 6 canonical type 0x7ffff18865e8 fields QI file /usr/src/gcc/gcc/testsuite/gcc.target/i386/iamcu/test_passing_structs.c line 133 col 8 size unit size align 8 offset_align 32 offset bit offset context chain > context chain > readonly addressable static ignored in-constant-pool BLK file (null) line 0 col 0 size unit size align 32 initial > We are not really going to warn about this anyway, e.g. because it is DECL_ARTIFICIAL, but that is checked only in a much later condition. So, I think you should check also for NULL DECL_SOURCE_FILE (and treat it as possibly in a header). Unfortunately DECL_SOURCE_FILE involves a function call, so you might want to cache it in some automatic variable. && (warn_unused_const_variable == 2 || (main_input_filename != NULL && (decl_file = DECL_SOURCE_FILE (decl)) != NULL && filename_cmp (main_input_filename, decl_file) == 0)))) Jakub