diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2018-03-10 06:30:25 -0300 |
---|---|---|
committer | Alexandre Oliva <aoliva@redhat.com> | 2018-03-10 07:32:37 -0300 |
commit | b725303da4cbcd57eb62d9c8bdc1817d666ede8a (patch) | |
tree | 388bacdf6e9506669370cee3a5c57c84a0b89d3c /gcc/cp/init.c | |
parent | 54b21b6b6c25f8fd81efc7b5b1dbd8e1a2dde120 (diff) | |
download | gcc-aoliva/testme.tar.gz |
[PR c++/84729] convert new init to array elt typeaoliva/testme
A parenthesized initializer is 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.
This patch fixes it: after turning the TREE_LIST initializer to a
compound_expr, we convert it to the base type.
for gcc/cp/ChangeLog
PR c++/84729
* init.c (build_vec_init): Convert tree list to base type.
for gcc/testsuite/ChangeLog
PR c++/84729
* g++.dg/pr84729.C: New.
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 15cee17c780..cb62f4886e6 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -4405,8 +4405,14 @@ build_vec_init (tree base, tree maxindex, tree init, else { if (TREE_CODE (init) == TREE_LIST) - init = build_x_compound_expr_from_list (init, ELK_INIT, - complain); + { + init = build_x_compound_expr_from_list (init, ELK_INIT, + complain); + init + = convert_for_initialization (NULL_TREE, type, init, + LOOKUP_IMPLICIT, ICR_INIT, + NULL_TREE, 0, complain); + } elt_init = (init == error_mark_node ? error_mark_node : build2 (INIT_EXPR, type, to, init)); |