From d99f015cc5daf02fe8949375026721cb5760f06a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 1 Sep 2002 03:46:38 -0400 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/cp-lang.c | 4 +++- gcc/testsuite/g++.dg/init/aggr1.C | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/init/aggr1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ba4fdbcbf06..5a4ce9762e5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2002-08-31 Jason Merrill + + * cp-lang.c (cp_expr_size): Allow initialization from a + CONSTRUCTOR. + 2002-08-30 Richard Henderson PR opt/7515 diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index f2689b5da97..3f771a9ccfd 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 00000000000..c63f0b02c65 --- /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() }; +} -- 2.30.2