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++/65625 (ICE using variable template as type)


We were specifically handling misuse of a function template, but we also need to handle variable templates now.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit d743a07ee6b19b3fec59c81ae2cbedbf38d91c4b
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 1 19:02:03 2015 -0400

    	PR c++/65625
    	* decl.c (make_typename_type): Handle seeing a variable template.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 31b8e0c..c4731ae 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3480,9 +3480,9 @@ make_typename_type (tree context, tree name, enum tag_types tag_type,
   if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
     {
       name = TREE_OPERAND (name, 0);
-      if (TREE_CODE (name) == TEMPLATE_DECL)
+      if (DECL_TYPE_TEMPLATE_P (name))
 	name = TREE_OPERAND (fullname, 0) = DECL_NAME (name);
-      else if (TREE_CODE (name) == OVERLOAD)
+      if (TREE_CODE (name) != IDENTIFIER_NODE)
 	{
 	  if (complain & tf_error)
 	    error ("%qD is not a type", name);
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ23.C b/gcc/testsuite/g++.dg/cpp1y/var-templ23.C
new file mode 100644
index 0000000..a5b19d2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/var-templ23.C
@@ -0,0 +1,7 @@
+// PR c++/65625
+// { dg-do compile { target c++14 } }
+
+namespace std {
+  template <typename T> int declval;
+  typename std::declval<> d;	// { dg-error "not a type" }
+}

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