From 10d3a72a808a1daa4a98a8be95a858a0aa053f3f Mon Sep 17 00:00:00 2001
From: Paolo Carlini <paolo.carlini@oracle.com>
Date: Fri, 20 Nov 2009 16:03:19 +0000
Subject: [PATCH] re PR c++/42060 ([c++0x] ICE throwing array with initializer
 list)

cp/
2009-11-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/42060
	* except.c (build_throw): Check the tree returned by
	decay_conversion for error_mark_node.

testsuite/
2009-11-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/42060
	* g++.dg/cpp0x/initlist28.C: New.

From-SVN: r154371
---
 gcc/cp/ChangeLog                        | 6 ++++++
 gcc/cp/except.c                         | 8 ++++++--
 gcc/testsuite/ChangeLog                 | 5 +++++
 gcc/testsuite/g++.dg/cpp0x/initlist28.C | 8 ++++++++
 4 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist28.C

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b5b2b04fe1d8..a4024ef51552 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+	PR c++/42060
+	* except.c (build_throw): Check the tree returned by
+	decay_conversion for error_mark_node.
+
 2009-11-20  Shujing Zhao  <pearly.zhao@oracle.com>
 
 	PR c++/29017
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 1b13819ed674..66dc14eaefbc 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -752,8 +752,12 @@ build_throw (tree exp)
 	    }
 	}
       else
-	exp = build2 (INIT_EXPR, temp_type, object,
-		      decay_conversion (exp));
+	{
+	  tmp = decay_conversion (exp);
+	  if (tmp == error_mark_node)
+	    return error_mark_node;
+	  exp = build2 (INIT_EXPR, temp_type, object, tmp);
+	}
 
       /* Pre-evaluate the thrown expression first, since if we allocated
 	 the space first we would have to deal with cleaning it up if
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4cc2378cdb35..de7ab00fd2b5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+	PR c++/42060
+	* g++.dg/cpp0x/initlist28.C: New.
+
 2009-11-20  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* gfortran.dg/proc_ptr_comp_23.f90: Add a missing space.
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist28.C b/gcc/testsuite/g++.dg/cpp0x/initlist28.C
new file mode 100644
index 000000000000..3b959a03a533
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist28.C
@@ -0,0 +1,8 @@
+// PR c++/42060
+// { dg-options "-std=c++0x" }
+
+void foo()
+{
+  int a[1];
+  throw a = {}; // { dg-error "invalid use of non-lvalue array" }
+}
-- 
GitLab