re PR c++/58636 (ICE with initializer_list and rvalue references)
authorJason Merrill <jason@redhat.com>
Mon, 14 Jul 2014 05:25:13 +0000 (01:25 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 14 Jul 2014 05:25:13 +0000 (01:25 -0400)
PR c++/58636
* call.c (build_list_conv): Don't try to build a list of references.

From-SVN: r212503

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/initlist-array4.C [new file with mode: 0644]

index e873d992cef7e872040f8e06edd69075638d84f1..bdad6d90ddfcaa2715d8b3543f81f25311b80e5b 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/58636
+       * call.c (build_list_conv): Don't try to build a list of references.
+
 2014-07-13  Edward Smith-Rowland  <3dw4rd@verizon.net>
 
        PR C++/60209 - Declaration of user-defined literal operator cause error
index 4ca6be5bd00872fdfb4cf4482dd8caf1fe5c7a77..b16c6e421674090c8bd7b7c50aee30032748aa82 100644 (file)
@@ -806,6 +806,12 @@ build_list_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
   /* But no narrowing conversions.  */
   flags |= LOOKUP_NO_NARROWING;
 
+  /* Can't make an array of these types.  */
+  if (TREE_CODE (elttype) == REFERENCE_TYPE
+      || TREE_CODE (elttype) == FUNCTION_TYPE
+      || VOID_TYPE_P (elttype))
+    return NULL;
+
   FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), i, val)
     {
       conversion *sub
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array4.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array4.C
new file mode 100644 (file)
index 0000000..af2045d
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/58636
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+// { dg-error "pointer to reference" "" { target *-*-* } 0 }
+int foo(std::initializer_list<int&&>);
+
+int i = foo({ 0 });            // { dg-error "std::initializer_list" }