This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/63588 (ICE with empty template args to variable template)


uses_template_parms ought to be able to deal with NULL_TREE.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 3a85a7bd7ea664fb594843433c51f3b6cbb320d3
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Nov 21 13:46:34 2014 -0500

    	PR c++/63588
    	* pt.c (uses_template_parms): Handle null argument.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 71b7af1..1d6b916 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8294,6 +8294,9 @@ for_each_template_parm (tree t, tree_fn_t fn, void* data,
 int
 uses_template_parms (tree t)
 {
+  if (t == NULL_TREE)
+    return false;
+
   bool dependent_p;
   int saved_processing_template_decl;
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ15.C b/gcc/testsuite/g++.dg/cpp1y/var-templ15.C
new file mode 100644
index 0000000..7dd2dcd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/var-templ15.C
@@ -0,0 +1,5 @@
+// PR c++/63588
+// { dg-do compile { target c++14 } }
+
+template <class T> T elements;
+int i = elements <>;		// { dg-error "arguments" }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]