Here we were seeing errors because of template instantiation triggered by mark_used within fold_non_dependent_expr. We don't want to instantiate templates based on uses in other uninstantiated templates, and we were already trying to avoid that; let's add another check to avoid it.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 619400bca71f10d05e6adfaaef53c67997fb3f57
Author: Jason Merrill <ja...@redhat.com>
Date:   Thu Dec 18 12:10:38 2014 -0500

    	PR c++/64251
    	* decl2.c (mark_used): Don't mark if in_template_function.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b2123f2..69201b0 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -5017,7 +5017,7 @@ mark_used (tree decl, tsubst_flags_t complain)
       --function_depth;
     }
 
-  if (processing_template_decl)
+  if (processing_template_decl || in_template_function ())
     return true;
 
   /* Check this too in case we're within instantiate_non_dependent_expr.  */
diff --git a/gcc/testsuite/g++.dg/template/non-dependent14.C b/gcc/testsuite/g++.dg/template/non-dependent14.C
new file mode 100644
index 0000000..b257d9b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/non-dependent14.C
@@ -0,0 +1,7 @@
+// PR c++/64251
+
+class DictionaryValue {};
+template <typename T> void CreateValue(T) {
+  DictionaryValue(0);
+  CreateValue(0);
+}

Reply via email to