]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/20142 (implicit assignment operator with multi-dimensional array is broken)
authorMark Mitchell <mark@codesourcery.com>
Wed, 9 Mar 2005 07:39:25 +0000 (07:39 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 9 Mar 2005 07:39:25 +0000 (07:39 +0000)
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

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog

index 2d30c545ee7ebd00bdf78dc284c6532981d82bbd..61e216c5735456d454ddb2a9bb48329a97f740c4 100644 (file)
@@ -1,3 +1,10 @@
+2005-03-08  Mark Mitchell  <mark@codesourcery.com>
+
+       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  <lerdsuwa@users.sourceforge.net>
 
        PR c++/19311
index 5659f0f1617a373da4c6e3a2b49777211264531d..6189f469a7dec1553f88f702259d73cd86d9718c 100644 (file)
@@ -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
index e583559c55d28611f0c71ab4d0b09b2c30553da1..56812033452511744853f0412f4db821d9af6847 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-08  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/20142
+       * g++.dg/init/array18.C: New test.
+       
 2005-03-06  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/19311