From patchwork Thu Jan 31 15:20:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 217210 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]) by ozlabs.org (Postfix) with SMTP id 6362F2C008E for ; Fri, 1 Feb 2013 03:16:02 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1360253763; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=hWj3KSW sjMdp1pnWeS+fURiN6Ps=; b=l8y1CJosH2twE4VH5r6jZjOgOmPWHP5W45AnqIC /rMAoPQZKPQ0Ia6KKyS0efSS/nMHirrcbhGKv9y0Ul6R9XM0Yt4lPwosYreiWHnI lUbGbtudY+vcuUMzbcp3rDGGHwfH51k3RUNGjNerVrpaXqKuD0BOQQEcXAQQxYjN QN1Q= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=qj9QIB342W/SflRySqjVACr9Hbs4nCiTfnmZttxRttQUlmp0Pq2cmE6oFtfZTp 0zNstiVg7d9ry0Md5R9/2chvJ6Wer5v96YnFTPdQMUK5ehpVjeLAdi5nlNj3A6CM cOzf5CI2squ5bd94/v459nebZHa0V4ndOUqc1p5WlafsA=; Received: (qmail 21800 invoked by alias); 31 Jan 2013 16:15:49 -0000 Received: (qmail 21747 invoked by uid 22791); 31 Jan 2013 16:15:42 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 31 Jan 2013 16:15:37 +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 (8.14.4/8.14.4) with ESMTP id r0VGFaui001636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 31 Jan 2013 11:15:36 -0500 Received: from [10.3.113.27] (ovpn-113-27.phx2.redhat.com [10.3.113.27]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0VFKJWr018137 for ; Thu, 31 Jan 2013 10:20:24 -0500 Message-ID: <510A8BB3.9030809@redhat.com> Date: Thu, 31 Jan 2013 10:20:19 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/54410 (duplicate template bindings in DWARF) 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 We ended up inserting the type in the array of types to add template parameters to twice, so we added the parameters twice. Fixed by only adding it the first time; it doesn't matter whether we happen to be creating a declaration or definition DIE at this point, since when we get to EOF we'll add the bindings to the definition die (if any). Tested x86_64-pc-linux-gnu, applying to trunk. commit 1e9546939b355bd9f84e1928e1599b3a9f3bbe21 Author: Jason Merrill Date: Wed Jan 30 17:21:49 2013 -0500 PR c++/54410 * dwarf2out.c (gen_struct_or_union_type_die): Always schedule template parameters the first time. (gen_scheduled_generic_parms_dies): Check completeness here. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 5a03280..3106dd9 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -19061,6 +19061,10 @@ gen_struct_or_union_type_die (tree type, dw_die_ref context_die, scope_die = scope_die_for (type, context_die); + /* Generate child dies for template paramaters. */ + if (!type_die && debug_info_level > DINFO_LEVEL_TERSE) + schedule_generic_params_dies_gen (type); + if (! type_die || (nested && is_cu_die (scope_die))) /* First occurrence of type or toplevel definition of nested class. */ { @@ -19078,11 +19082,6 @@ gen_struct_or_union_type_die (tree type, dw_die_ref context_die, else remove_AT (type_die, DW_AT_declaration); - /* Generate child dies for template paramaters. */ - if (debug_info_level > DINFO_LEVEL_TERSE - && COMPLETE_TYPE_P (type)) - schedule_generic_params_dies_gen (type); - /* If this type has been completed, then give it a byte_size attribute and then give a list of members. */ if (complete && !ns_decl) @@ -20592,7 +20591,8 @@ gen_scheduled_generic_parms_dies (void) return; FOR_EACH_VEC_ELT (*generic_type_instances, i, t) - gen_generic_params_dies (t); + if (COMPLETE_TYPE_P (t)) + gen_generic_params_dies (t); } diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-11.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-11.C new file mode 100644 index 0000000..8000295 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-11.C @@ -0,0 +1,9 @@ +// PR c++/54410 +// { dg-options "-g -dA" } +// { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_template_type_param" 1 } } + +namespace N { + template struct A { }; +} + +N::A a;