C++ PATCH for c++/84376, ICE with missing template arguments

Jason Merrill jason@redhat.com
Thu Feb 15 19:46:00 GMT 2018


Here we are asked deduction_guide_p about a TEMPLATE_ID_EXPR; give the
right answer.

Tested x86_64-pc-linux-gnu, applying to trunk.
-------------- next part --------------
commit 6ef5c80e09542b55e5dc4e66db87c78adfc0a266
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Feb 15 13:37:58 2018 -0500

            PR c++/84376 - ICE with omitted template arguments.
    
            * pt.c (dguide_name_p): Check for IDENTIFIER_NODE.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index cd1aed8d677..268cfe5a454 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -25454,7 +25454,8 @@ dguide_name (tree tmpl)
 bool
 dguide_name_p (tree name)
 {
-  return (TREE_TYPE (name)
+  return (TREE_CODE (name) == IDENTIFIER_NODE
+	  && TREE_TYPE (name)
 	  && !strncmp (IDENTIFIER_POINTER (name), dguide_base,
 		       strlen (dguide_base)));
 }
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction47.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction47.C
new file mode 100644
index 00000000000..3e47f58e698
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction47.C
@@ -0,0 +1,7 @@
+// PR c++/84376
+
+template<int> struct A {};
+
+template<typename T> T foo() { return T(); }
+
+template<> A foo<A>();		// { dg-error "A" }


More information about the Gcc-patches mailing list