From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69787 invoked by alias); 9 Mar 2017 15:57:49 -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 69778 invoked by uid 89); 9 Mar 2017 15:57:49 -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:2167 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 ESMTP; Thu, 09 Mar 2017 15:57:47 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8352EA89D; Thu, 9 Mar 2017 15:57:48 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-76.ams2.redhat.com [10.36.117.76]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v29Fvk8l004214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 9 Mar 2017 10:57:48 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v29FvivN001551; Thu, 9 Mar 2017 16:57:44 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v29FvgZ3001550; Thu, 9 Mar 2017 16:57:42 +0100 Date: Thu, 09 Mar 2017 15:57:00 -0000 From: Jakub Jelinek To: Marek Polacek Cc: "Joseph S. Myers" , gcc-patches@gcc.gnu.org Subject: Re: [C PATCH] Fix debug info locus of enum with previous forward declaration (PR c/79969) Message-ID: <20170309155742.GH22703@tucnak> Reply-To: Jakub Jelinek References: <20170309092443.GF22703@tucnak> <20170309154931.GD3172@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170309154931.GD3172@redhat.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00435.txt.bz2 On Thu, Mar 09, 2017 at 04:49:31PM +0100, Marek Polacek wrote: > On Thu, Mar 09, 2017 at 10:24:43AM +0100, Jakub Jelinek wrote: > > Hi! > > > > Similarly to https://gcc.gnu.org/ml/gcc-patches/2009-09/msg01161.html > > the C FE gets wrong the location of DW_TAG_enumeral_type if there is a > > forward declaration. If we e.g. have a variable that is first declared > > extern and then defined, we emit DW_TAG_variable with the location of the > > first declaration and then another DW_TAG_variable with DW_AT_specification > > pointing to the previous one for the definition, with locus of the > > definition. That is not what we do for enums, there is just one DIE, so we > > should use the more descriptive from the locations, which is the definition. > > > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > > > 2017-03-09 Jakub Jelinek > > > > PR c/79969 > > * c-decl.c (start_enum): Adjust DECL_SOURCE_LOCATION of > > TYPE_STUB_DECL. > > How about doing this in finish_enum, similarly to finish_struct? You'd need to > pass a location from the parser, but that's easy: That would be just for consistency with finish_struct, right? Not sure if we need such consistency, but I don't care that much. The point to put it into start_enum was that we don't really care about the location of the forward declaration after that. That said, there is one thing I'm wondering about: if (name != NULL_TREE) enumtype = lookup_tag (ENUMERAL_TYPE, name, true, &enumloc); if (enumtype == NULL_TREE || TREE_CODE (enumtype) != ENUMERAL_TYPE) { enumtype = make_node (ENUMERAL_TYPE); pushtag (loc, name, enumtype); } with the optional patched spot after this. Now, if somebody does: enum E; enum E { A, B, C }; enum E { D, F }; then I think we'll complain about line 3 overriding previous definition at line 1 (which is not right). Maybe if there is TYPE_STUB_DECL (do we have it always?), we can override enumloc = DECL_SOURCE_LOCATION (TYPE_STUB_DECL (enumtype));? I bet trying to change the binding ->locus would be too much work. Jakub