From 3ec16e36107214035fe9d1177e0acc6ebe037112 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Fri, 23 Mar 2018 01:19:01 +0000 Subject: [PATCH] [PR c++/84729] reject parenthesized array init A parenthesized initializer was only accepted when new()ing an array in permissive mode. We were not careful, however, to convert the TREE_LIST initializer to the array element type in this extension. Instead of fixing it, converting the initializer to the base type after turning the TREE_LIST initializer to a compound_expr, we disable this deprecated extension. for gcc/cp/ChangeLog PR c++/84729 * init.c (build_vec_init): Error at parenthesized array init. for gcc/testsuite/ChangeLog PR c++/84729 * g++.dg/pr84729.C: New. * g++.old-deja/g++.ext/arrnew2.C: Require error. * g++.old-deja/g++.robertl/eb58.C: Likewise. * g++.old-deja/g++.robertl/eb63.C: Likewise. From-SVN: r258791 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/init.c | 7 ++----- gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/g++.dg/pr84729.C | 7 +++++++ gcc/testsuite/g++.old-deja/g++.ext/arrnew2.C | 4 ++-- gcc/testsuite/g++.old-deja/g++.robertl/eb58.C | 4 ++-- gcc/testsuite/g++.old-deja/g++.robertl/eb63.C | 4 ++-- 7 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr84729.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5dae29d23a1..33add697a86 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2018-03-22 Alexandre Oliva + PR c++/84729 + * init.c (build_vec_init): Error at parenthesized array init. + PR c++/84610 PR c++/84642 PR c++/84942 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 3215c238554..ff52c42c1ad 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3370,11 +3370,8 @@ build_new_1 (vec **placement, tree type, tree nelts, else if (*init) { if (complain & tf_error) - permerror (input_location, - "parenthesized initializer in array new"); - else - return error_mark_node; - vecinit = build_tree_list_vec (*init); + error ("parenthesized initializer in array new"); + return error_mark_node; } init_expr = build_vec_init (data_addr, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d4b8c275d55..07951d99ba9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2018-03-22 Alexandre Oliva + + PR c++/84729 + * g++.dg/pr84729.C: New. + * g++.old-deja/g++.ext/arrnew2.C: Require error. + * g++.old-deja/g++.robertl/eb58.C: Likewise. + * g++.old-deja/g++.robertl/eb63.C: Likewise. + 2018-03-22 Steven G. Kargl @@ -13,5 +13,5 @@ public: main() { A* a; - a = new A[2](1,false); + a = new A[2](1,false); // { dg-error "parenthesized" } } -- 2.30.2