[PATCH] Fix tsubst_init error recovery (PR c++/78649)

Jakub Jelinek jakub@redhat.com
Fri Dec 2 20:41:00 GMT 2016


Hi!

Trying to value initialize error_mark_node type ICEs, other spots avoid
calling build_value_init* if the type is error_mark_node.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-12-02  Jakub Jelinek  <jakub@redhat.com>

	PR c++/78649
	* pt.c (tsubst_init): Don't call build_value_init if decl's type
	is error_mark_node.

	* g++.dg/cpp0x/pr78649.C: New test.

--- gcc/cp/pt.c.jj	2016-11-23 16:58:30.000000000 +0100
+++ gcc/cp/pt.c	2016-12-02 14:38:43.237451068 +0100
@@ -14082,7 +14082,7 @@ tsubst_init (tree init, tree decl, tree
 
   init = tsubst_expr (init, args, complain, in_decl, false);
 
-  if (!init)
+  if (!init && TREE_TYPE (decl) != error_mark_node)
     {
       /* If we had an initializer but it
 	 instantiated to nothing,
--- gcc/testsuite/g++.dg/cpp0x/pr78649.C.jj	2016-12-02 14:51:02.057892855 +0100
+++ gcc/testsuite/g++.dg/cpp0x/pr78649.C	2016-12-02 14:50:42.000000000 +0100
@@ -0,0 +1,16 @@
+// PR c++/78649
+// { dg-do compile { target c++11 } }
+
+template <class> void foo ();
+template <class T, class... U>
+void
+test ()
+{
+  T t (foo<U>...);	// { dg-error "declared void" }
+}
+
+int
+main ()
+{
+  test<void> ();
+}

	Jakub



More information about the Gcc-patches mailing list