From patchwork Sat Nov 23 16:27:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 293664 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 54D3E2C008A for ; Sun, 24 Nov 2013 03:27:37 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=QIV8vE19K6do4BfViMre4G4fGOIutHM5y1IgqrJL871E7A CSA0fc/ZwR/TfDHcYwW3y97nhNPRpdjP3vgyNBqpfFr395nzfScuE93H07G4H7ty 0FZIB1enBLFFq1GVdWMl3iu9VSGA5S11/wMc4ElssjYwMtcLKDu7zbH55z8Ac= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=UClrQSSdL8VNLjXFgSYBdnGyA+c=; b=EZIhP+JCz3XWG51lSkH7 hjuu86xXr+woJlVkmXeTp+WXx20jYH9/1E8wWFbFpicKl6Bc5zklP9QcJPbQx2+m XU/P3mME9AhBXLJ7CYaIQct+S1ngIifZbrrl1Np33MjpniIl+huZGkpxljFIAHAt U0hha97slOhcX+7zw18EI6o= Received: (qmail 27445 invoked by alias); 23 Nov 2013 16:27:24 -0000 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 Received: (qmail 27424 invoked by uid 89); 23 Nov 2013 16:27:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 23 Nov 2013 16:27:21 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rANGRExi019283 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 23 Nov 2013 11:27:14 -0500 Received: from [10.10.116.21] ([10.10.116.21]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rANGRDBc016472 for ; Sat, 23 Nov 2013 11:27:13 -0500 Message-ID: <5290D761.3080505@redhat.com> Date: Sat, 23 Nov 2013 11:27:13 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH #2 for c++/58868 The earlier patch fixed the testcase, but it seemed to me that build_aggr_init still ought to do the right thing here. Tested x86_64-pc-linux-gnu, applying to trunk. commit cfde6c1e56ecbbd098de20451cc718cedeb8dffd Author: Jason Merrill Date: Wed Nov 6 09:33:24 2013 -0500 PR c++/58868 * init.c (build_aggr_init): Don't clobber the type of init if we got an INIT_EXPR back from build_vec_init. (build_vec_init): Do digest_init on trivial initialization. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index fd43a4f..d7b0643 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1508,7 +1508,8 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) TREE_READONLY (exp) = was_const; TREE_THIS_VOLATILE (exp) = was_volatile; TREE_TYPE (exp) = type; - if (init) + /* Restore the type of init unless it was used directly. */ + if (init && TREE_CODE (stmt_expr) != INIT_EXPR) TREE_TYPE (init) = itype; return stmt_expr; } @@ -3421,6 +3422,8 @@ build_vec_init (tree base, tree maxindex, tree init, brace-enclosed initializers. In this case, digest_init and store_constructor will handle the semantics for us. */ + if (BRACE_ENCLOSED_INITIALIZER_P (init)) + init = digest_init (atype, init, complain); stmt_expr = build2 (INIT_EXPR, atype, base, init); if (length_check) stmt_expr = build3 (COND_EXPR, atype, length_check,