re PR c++/42061 ([c++0x] ICE with invalid initializer list for reference)
authorJakub Jelinek <jakub@redhat.com>
Tue, 17 Nov 2009 07:01:18 +0000 (08:01 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 17 Nov 2009 07:01:18 +0000 (08:01 +0100)
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.

From-SVN: r154238

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

index d1db746c7946c92912bd2a7c298be689a0fbf364..4f5f9b542489da3665e591570b9480ea548efac4 100644 (file)
@@ -1,5 +1,9 @@
 2009-11-17  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/42061
+       * call.c (reference_binding): Return NULL for initializer list with
+       error operand inside of it.
+
        PR c++/42059
        * typeck.c (cp_build_modify_expr): For initializer list call
        check_array_initializer to make sure lhs isn't a VLA.
index e4a6bca347fb6ab2d2fc9371054975bf3837dc6b..e051e907220e45f2ec78e5c25cf59eefe7571650 100644 (file)
@@ -1235,6 +1235,8 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
          && CONSTRUCTOR_NELTS (expr) == 1)
        {
          expr = CONSTRUCTOR_ELT (expr, 0)->value;
+         if (error_operand_p (expr))
+           return NULL;
          from = TREE_TYPE (expr);
        }
     }
index 325bcf9b53b5e6ba17ab924cd1a23c7b7d1795b9..f73a427fa096f37598226517717273670153af7e 100644 (file)
@@ -1,5 +1,8 @@
 2009-11-17  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/42061
+       * g++.dg/cpp0x/initlist27.C: New test.
+
        PR c++/42059
        * g++.dg/cpp0x/initlist26.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist27.C b/gcc/testsuite/g++.dg/cpp0x/initlist27.C
new file mode 100644 (file)
index 0000000..f8536d3
--- /dev/null
@@ -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" }