re PR c++/45418 ([C++0x] can't initialize array of non-trivial type with brace-init)
authorJason Merrill <jason@redhat.com>
Wed, 25 May 2011 14:35:09 +0000 (10:35 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 25 May 2011 14:35:09 +0000 (10:35 -0400)
PR c++/45418
* init.c (perform_member_init): Handle list-initialization
of array of non-trivial class type.

From-SVN: r174204

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

index 5bc1748d32db6c2dae6168afea93e407c24d0d52..3de0639bd60884e2ea9880bed6e9a488c0b8d620 100644 (file)
@@ -1,5 +1,9 @@
 2011-05-25  Jason Merrill  <jason@redhat.com>
 
+       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.
index 5f30275ae5bb6d944069b43ff1f77fc072ec778a..6336dd7b03f5b1cbca6a95b0f3ef1150fcb304ff 100644 (file)
@@ -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,
index 5d01971c3037abd71b64c7d6dabc7ff2adc9a84d..e6327e0bad326a2ef6678897e33a3e45ab1f84b5 100644 (file)
@@ -1,5 +1,7 @@
 2011-05-25  Jason Merrill  <jason@redhat.com>
 
+       * 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 (file)
index 0000000..ef4e72c
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/45418
+// { dg-options -std=c++0x }
+
+struct A1 { };
+struct A2 {
+  A2();
+};
+
+template <class T> struct B {
+  T ar[1];
+  B(T t):ar({t}) {}
+};
+
+int main(){
+  B<int> bi{1};
+  A1 a1;
+  B<A1> ba1{a1};
+  A2 a2;
+  A2 a2r[1]{{a2}};
+  B<A2> ba2{a2};
+}