[C++ PATCH] Fix reference_binding for brace enclosed list containing error mark (PR c++/42061)

Jakub Jelinek jakub@redhat.com
Mon Nov 16 19:38:00 GMT 2009


Hi!

On this testcase, reference_binding ICEs because it doesn't expect expr to
be error_mark_node (resp. its type to be error_mark_node rather than a
type).  The callers are checking expr passed to it, so we just need to check
the single element of a brace initialized list.

Bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for trunk/4.4?

2009-11-16  Jakub Jelinek  <jakub@redhat.com>

	PR c++/42061
	* call.c (reference_binding): Return NULL for initializer list with
	error operand inside of it.

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

--- gcc/cp/call.c.jj	2009-11-13 11:13:20.000000000 +0100
+++ gcc/cp/call.c	2009-11-16 16:58:58.000000000 +0100
@@ -1235,6 +1235,8 @@ reference_binding (tree rto, tree rfrom,
 	  && CONSTRUCTOR_NELTS (expr) == 1)
 	{
 	  expr = CONSTRUCTOR_ELT (expr, 0)->value;
+	  if (error_operand_p (expr))
+	    return NULL;
 	  from = TREE_TYPE (expr);
 	}
     }
--- gcc/testsuite/g++.dg/cpp0x/initlist27.C.jj	2009-11-16 17:01:52.000000000 +0100
+++ gcc/testsuite/g++.dg/cpp0x/initlist27.C	2009-11-16 17:02:36.000000000 +0100
@@ -0,0 +1,5 @@
+// PR c++/42061
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+int& i = { j };	// { dg-error "invalid initialization|was not declared" }

	Jakub



More information about the Gcc-patches mailing list