From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D80263858D32 for ; Sun, 22 Jan 2023 20:50:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D80263858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674420650; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=1TkeGqhewo1xQQkY16Py27E0TJCzPFyoMFLSG0DPvbU=; b=L0KA1G9dlXSLzfhT2ct0TIOrdD0b9GBRaUAdT525HFBxSlbbOzm/zLEbKqmhIDh7BSUuDc 6F7ZBhtH10PYfDuhEKgDJUOheaA5rqW9L6P1YpQFW1A3RK8EhE2yYeApUrBbfFnUaoq+48 YosrVetJhYuTR/6dPXJBgbjxfNnkoYg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-_vr0qsOROECDftXeDtRnZQ-1; Sun, 22 Jan 2023 15:50:49 -0500 X-MC-Unique: _vr0qsOROECDftXeDtRnZQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF30A1C0432A for ; Sun, 22 Jan 2023 20:50:48 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7943400D795; Sun, 22 Jan 2023 20:50:48 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30MKojNG1535078 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 22 Jan 2023 21:50:46 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30MKoj7S1535077; Sun, 22 Jan 2023 21:50:45 +0100 Date: Sun, 22 Jan 2023 21:50:45 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++: Handle structured bindings like anon unions in initializers [PR108474] Message-ID: Reply-To: Jakub Jelinek References: <799bfe17-b60d-7353-d676-5296e64b3769@redhat.com> MIME-Version: 1.0 In-Reply-To: <799bfe17-b60d-7353-d676-5296e64b3769@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, Jan 22, 2023 at 03:40:26PM -0500, Jason Merrill wrote: > > 2023-01-21 Jakub Jelinek > > > > PR c++/108474 > > * cp-gimplify.cc (cp_fold_r): Handle structured bindings > > vars like anon union artificial vars. > > > > * g++.dg/cpp1z/decomp57.C: New test. > > * g++.dg/cpp1z/decomp58.C: New test. > > > > --- gcc/cp/cp-gimplify.cc.jj 2023-01-19 23:27:27.998400866 +0100 > > +++ gcc/cp/cp-gimplify.cc 2023-01-20 11:00:06.093446737 +0100 > > @@ -1012,8 +1012,12 @@ cp_fold_r (tree *stmt_p, int *walk_subtr > > case VAR_DECL: > > /* In initializers replace anon union artificial VAR_DECLs > > - with their DECL_VALUE_EXPRs, as nothing will do it later. */ > > - if (DECL_ANON_UNION_VAR_P (stmt) && !data->genericize) > > + with their DECL_VALUE_EXPRs, as nothing will do it later. > > + Ditto for structured bindings. */ > > + if (!data->genericize > > + && DECL_HAS_VALUE_EXPR_P (stmt) > > + && (DECL_ANON_UNION_VAR_P (stmt) > > + || (DECL_DECOMPOSITION_P (stmt) && DECL_DECOMP_BASE (stmt)))) > > Is there a reason not to do this for all cases of DECL_HAS_VALUE_EXPR_P, > without the extra checks? I was just trying to be careful, because unfortunately this spot doesn't mean it really is only expanded in static var DECL_INITIAL, it can make it into dynamic initializers, and most of DECL_VALUE_EXPRs appear only in runtime code, otherwise we'd have much more of these issues. But if you think it is ok, I'll test tonight a version just with if (!data->genericize && DECL_HAS_VALUE_EXPR_P (stmt) Jakub