public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/45418 (list-initialization of member array)
@ 2011-05-25 14:47 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2011-05-25 14:47 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 170 bytes --]

The code in perform_member_init for handling arrays of non-trivial 
classes needed a tweak to handle list-initialization.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 45418.patch --]
[-- Type: text/x-patch, Size: 1214 bytes --]

commit ca84b75b33c26be3e9cf2894f4c8b08e3a5cac73
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 25 00:45:38 2011 -0400

    	PR c++/45418
    	* init.c (perform_member_init): Handle list-initialization
    	of array of non-trivial class type.

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/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 <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};
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-25 14:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-25 14:47 C++ PATCH for c++/45418 (list-initialization of member array) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).