From f41349a3d41a8a882cd3119c3a094947369c8806 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 25 May 2011 10:35:09 -0400 Subject: re PR c++/45418 ([C++0x] can't initialize array of non-trivial type with brace-init) PR c++/45418 * init.c (perform_member_init): Handle list-initialization of array of non-trivial class type. From-SVN: r174204 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/init.c | 2 ++ gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/initlist50.C | 21 +++++++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist50.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5bc1748..3de0639 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-05-25 Jason Merrill + PR c++/45418 + * init.c (perform_member_init): Handle list-initialization + of array of non-trivial class type. + PR c++/45080 * pt.c (instantiate_class_template_1): Call maybe_add_lambda_conv_op. * semantics.c (lambda_function): Check COMPLETE_OR_OPEN_TYPE_P. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 5f30275..6336dd7 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -549,6 +549,8 @@ perform_member_init (tree member, tree init) { gcc_assert (TREE_CHAIN (init) == NULL_TREE); init = TREE_VALUE (init); + if (BRACE_ENCLOSED_INITIALIZER_P (init)) + init = digest_init (type, init, tf_warning_or_error); } if (init == NULL_TREE || same_type_ignoring_top_level_qualifiers_p (type, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5d01971..e6327e0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-05-25 Jason Merrill + * g++.dg/cpp0x/initlist50.C: New. + * g++.dg/cpp0x/lambda/lambda-conv5.C: New. * g++.dg/cpp0x/variadic109.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist50.C b/gcc/testsuite/g++.dg/cpp0x/initlist50.C new file mode 100644 index 0000000..ef4e72c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist50.C @@ -0,0 +1,21 @@ +// PR c++/45418 +// { dg-options -std=c++0x } + +struct A1 { }; +struct A2 { + A2(); +}; + +template struct B { + T ar[1]; + B(T t):ar({t}) {} +}; + +int main(){ + B bi{1}; + A1 a1; + B ba1{a1}; + A2 a2; + A2 a2r[1]{{a2}}; + B ba2{a2}; +} -- cgit v1.1