From patchwork Sat Sep 7 08:28:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 273376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 772A12C0114 for ; Sat, 7 Sep 2013 18:28:58 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=gXAEzsIyzGoDao0v1 99yagdhNd7bfQqr4XOkJCApoNhEekeLo5Cyx6wAvjAB1qP2T7TQxGEi3N+P77IbU VfkuRhMQYx7KVzQhFqV+53KPNmug6YHfiFNug5mTeYoY2J99rynYnczzowyxyrVp Ee6nOXjyIXQjx4ZoxlcV6Mmih4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=cFs6W7wYYVTsSJJKZ1niFB1 Ke2w=; b=CKgghrY0e6BACyk4s+DhKu38DvQIEHoDex9tguwxbSCBCu+J2aapVcW NmQG8DS2e/j3jMw1tJcLnLeYpgQOjDEDZ5s4c70Buahu2CFN9nJie6d4GPWbbdkM 9dJwhPI/nrBAwsooTXbTDONqVue4jLGdYJOU6kT3YUsj8u7G2N8w= Received: (qmail 20986 invoked by alias); 7 Sep 2013 08:28:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 20974 invoked by uid 89); 7 Sep 2013 08:28:50 -0000 Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 07 Sep 2013 08:28:50 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, NO_RELAYS autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 4D988542F9F; Sat, 7 Sep 2013 10:28:46 +0200 (CEST) Date: Sat, 7 Sep 2013 10:28:46 +0200 From: Jan Hubicka To: Jan Hubicka Cc: Paolo Carlini , Richard Biener , Bernd Schmidt , gcc-patches@gcc.gnu.org, jason@redhat.com Subject: Re: [RFC] Fix for PR58201 Message-ID: <20130907082846.GC4841@kam.mff.cuni.cz> References: <20130904160409.GF20687@kam.mff.cuni.cz> <52276493.9070706@codesourcery.com> <20130904170918.GI20687@kam.mff.cuni.cz> <20130905230516.GB14285@kam.mff.cuni.cz> <5229FC71.2090709@oracle.com> <20130907080308.GA8074@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130907080308.GA8074@kam.mff.cuni.cz> User-Agent: Mutt/1.5.20 (2009-06-14) > > >+ 2013-09-04 Jan Hubicka > > >+ > > >+ PR middle-end/58201 > > >+ * cgraphunit.c (analyze_functions): Clear AUX fields > > >+ after processing; initialize assembler name has. > > >+ > > I checked and double checked and with this commit a C++ test regressed: > > > > FAIL: g++.dg/template/cond2.C -std=gnu++98 (test for warnings, line 9) > > FAIL: g++.dg/template/cond2.C -std=gnu++11 (test for warnings, line 9) > > > > In practice we emit a message off by one line, line 10 instead of > > the correct line 9. Is it possible that you are clearing too much, > > so to speak? > > Amazing, this testcase was triggering an ICE and I had to disable initialization > of assembler name hash when error arrived. That fixed the problem, but I did not > notice it is still having wrong line info. > > Adding an alias into the unit will trigger wrong line info before my change, since > assembler name hash is populated too. > > The error is output from DECL_ASSEMBLER_NAME hook that by itself is strange. > > #0 0x0000000001041490 in error(char const*, ...) () > #1 0x0000000000735039 in write_expression(tree_node*) () at ../../gcc/cp/mangle.c:3008 > #2 0x000000000073a70f in write_template_arg(tree_node*) () at ../../gcc/cp/mangle.c:3179 > #3 0x000000000073ae69 in write_template_args(tree_node*) () at ../../gcc/cp/mangle.c:2551 > #4 0x00000000007332a4 in write_name(tree_node*, int) () at ../../gcc/cp/mangle.c:821 > #5 0x000000000073700c in write_type(tree_node*) () at ../../gcc/cp/mangle.c:2522 > #6 0x0000000000737279 in write_type(tree_node*) () at ../../gcc/cp/mangle.c:2017 > #7 0x0000000000738a18 in write_method_parms(tree_node*, int, tree_node*) () at ../../gcc/cp/mangle.c:2509 > #8 0x0000000000738e2f in write_bare_function_type(tree_node*, int, tree_node*) () at ../../gcc/cp/mangle.c:2451 > #9 0x0000000000733b9e in write_mangled_name(tree_node*, bool) () at ../../gcc/cp/mangle.c:689 > #10 0x000000000073c5b6 in mangle_decl_string(tree_node*) () at ../../gcc/cp/mangle.c:3446 > #11 0x000000000073c7e9 in mangle_decl(tree_node*) () at ../../gcc/cp/mangle.c:3468 > #12 0x0000000000d1df01 in decl_assembler_name(tree_node*) () at ../../gcc/tree.c:546 > #13 0x000000000083b1f5 in insert_to_assembler_name_hash(symtab_node_def*, bool) () > #14 0x000000000083b352 in symtab_initialize_asm_name_hash() [clone .part.3] () In the tree prior my change: jh@gcc10:~/trunk/build4/gcc$ ./xgcc -B ./ -O2 ../../gcc/testsuite/g++.dg/template/cond2.C ../../gcc/testsuite/g++.dg/template/cond2.C: In instantiation of 'int test(c<(X ? : Y)>&) [with int X = 0; int Y = 2]': ../../gcc/testsuite/g++.dg/template/cond2.C:9:17: required from here ../../gcc/testsuite/g++.dg/template/cond2.C:6:28: error: omitted middle operand to '?:' operand cannot be mangled template int test(c&); // { dg-error "omitted" } ^ jh@gcc10:~/trunk/build4/gcc$ ./xgcc -B ./ -O2 ../../gcc/testsuite/g++.dg/template/cond2.C -flto ../../gcc/testsuite/g++.dg/template/cond2.C: In instantiation of 'int test(c<(X ? : Y)>&) [with int X = 0; int Y = 2]': ../../gcc/testsuite/g++.dg/template/cond2.C:6:28: required from here ../../gcc/testsuite/g++.dg/template/cond2.C:6:28: error: omitted middle operand to '?:' operand cannot be mangled template int test(c&); // { dg-error "omitted" } So it is just an accident that the line info is output sanely (if line 9 is sane, I don't exactly know) What I can think of is to hide the stale source location when it no longer have defined meaning: but of course this just leads to: jh@gcc10:~/trunk/build7/gcc$ ./xgcc -B ./ -O2 ../../gcc/testsuite/g++.dg/template/cond2.C ../../gcc/testsuite/g++.dg/template/cond2.C: In instantiation of 'int test(c<(X ? : Y)>&) [with int X = 0; int Y = 2]': :0:0: required from here ../../gcc/testsuite/g++.dg/template/cond2.C:6:28: error: omitted middle operand to '?:' operand cannot be mangled template int test(c&); // { dg-error "omitted" } So i think it is up to C++ FE to correctly set and restore location info if it wants to have error output correctly. DECL_SOURCE_LOCATION of the decl being mangled is 6 that leads to useless mesage: jh@gcc10:~/trunk/build7/gcc$ ./xgcc -B ./ -O2 ../../gcc/testsuite/g++.dg/template/cond2.C ../../gcc/testsuite/g++.dg/template/cond2.C: In instantiation of 'int test(c<(X ? : Y)>&) [with int X = 0; int Y = 2]': ../../gcc/testsuite/g++.dg/template/cond2.C:6:28: required from here ../../gcc/testsuite/g++.dg/template/cond2.C:6:28: error: omitted middle operand to '?:' operand cannot be mangled template int test(c&); // { dg-error "omitted" } Honza Index: cgraphunit.c =================================================================== --- cgraphunit.c (revision 202352) +++ cgraphunit.c (working copy) @@ -913,6 +913,7 @@ analyze_functions (void) bitmap_obstack_initialize (NULL); cgraph_state = CGRAPH_STATE_CONSTRUCTION; + input_location = UNKNOWN_LOCATION; /* Ugly, but the fixup can not happen at a time same body alias is created; C++ FE is confused about the COMDAT groups being right. */