From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126199 invoked by alias); 19 Dec 2018 14:36:34 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 125886 invoked by uid 89); 19 Dec 2018 14:36:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:a1f, sk:aoliva, somewhere X-HELO: mail-vk1-f176.google.com Received: from mail-vk1-f176.google.com (HELO mail-vk1-f176.google.com) (209.85.221.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Dec 2018 14:36:31 +0000 Received: by mail-vk1-f176.google.com with SMTP id y14so4536414vky.9 for ; Wed, 19 Dec 2018 06:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0gDWyp5tiq/FmebIJXvZZI/pR5gJ6Q5saTvY38vmr8M=; b=cKQ0FcfrrX3bTUXVhnEXLEn16IWJbwoQBtv8nJ4EqlBTsEZzZM8iWYxjvR+bdcc3U/ 9VgJ6JlmjHwhhZTjks3b/4S5ASxVS+/vSseQxSb5TvBR8sC6vuogUNXeT44p32cElQat lmnA+SBlCmm7PEpprZZQYec4JiB3ZsLqaibhQ= MIME-Version: 1.0 References: <81ac6c22-8907-a166-b8df-80e06d2850da@redhat.com> <12883fc9-4e44-e16d-fdc6-9a90c21bf01c@redhat.com> In-Reply-To: From: Christophe Lyon Date: Wed, 19 Dec 2018 14:36:00 -0000 Message-ID: Subject: Re: [C++ Patch] [PR c++/88146] do not crash synthesizing inherited ctor(...) To: Jason Merrill Cc: Alexandre Oliva , gcc-patches List Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg01391.txt.bz2 On Sat, 15 Dec 2018 at 23:11, Jason Merrill wrote: > > On Fri, Dec 14, 2018 at 6:05 PM Alexandre Oliva wrote: > > > > On Dec 14, 2018, Jason Merrill wrote: > > > > > Let's move the initialization of "fields" inside the 'then' block here > > > with the initialization of "cvquals", rather than clear it in the > > > 'else'. > > > > We'd still have to NULL-initialize it somewhere, so I'd rather just move > > the entire loop into the conditional, and narrow the scope of variables > > only used within the loop, like this. The full patch below is very hard > > to read because of the reindentation, so here's a diff -b. > > > > diff --git a/gcc/cp/method.c b/gcc/cp/method.c > > index fd023e200538..17404a65b0fd 100644 > > --- a/gcc/cp/method.c > > +++ b/gcc/cp/method.c > > @@ -675,12 +675,9 @@ do_build_copy_constructor (tree fndecl) > > } > > else > > { > > - tree fields = TYPE_FIELDS (current_class_type); > > tree member_init_list = NULL_TREE; > > - int cvquals = cp_type_quals (TREE_TYPE (parm)); > > int i; > > tree binfo, base_binfo; > > - tree init; > > vec *vbases; > > > > /* Initialize all the base-classes with the parameter converted > > @@ -704,15 +701,18 @@ do_build_copy_constructor (tree fndecl) > > inh, member_init_list); > > } > > > > - for (; fields; fields = DECL_CHAIN (fields)) > > + if (!inh) > > + { > > + int cvquals = cp_type_quals (TREE_TYPE (parm)); > > + > > + for (tree fields = TYPE_FIELDS (current_class_type); > > + fields; fields = DECL_CHAIN (fields)) > > { > > tree field = fields; > > tree expr_type; > > > > if (TREE_CODE (field) != FIELD_DECL) > > continue; > > - if (inh) > > - continue; > > > > expr_type = TREE_TYPE (field); > > if (DECL_NAME (field)) > > @@ -742,7 +742,7 @@ do_build_copy_constructor (tree fndecl) > > expr_type = cp_build_qualified_type (expr_type, quals); > > } > > > > - init = build3 (COMPONENT_REF, expr_type, parm, field, NULL_TREE); > > + tree init = build3 (COMPONENT_REF, expr_type, parm, field, NULL_TREE); > > if (move_p && !TYPE_REF_P (expr_type) > > /* 'move' breaks bit-fields, and has no effect for scalars. */ > > && !scalarish_type_p (expr_type)) > > @@ -751,6 +751,8 @@ do_build_copy_constructor (tree fndecl) > > > > member_init_list = tree_cons (field, init, member_init_list); > > } > > + } > > + > > finish_mem_initializers (member_init_list); > > } > > } > > @@ -891,6 +893,7 @@ synthesize_method (tree fndecl) > > > > /* Reset the source location, we might have been previously > > deferred, and thus have saved where we were first needed. */ > > + if (!DECL_INHERITED_CTOR (fndecl)) > > DECL_SOURCE_LOCATION (fndecl) > > = DECL_SOURCE_LOCATION (TYPE_NAME (DECL_CONTEXT (fndecl))); > > > > > > Is this OK too? (pending regstrapping) > > Yes, thanks. > Hi, The new test inh-ctor32.C fails on arm: FAIL: g++.dg/cpp0x/inh-ctor32.C -std=c++14 (test for warnings, line 208) FAIL: g++.dg/cpp0x/inh-ctor32.C -std=c++17 (test for warnings, line 208) The log has: /gcc/testsuite/g++.dg/cpp0x/inh-ctor32.C: In instantiation of 'constexpr derived_ctor::inherited_derived_ctor::constexpr_noninherited_ctor::bor::bor(T ...) [with T = {int, int}]': /gcc/testsuite/g++.dg/cpp0x/inh-ctor32.C:206:13: required from 'constexpr derived_ctor::inherited_derived_ctor::constexpr_noninherited_ctor::bar::bar(T ...) [with T = {int, int}][inherited from derived_ctor::inherited_derived_ctor::constexpr_noninherited_ctor::bor]' /gcc/testsuite/g++.dg/cpp0x/inh-ctor32.C:208:42: required from here Christophe > Jason