From patchwork Thu Feb 4 19:56:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 579092 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D51A2140322 for ; Fri, 5 Feb 2016 06:56:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=OVxlihWu; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=iWVWhB9K4H+hlgFwGz6v7TsUzQBhk JqnFm7oEOnXu6qYflNlBeYzc2XmY5ZIclSbYPcgw6NTMdU+8bSpisuqxjl2D/8E+ oOfSooZW6GA9Dosn04P2bh8SVWG+RXXgrhiNYMOoDH6MoS0EBMRDFw2cvRXhEWFg pvc81fOWxYdvC0= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=+Zb2MUM1hb+YzqoWk+zFXeAVW4w=; b=OVx lihWud8G9xg5YglqgoOL43SgC39nPfybIpHNua2oWbQE5qBkkLTno3d3mVgRCTmM T7bqCGeDY9ng5BNUQJI2Vkm5GYArosVHU1QxoLQg7nHYc/zsCosc4D0Eg88RnWf+ lW5+mHnNJIrZz3WDbpAS0ivDEYARCZztm00fObTc= Received: (qmail 64487 invoked by alias); 4 Feb 2016 19:56:37 -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 64477 invoked by uid 89); 4 Feb 2016 19:56:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=HTo:D*oracle.com X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 04 Feb 2016 19:56:35 +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 (Postfix) with ESMTPS id 716AE7732D; Thu, 4 Feb 2016 19:56:34 +0000 (UTC) Received: from tucnak.zalov.cz ([10.3.113.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u14JuWhE010281 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 4 Feb 2016 14:56:33 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u14JuPKL014272; Thu, 4 Feb 2016 20:56:31 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u14JuOhi014271; Thu, 4 Feb 2016 20:56:24 +0100 Date: Thu, 4 Feb 2016 20:56:24 +0100 From: Jakub Jelinek To: Jason Merrill , Paolo Carlini Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix regression due to reshape_init being called multiple times (PR c++/69658) Message-ID: <20160204195623.GR3017@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi! As mentioned in the PR, it seems reshape_init isn't prepared to be called on the result of earlier reshape_init call, but since the recent Paolo's changes expand_default_init can call it the second time. The following patch attempts to narrow it down to the case where it has not been called yet, and not call it when it is called indirectly from check_initializer that has already called reshape_init. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-02-04 Jakub Jelinek PR c++/69658 * init.c (expand_default_init): Only call reshape_init in the direct-initialization from an initializer list case. * g++.dg/init/pr69658.C: New test. Jakub --- gcc/cp/init.c.jj 2016-01-29 12:12:46.000000000 +0100 +++ gcc/cp/init.c 2016-02-04 18:53:26.865318337 +0100 @@ -1636,16 +1636,17 @@ expand_default_init (tree binfo, tree tr gcc_checking_assert ((flags & LOOKUP_ONLYCONVERTING) == 0 && TREE_CHAIN (init) == NULL_TREE); init = TREE_VALUE (init); + /* Only call reshape_init if it has not been called earlier + by the callers. */ + if (BRACE_ENCLOSED_INITIALIZER_P (init) && CP_AGGREGATE_TYPE_P (type)) + init = reshape_init (type, init, complain); } if (init && BRACE_ENCLOSED_INITIALIZER_P (init) && CP_AGGREGATE_TYPE_P (type)) /* A brace-enclosed initializer for an aggregate. In C++0x this can happen for direct-initialization, too. */ - { - init = reshape_init (type, init, complain); - init = digest_init (type, init, complain); - } + init = digest_init (type, init, complain); /* A CONSTRUCTOR of the target's type is a previously digested initializer, whether that happened just above or in --- gcc/testsuite/g++.dg/init/pr69658.C.jj 2016-02-04 18:55:46.862390961 +0100 +++ gcc/testsuite/g++.dg/init/pr69658.C 2016-02-04 18:54:58.000000000 +0100 @@ -0,0 +1,6 @@ +// PR c++/69658 +// { dg-do compile } + +struct S { S (int); }; +struct T { char n[6]; S s; }; +T t[1] = { { "foo", 1 } }; // { dg-bogus "C99 designator" }