public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/64251 (unnecessary template instantiation)
@ 2014-12-18 22:20 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2014-12-18 22:20 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 336 bytes --]

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.

[-- Attachment #2: 64251.patch --]
[-- Type: text/x-patch, Size: 998 bytes --]

commit 619400bca71f10d05e6adfaaef53c67997fb3f57
Author: Jason Merrill <jason@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);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-18 22:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-18 22:20 C++ PATCH for c++/64251 (unnecessary template instantiation) Jason Merrill

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).