public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] PR debug/49348 (DW_TAG_template_* missing from template specializations)
Date: Fri, 10 Jun 2011 18:40:00 -0000	[thread overview]
Message-ID: <m3mxhpfs7u.fsf@redhat.com> (raw)

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 <unsigned int n>
 struct foo
-- 
		Dodji

             reply	other threads:[~2011-06-10 18:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-10 18:40 Dodji Seketeli [this message]
2011-06-10 19:15 ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3mxhpfs7u.fsf@redhat.com \
    --to=dodji@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).