re PR c++/81055 (ICE with invalid initializer for array new)
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 10 Jan 2018 16:37:22 +0000 (16:37 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 10 Jan 2018 16:37:22 +0000 (16:37 +0000)
/cp
2018-01-10  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/81055
* init.c (build_vec_init): Avoid building an INIT_EXPR with
error_mark_node as second argument.

/testsuite
2018-01-10  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/81055
* g++.dg/cpp0x/new2.C: New.

From-SVN: r256438

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

index 54860dc278eaea0d60499fcc103748a81d2c49af..9b6f46265866bbb1e7cf6a8e9a88bab46d2748fa 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-10  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/81055
+       * init.c (build_vec_init): Avoid building an INIT_EXPR with
+       error_mark_node as second argument.
+
 2018-01-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/83734
index 6c820e5689e4d8406580472633730e859d2c2f03..1be7c67d867d7224173d6dc026b62bc471aa4848 100644 (file)
@@ -4399,7 +4399,9 @@ build_vec_init (tree base, tree maxindex, tree init,
              if (TREE_CODE (init) == TREE_LIST)
                init = build_x_compound_expr_from_list (init, ELK_INIT,
                                                        complain);
-             elt_init = build2 (INIT_EXPR, type, to, init);
+             elt_init = (init == error_mark_node
+                         ? error_mark_node
+                         : build2 (INIT_EXPR, type, to, init));
            }
        }
 
index a46a5ee6722e57d128dc2bf14fbb262697f55c0e..dca24d8f28b1a314b4b5d673fd73db4650599d1a 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-10  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/81055
+       * g++.dg/cpp0x/new2.C: New.
+
 2018-01-10  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/83735
diff --git a/gcc/testsuite/g++.dg/cpp0x/new2.C b/gcc/testsuite/g++.dg/cpp0x/new2.C
new file mode 100644 (file)
index 0000000..f0bbc80
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/81055
+// { dg-do compile { target c++11 } }
+
+int** p = new int*[1]{q};  // { dg-error "not declared" }