From: Mark Mitchell Date: Wed, 9 Mar 2005 07:39:25 +0000 (+0000) Subject: re PR c++/20142 (implicit assignment operator with multi-dimensional array is broken) X-Git-Tag: releases/gcc-3.4.4~166 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7487ff56c1897c70f0e2eb37736c73ac04c1a7ea;p=thirdparty%2Fgcc.git re PR c++/20142 (implicit assignment operator with multi-dimensional array is broken) PR c++/20142 * init.c (build_vec_init): When determining whether or not the element type has an asignment operator, look through all array dimensions. PR c++/20142 * g++.dg/init/array18.C: New test. From-SVN: r96175 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2d30c545ee7e..61e216c57354 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2005-03-08 Mark Mitchell + + PR c++/20142 + * init.c (build_vec_init): When determining whether or not the + element type has an asignment operator, look through all array + dimensions. + 2005-03-06 Kriang Lerdsuwanakij PR c++/19311 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 5659f0f1617a..6189f469a7de 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2542,6 +2542,9 @@ build_vec_init (tree base, tree maxindex, tree init, int from_array) tree atype = TREE_TYPE (base); /* The type of an element in the array. */ tree type = TREE_TYPE (atype); + /* The element type reached after removing all outer array + types. */ + tree inner_elt_type; /* The type of a pointer to an element in the array. */ tree ptype; tree stmt_expr; @@ -2558,15 +2561,17 @@ build_vec_init (tree base, tree maxindex, tree init, int from_array) if (maxindex == NULL_TREE || maxindex == error_mark_node) return error_mark_node; + inner_elt_type = strip_array_types (atype); if (init && (from_array == 2 - ? (!CLASS_TYPE_P (type) || !TYPE_HAS_COMPLEX_ASSIGN_REF (type)) + ? (!CLASS_TYPE_P (inner_elt_type) + || !TYPE_HAS_COMPLEX_ASSIGN_REF (inner_elt_type)) : !TYPE_NEEDS_CONSTRUCTING (type)) && ((TREE_CODE (init) == CONSTRUCTOR /* Don't do this if the CONSTRUCTOR might contain something that might throw and require us to clean up. */ && (CONSTRUCTOR_ELTS (init) == NULL_TREE - || ! TYPE_HAS_NONTRIVIAL_DESTRUCTOR (target_type (type)))) + || ! TYPE_HAS_NONTRIVIAL_DESTRUCTOR (inner_elt_type))) || from_array)) { /* Do non-default initialization of POD arrays resulting from diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e583559c55d2..568120334525 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-03-08 Mark Mitchell + + PR c++/20142 + * g++.dg/init/array18.C: New test. + 2005-03-06 Kriang Lerdsuwanakij PR c++/19311