]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cp-lang.c (cp_expr_size): Allow initialization from a CONSTRUCTOR.
authorJason Merrill <jason@redhat.com>
Sun, 1 Sep 2002 07:46:38 +0000 (03:46 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 1 Sep 2002 07:46:38 +0000 (03:46 -0400)
        * cp-lang.c (cp_expr_size): Allow initialization from a
        CONSTRUCTOR.

From-SVN: r56720

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

index ba4fdbcbf0644f320db594f3e47a71d7497a9dc8..5a4ce9762e50a923228bdc8f3e8bf241e47564a0 100644 (file)
@@ -1,3 +1,8 @@
+2002-08-31  Jason Merrill  <jason@redhat.com>
+
+       * cp-lang.c (cp_expr_size): Allow initialization from a
+       CONSTRUCTOR.
+
 2002-08-30  Richard Henderson  <rth@redhat.com>
 
        PR opt/7515
index f2689b5da97e7c6c555e7b9e533c900a519c48a6..3f771a9ccfd606df44c3caeadbfa637c92184b26 100644 (file)
@@ -298,7 +298,9 @@ cp_expr_size (exp)
         of a type with both of these set; all copies of such types must go
         through a constructor or assignment op.  */
       if (TYPE_HAS_COMPLEX_INIT_REF (TREE_TYPE (exp))
-         && TYPE_HAS_COMPLEX_ASSIGN_REF (TREE_TYPE (exp)))
+         && TYPE_HAS_COMPLEX_ASSIGN_REF (TREE_TYPE (exp))
+         /* But storing a CONSTRUCTOR isn't a copy.  */
+         && TREE_CODE (exp) != CONSTRUCTOR)
        abort ();
       /* This would be wrong for a type with virtual bases, but they are
         caught by the abort above.  */
diff --git a/gcc/testsuite/g++.dg/init/aggr1.C b/gcc/testsuite/g++.dg/init/aggr1.C
new file mode 100644 (file)
index 0000000..c63f0b0
--- /dev/null
@@ -0,0 +1,19 @@
+// Test that initializing an aggregate with complex copy constructor
+// and assignment ops doesn't cause cp_expr_size to abort.
+
+struct A
+{
+  A();
+  A(const A&);
+  A& operator=(const A&);
+};
+
+struct B
+{
+  A a;
+};
+
+int main ()
+{
+  B b = { A() };
+}