From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30446 invoked by alias); 10 Jun 2011 18:37:42 -0000 Received: (qmail 30438 invoked by uid 22791); 10 Jun 2011 18:37:42 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD 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; Fri, 10 Jun 2011 18:37:28 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5AIbRtq028655 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 10 Jun 2011 14:37:27 -0400 Received: from localhost (ovpn-113-108.phx2.redhat.com [10.3.113.108]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5AIbPW8019793 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 10 Jun 2011 14:37:27 -0400 Received: by localhost (Postfix, from userid 500) id 2AF1E29C05D; Fri, 10 Jun 2011 20:37:25 +0200 (CEST) From: Dodji Seketeli To: Jason Merrill Cc: GCC Patches Subject: [PATCH] PR debug/49348 (DW_TAG_template_* missing from template specializations) X-URL: http://www.redhat.com Mail-Followup-To: Jason Merrill , GCC Patches Date: Fri, 10 Jun 2011 18:40:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 X-SW-Source: 2011-06/txt/msg00875.txt.bz2 Hello, For a given template instantiation, the dwarf backend emits debug info that describes its template parameters and arguments if generic_type_p returns TRUE on the the instantiation. For that, primary_template_instantiation_p must be also return TRUE. The problem in this PR is that primary_template_instantiation_p doesn't return TRUE for explicit specializations. This patch makes it return TRUE for explicit specializations and instantiations of a primary template. I have renamed the function primary_template_instantiation_p into primary_template_specialization_p, as [temp.spec]/4 reads: A specialization is a class, function, or class member that is either instantiated or explicitly specialized Tested on x86_64-unknown-linux-gnu against trunk. gcc/cp/ * cp-tree.h (primary_template_specialization_p): Rename primary_template_instantiatiation_p into this. * pt.c (primary_template_specialization_p): Likewise. Don't rule out explicit template specializations. (get_function_template_decl) (get_primary_template_innermost_parameters): Adjust. * call.c (non_placement_deallocation_fn_p): Adjust. gcc/testsuite/ * g++.dg/debug/dwarf2/typedef1.C: Adjust to test that a DW_TAG_template_value_param DIE is emitted. --- gcc/cp/call.c | 2 +- gcc/cp/cp-tree.h | 2 +- gcc/cp/pt.c | 11 +++++------ gcc/testsuite/g++.dg/debug/dwarf2/typedef1.C | 1 + 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 4ee0eaf..51a2a2c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5183,7 +5183,7 @@ non_placement_deallocation_fn_p (tree t) /* A template instance is never a usual deallocation function, regardless of its signature. */ if (TREE_CODE (t) == TEMPLATE_DECL - || primary_template_instantiation_p (t)) + || primary_template_specialization_p (t)) return false; /* If a class T has a member deallocation function named operator delete diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 06b5926..aef7053 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5200,7 +5200,7 @@ extern bool parameter_of_template_p (tree, tree); extern void init_template_processing (void); extern void print_template_statistics (void); bool template_template_parameter_p (const_tree); -extern bool primary_template_instantiation_p (const_tree); +extern bool primary_template_specialization_p (const_tree); extern tree get_primary_template_innermost_parameters (const_tree); extern tree get_template_parms_at_level (tree, int); extern tree get_template_innermost_arguments (const_tree); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 814a08f..01bafe8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2760,7 +2760,7 @@ get_function_template_decl (const_tree primary_func_tmpl_inst) { if (! primary_func_tmpl_inst || TREE_CODE (primary_func_tmpl_inst) != FUNCTION_DECL - || ! primary_template_instantiation_p (primary_func_tmpl_inst)) + || ! primary_template_specialization_p (primary_func_tmpl_inst)) return NULL; return DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (primary_func_tmpl_inst)); @@ -2829,18 +2829,17 @@ make_ith_pack_parameter_name (tree name, int i) or class template instantiation. */ bool -primary_template_instantiation_p (const_tree t) +primary_template_specialization_p (const_tree t) { if (!t) return false; if (TREE_CODE (t) == FUNCTION_DECL) return DECL_LANG_SPECIFIC (t) - && DECL_TEMPLATE_INSTANTIATION (t) + && DECL_USE_TEMPLATE (t) && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t)); else if (CLASS_TYPE_P (t)) - return CLASSTYPE_TEMPLATE_INSTANTIATION (t) - && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t)); + return CLASSTYPE_SPECIALIZATION_OF_PRIMARY_TEMPLATE_P (t); return false; } @@ -2861,7 +2860,7 @@ get_primary_template_innermost_parameters (const_tree t) tree parms = NULL, template_info = NULL; if ((template_info = get_template_info (t)) - && primary_template_instantiation_p (t)) + && primary_template_specialization_p (t)) parms = INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (TI_TEMPLATE (template_info))); diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/typedef1.C b/gcc/testsuite/g++.dg/debug/dwarf2/typedef1.C index a9ce44d..38a6753 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/typedef1.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/typedef1.C @@ -9,6 +9,7 @@ // { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_enumeration_type" 1 } } // { dg-final { scan-assembler-times "\"e0..\"\[^\n\]*DW_AT_name" 1 } } // { dg-final { scan-assembler-times "\"e1..\"\[^\n\]*DW_AT_name" 1 } } +// { dg-final { scan-assembler-times "DIE \\(0x\[^\n\r\]*\\) DW_TAG_template_value_param" 1 } } template struct foo -- Dodji