re PR c++/65625 (ICE in make_typename_type, at cp/decl.c:3499)
authorJason Merrill <jason@redhat.com>
Thu, 2 Apr 2015 16:43:02 +0000 (12:43 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 2 Apr 2015 16:43:02 +0000 (12:43 -0400)
PR c++/65625
* decl.c (make_typename_type): Handle seeing a variable template.

From-SVN: r221842

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp1y/var-templ23.C [new file with mode: 0644]

index d3dbd671ed113f871ac34ec7de577dde498c74c3..6f300fb20da982304aba11a5f4bcc0979fed2c9a 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/65625
+       * decl.c (make_typename_type): Handle seeing a variable template.
+
 2015-04-01  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/56100
index 31b8e0cf50a68b7d759e012dda092c264d724bd2..c4731ae2416e61e282447da957370960946fd70b 100644 (file)
@@ -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 (file)
index 0000000..a5b19d2
--- /dev/null
@@ -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" }
+}