aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2005-03-09 07:28:10 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2005-03-09 07:28:10 +0000
commitb5af313312d166f0d94ae408f28db90486236496 (patch)
treeeae4d082b5125cdbc718dbc2af1ebb736c775972 /gcc/cp/init.c
parente140d617c5f1d880dec74f5036d3a5c1b374311d (diff)
downloadgcc-b5af313312d166f0d94ae408f28db90486236496.zip
gcc-b5af313312d166f0d94ae408f28db90486236496.tar.gz
gcc-b5af313312d166f0d94ae408f28db90486236496.tar.bz2
re PR c++/20142 (implicit assignment operator with multi-dimensional array is broken)
PR c++/20142 * cp-tree.h (target_type): Remove. * decl.c (layout_var_decl): Remove #if 0'd code. (cp_finish_decl): Remove dead code. * init.c (build_vec_init): When determining whether or not the element type has an asignment operator, look through all array dimensions. * typeck.c (target_type): Remove. PR c++/20142 * g++.dg/init/array18.C: New test. From-SVN: r96170
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index d572bca..c526bb1 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2388,6 +2388,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;
@@ -2403,15 +2406,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
@@ -2602,14 +2607,12 @@ build_vec_init (tree base, tree maxindex, tree init, int from_array)
/* Flatten multi-dimensional array since build_vec_delete only
expects one-dimensional array. */
if (TREE_CODE (type) == ARRAY_TYPE)
- {
- m = cp_build_binary_op (MULT_EXPR, m,
- array_type_nelts_total (type));
- type = strip_array_types (type);
- }
+ m = cp_build_binary_op (MULT_EXPR, m,
+ array_type_nelts_total (type));
finish_cleanup_try_block (try_block);
- e = build_vec_delete_1 (rval, m, type, sfk_base_destructor,
+ e = build_vec_delete_1 (rval, m,
+ inner_elt_type, sfk_base_destructor,
/*use_global_delete=*/0);
finish_cleanup (e, try_block);
}