diff mbox

C++ PATCH for c++/51403 (ICE with void template parameter)

Message ID 4F0F130A.8090103@redhat.com
State New
Headers show

Commit Message

Jason Merrill Jan. 12, 2012, 5:06 p.m. UTC
Simple error-recovery.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 547a34a4cc962c0aa2d914416e94e014900c33b6
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jan 12 06:15:17 2012 -0500

    	PR c++/51403
    	* pt.c (unify): Handle error_mark_node.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ac72b6d..97a9294 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -16272,6 +16272,8 @@  unify (tree tparms, tree targs, tree parm, tree arg, int strict,
       idx = TEMPLATE_TYPE_IDX (parm);
       targ = TREE_VEC_ELT (INNERMOST_TEMPLATE_ARGS (targs), idx);
       tparm = TREE_VALUE (TREE_VEC_ELT (tparms, idx));
+      if (tparm == error_mark_node)
+	return unify_invalid (explain_p);
 
       /* Check for mixed types and values.  */
       if ((TREE_CODE (parm) == TEMPLATE_TYPE_PARM
diff --git a/gcc/testsuite/g++.dg/template/arg8.C b/gcc/testsuite/g++.dg/template/arg8.C
new file mode 100644
index 0000000..adcd013
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/arg8.C
@@ -0,0 +1,7 @@ 
+template<typename T, void, typename U> // { dg-error "void" }
+void foo(T, U, int) {}
+
+void bar()
+{
+  foo(0, 0, 0);			// { dg-error "no match" }
+}