init.c (expand_default_init): Handle brace-enclosed initializers correctly.
authorMark Mitchell <mark@codesourcery.com>
Thu, 17 Oct 2002 07:40:35 +0000 (07:40 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 17 Oct 2002 07:40:35 +0000 (07:40 +0000)
* init.c (expand_default_init): Handle brace-enclosed initializers
correctly.

* g++.dg/init/array8.C: New test.

From-SVN: r58245

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/array8.C [new file with mode: 0644]

index ce7f82939d8cb8fc15cd77b2a12b4fc94218408f..3234883303225d40f1d0ec11d762dc9dffa16cc4 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-17  Mark Mitchell  <mark@codesourcery.com>
+
+       * init.c (expand_default_init): Handle brace-enclosed initializers
+       correctly.
+
 2002-10-16  Mark Mitchell  <mark@codesourcery.com>
 
        * mangle.c (write_expression): Correct handling of enumeration
index 3e71e9f1a860029611dd1c12a712d08883f4b558..a7db626785350aaa43e174da77a596a2fc72333c 100644 (file)
@@ -1181,17 +1181,12 @@ expand_default_init (binfo, true_exp, exp, init, flags)
           to run a new constructor; and catching an exception, where we
           have already built up the constructor call so we could wrap it
           in an exception region.  */;
-      else if (TREE_CODE (init) == CONSTRUCTOR)
+      else if (TREE_CODE (init) == CONSTRUCTOR 
+              && TREE_HAS_CONSTRUCTOR (init))
        {
-         if (!TYPE_HAS_CONSTRUCTOR (type))
-           /* A brace-enclosed initializer has whatever type is
-              required.  There's no need to convert it.  */
-           ;
-         else
-           init = ocp_convert (type, 
-                               TREE_VALUE (CONSTRUCTOR_ELTS (init)),
-                               CONV_IMPLICIT | CONV_FORCE_TEMP, 
-                               flags);
+         /* A brace-enclosed initializer for an aggregate.  */
+         my_friendly_assert (CP_AGGREGATE_TYPE_P (type), 20021016);
+         init = digest_init (type, init, (tree *)NULL);
        }
       else
        init = ocp_convert (type, init, CONV_IMPLICIT|CONV_FORCE_TEMP, flags);
index d8ebf360424e1981379934d23f575b9bea326a74..75bf1695f8395291c34776353ebccdbc0c9251a4 100644 (file)
@@ -1,3 +1,7 @@
+2002-10-17  Mark Mitchell  <mark@codesourcery.com>
+
+       * g++.dg/init/array8.C: New test.
+
 2002-10-17  Richard Sandiford  <rsandifo@redhat.com>
 
        * gcc.dg/special/mips-abi.exp: New test.
diff --git a/gcc/testsuite/g++.dg/init/array8.C b/gcc/testsuite/g++.dg/init/array8.C
new file mode 100644 (file)
index 0000000..5f28ca4
--- /dev/null
@@ -0,0 +1,12 @@
+struct A {
+  A ();
+};
+
+struct B {
+  A a1;
+  A a2;
+};
+
+A a;
+
+struct B b[] = { { a, a }, { a, a } };