aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2002-09-01 03:46:38 -0400
committerJason Merrill <jason@gcc.gnu.org>2002-09-01 03:46:38 -0400
commitd99f015cc5daf02fe8949375026721cb5760f06a (patch)
tree5c0d0910aad95f6cf29f373f24156cc73a7b6e69 /gcc
parentad5aa77eec9d1fa562b7f16a139ec9564ec7e330 (diff)
downloadgcc-d99f015cc5daf02fe8949375026721cb5760f06a.zip
gcc-d99f015cc5daf02fe8949375026721cb5760f06a.tar.gz
gcc-d99f015cc5daf02fe8949375026721cb5760f06a.tar.bz2
cp-lang.c (cp_expr_size): Allow initialization from a CONSTRUCTOR.
* cp-lang.c (cp_expr_size): Allow initialization from a CONSTRUCTOR. From-SVN: r56720
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/cp-lang.c4
-rw-r--r--gcc/testsuite/g++.dg/init/aggr1.C19
3 files changed, 27 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ba4fdbc..5a4ce97 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index f2689b5..3f771a9 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -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
index 0000000..c63f0b0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/aggr1.C
@@ -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() };
+}