This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/50054 (ICE after error with init-list)


It is possible to run into a situation where we don't know what to do with an initializer-list.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.6.
commit 1a54ca9d63f7e6453b3327a5699a39696f856a79
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Aug 15 06:15:17 2011 -0400

    	PR c++/50054
    	* typeck2.c (cxx_incomplete_type_diagnostic): Handle
    	init_list_type_node.

diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 0788138..79aa354 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -450,6 +450,12 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
       break;
 
     case LANG_TYPE:
+      if (type == init_list_type_node)
+	{
+	  emit_diagnostic (diag_kind, input_location, 0,
+			   "invalid use of brace-enclosed initializer list");
+	  break;
+	}
       gcc_assert (type == unknown_type_node);
       if (value && TREE_CODE (value) == COMPONENT_REF)
 	goto bad_member;
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist57.C b/gcc/testsuite/g++.dg/cpp0x/initlist57.C
new file mode 100644
index 0000000..d945a46
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist57.C
@@ -0,0 +1,8 @@
+// PR c++/50054
+// { dg-options -std=c++0x }
+
+void g( const int& (a)[1] ) {}	// { dg-error "array of references" }
+
+int main () {
+    g( { 1, 2 } );		// { dg-error "initializer list" }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]