summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2006-06-16 02:09:10 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2006-06-16 02:09:10 +0000
commit54daf078a77b59cac5a460b62816367e07c7382d (patch)
tree462bb323dcfbee6531d4cdcd154b78f02a6234de
parent733ed9fe3c6100b6786a03e3c433f2a9ce35cfec (diff)
downloadppe42-gcc-54daf078a77b59cac5a460b62816367e07c7382d.tar.gz
ppe42-gcc-54daf078a77b59cac5a460b62816367e07c7382d.zip
PR c++/27640
* pt.c (instantiate_template): Set processing_template_decl to zero while performing substitutions. PR c++/27640 * g++.dg/template/ctor7.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114701 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c11
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/ctor7.C19
4 files changed, 40 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 78e4ed861c8..f80d362db88 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2006-06-15 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/27640
+ * pt.c (instantiate_template): Set processing_template_decl to
+ zero while performing substitutions.
+
2006-06-14 Mark Mitchell <mark@codesourcery.com>
PR c++/27665
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 0cc93fdbb11..d25ea79fae8 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9233,6 +9233,7 @@ instantiate_template (tree tmpl, tree targ_ptr, tsubst_flags_t complain)
tree fndecl;
tree gen_tmpl;
tree spec;
+ HOST_WIDE_INT saved_processing_template_decl;
if (tmpl == error_mark_node)
return error_mark_node;
@@ -9292,9 +9293,17 @@ instantiate_template (tree tmpl, tree targ_ptr, tsubst_flags_t complain)
deferring all checks until we have the FUNCTION_DECL. */
push_deferring_access_checks (dk_deferred);
- /* Substitute template parameters. */
+ /* Although PROCESSING_TEMPLATE_DECL may be true at this point
+ (because, for example, we have encountered a non-dependent
+ function call in the body of a template function must determine
+ which of several overloaded functions will be called), within the
+ instantiation itself we are not processing a template. */
+ saved_processing_template_decl = processing_template_decl;
+ processing_template_decl = 0;
+ /* Substitute template parameters to obtain the specialization. */
fndecl = tsubst (DECL_TEMPLATE_RESULT (gen_tmpl),
targ_ptr, complain, gen_tmpl);
+ processing_template_decl = saved_processing_template_decl;
if (fndecl == error_mark_node)
return error_mark_node;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 25fd9f9dd62..9f056c38cd5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-15 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/27640
+ * g++.dg/template/ctor7.C: New test.
+
2006-06-15 Janis Johnson <janis187@us.ibm.com>
* gcc.dg/vmx/pr27842.c: Remove dg-do directive; use default.
diff --git a/gcc/testsuite/g++.dg/template/ctor7.C b/gcc/testsuite/g++.dg/template/ctor7.C
new file mode 100644
index 00000000000..ee65172fe75
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ctor7.C
@@ -0,0 +1,19 @@
+// PR c++/27640
+
+template < class T > struct refcounted :
+virtual T
+{
+ template < class A1 > refcounted (const A1 & a1) : T () { }
+};
+struct nfsserv {};
+template < class T >
+void
+sfsserver_cache_alloc (int *ns)
+{
+ new refcounted < nfsserv > (*ns);
+}
+void
+usage ()
+{
+ sfsserver_cache_alloc < int > ( 0);
+}
OpenPOWER on IntegriCloud