diff options
| -rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
| -rw-r--r-- | gcc/cp/cp-lang.c | 4 | ||||
| -rw-r--r-- | gcc/testsuite/g++.dg/init/aggr1.C | 19 |
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() }; +} |
