From patchwork Wed May 25 14:29:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 97353 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 135A5B6F97 for ; Thu, 26 May 2011 00:29:30 +1000 (EST) Received: (qmail 15527 invoked by alias); 25 May 2011 14:29:29 -0000 Received: (qmail 15518 invoked by uid 22791); 25 May 2011 14:29:28 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 May 2011 14:29:13 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4PETDt7013848 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 May 2011 10:29:13 -0400 Received: from [127.0.0.1] (ovpn-113-23.phx2.redhat.com [10.3.113.23]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4PETCBi015192 for ; Wed, 25 May 2011 10:29:12 -0400 Message-ID: <4DDD1238.7000107@redhat.com> Date: Wed, 25 May 2011 10:29:12 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/45418 (list-initialization of member array) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. commit ca84b75b33c26be3e9cf2894f4c8b08e3a5cac73 Author: Jason Merrill 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 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}; +}