From patchwork Tue Mar 20 19:17:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 147826 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 8D759B6EF3 for ; Wed, 21 Mar 2012 06:17:57 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1332875877; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=55pKzZ9 BWndyhkTuYEFkhSdicko=; b=MonAU/3lk1WOehD7kZmgFBqpIb4d2JHC+sF8pc/ gRdiwrmJa1naNQaAfrWGO+/nGgZ5ooE3jx/nny9krHJB1i+seVv5de1oWAkEmH6w xhTxNTRI3JvGenRFFQD1w3UxQ2qbAOBL78aJT/fx11RJlrGdfwuLt4fx64HIKvwe w/h0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=VGzycw5p7Yh3zSg8OSOtmFg4RxQPKih88lEtHAbI1zjxYwx8diaPjtMfyksjpG poMoW1iC7cA5XXBNYKRSy8rFe2PbIlGcIzEAHYUclCsIv/Ma9FibVW0lgQBn4hSC BZSMNZ6cU7bnQeWQHt7QF3pymy4nZcdmy4K2qwin9Ums8=; Received: (qmail 30599 invoked by alias); 20 Mar 2012 19:17:54 -0000 Received: (qmail 30591 invoked by uid 22791); 20 Mar 2012 19:17:53 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_RW, 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; Tue, 20 Mar 2012 19:17:40 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2KJHe02008012 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Mar 2012 15:17:40 -0400 Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2KJHeGt012930 for ; Tue, 20 Mar 2012 15:17:40 -0400 Message-ID: <4F68D7D3.4040709@redhat.com> Date: Tue, 20 Mar 2012 15:17:39 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/52510 (rejects-valid with list-initialization of pthread_cond) 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 My change for core issue 1270 to allow brace elision in all list-initialization resulted in multiple calls to reshape_init for the same CONSTRUCTOR, which we weren't handling properly. Tested x86_64-pc-linux-gnu, applying to trunk. commit d7b5c07030b11599b846342b19ff50306043965f Author: Jason Merrill Date: Mon Mar 19 16:57:48 2012 -0400 PR c++/52510 * decl.c (reshape_init_class): Handle repeated reshaping. * search.c (lookup_field_1): Add sanity check. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index a18b312..2b2a551 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5110,7 +5110,11 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p, return error_mark_node; } - field = lookup_field_1 (type, d->cur->index, /*want_type=*/false); + if (TREE_CODE (d->cur->index) == FIELD_DECL) + /* We already reshaped this. */ + gcc_assert (d->cur->index == field); + else + field = lookup_field_1 (type, d->cur->index, /*want_type=*/false); if (!field || TREE_CODE (field) != FIELD_DECL) { diff --git a/gcc/cp/search.c b/gcc/cp/search.c index a1f8a3d..bd1bc57 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -384,6 +384,8 @@ lookup_field_1 (tree type, tree name, bool want_type) { tree field; + gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE); + if (TREE_CODE (type) == TEMPLATE_TYPE_PARM || TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM || TREE_CODE (type) == TYPENAME_TYPE) diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist66.C b/gcc/testsuite/g++.dg/cpp0x/initlist66.C new file mode 100644 index 0000000..4fc162e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist66.C @@ -0,0 +1,29 @@ +// PR c++/52510 +// { dg-do compile { target c++11 } } + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef uint64_t upad64_t; + +typedef struct _pthread_cond { + struct { + uint8_t __pthread_cond_flag[4]; + uint16_t __pthread_cond_type; + uint16_t __pthread_cond_magic; + } __pthread_cond_flags; + upad64_t __pthread_cond_data; +} pthread_cond_t; + +class gtm_rwlock +{ + pthread_cond_t c_readers; + public: + gtm_rwlock(); +}; + +gtm_rwlock::gtm_rwlock() + : c_readers ({{{0, 0, 0, 0}, 0, 0x4356}, 0}) +{ } +