From 143aa5cc4ae329f6f0720d091569c71e1fc8db73 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 10 Jan 2018 16:37:22 +0000 Subject: [PATCH] re PR c++/81055 (ICE with invalid initializer for array new) /cp 2018-01-10 Paolo Carlini 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 PR c++/81055 * g++.dg/cpp0x/new2.C: New. From-SVN: r256438 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/init.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/new2.C | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/new2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 54860dc278e..9b6f4626586 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-01-10 Paolo Carlini + + 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 PR c++/83734 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 6c820e5689e..1be7c67d867 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -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)); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a46a5ee6722..dca24d8f28b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-10 Paolo Carlini + + PR c++/81055 + * g++.dg/cpp0x/new2.C: New. + 2018-01-10 H.J. Lu 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 index 00000000000..f0bbc8092cd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/new2.C @@ -0,0 +1,4 @@ +// PR c++/81055 +// { dg-do compile { target c++11 } } + +int** p = new int*[1]{q}; // { dg-error "not declared" } -- 2.30.2