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 997693858D32 for ; Mon, 23 Jan 2023 00:19:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 997693858D32 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=1674433153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VgM8Q52AaavcgIF0VLDfBGOZqmMFRloWK95XUqxa5FY=; b=YA6zQfN7+aZvFlo2rrxceMXT023X3UaD59coo5jRxiNSFDoeQJ7WuoSrVTArEtmrwDKZhC iTGcloa5uNHWlkmI/yQn3bnp6J5Y9CdgIF+BRzNxpta1AInw1ckVP5jXooDdXlMP9/ZOux wSMrqEniUkvQ3/4jKV8x+uITMfK02LA= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-331-YH0UiLJpPHSo503Is-uEqw-1; Sun, 22 Jan 2023 19:19:11 -0500 X-MC-Unique: YH0UiLJpPHSo503Is-uEqw-1 Received: by mail-qt1-f199.google.com with SMTP id w2-20020ac84d02000000b003b63cd590dfso4036536qtv.14 for ; Sun, 22 Jan 2023 16:19:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VgM8Q52AaavcgIF0VLDfBGOZqmMFRloWK95XUqxa5FY=; b=eOCk37AuKIpiN7eGHZlAenciFGCMD0Gyc5YuJ0hxRdvZUQH/h+saPOLSmA9ntze9OU MKEE5GeYc0jP3n1XLzl1tOwrqpe+Lj+CWE3pCcTjnNNPJXnzs8f/AIzXhm7WFvFI7hEW ow5G4bQBa4miI/nDqHdJN3lh6OJPjgXstJEL+hq4WqrI8Hl51YPFmwl/qnvxtmuIHZXk 5xeKDKeRc7DgbQuPPxLRCWE88e83mI4T/WoZDCf4in7trpa1SqR+S++dCCAX4cXNIiPX t9SabICviJT6RmG1sUtrM+9UsipMNR9ehjMn+Gu7wKDdC98+cnMUipuQLSEgvNIXY3mA qx7g== X-Gm-Message-State: AFqh2koFBOJnq7xwUEnCbHHKJmaYOpV4L8f+NqfGbHlfRubZNSPx+hEy kVxj3dh7iZCjq2j/geMKAqFa8zrOFUUuYUQJprVfGVVpGkzlum6tJugDyMTe/R5tyoBjUVn9yGH Q4uzFee6l2gfAuhxEQQ== X-Received: by 2002:ac8:6ec2:0:b0:3af:ba3b:db80 with SMTP id f2-20020ac86ec2000000b003afba3bdb80mr31426575qtv.33.1674433150813; Sun, 22 Jan 2023 16:19:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXs61nvgk7agIbhId9JzyAv34Fxh0UznhJoSfVJhAX//cWTflAlXn6X+mwCL8c2Aj/2eQAji+Q== X-Received: by 2002:ac8:6ec2:0:b0:3af:ba3b:db80 with SMTP id f2-20020ac86ec2000000b003afba3bdb80mr31426558qtv.33.1674433150484; Sun, 22 Jan 2023 16:19:10 -0800 (PST) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id bj3-20020a05620a190300b00705975d0054sm30738382qkb.19.2023.01.22.16.19.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Jan 2023 16:19:09 -0800 (PST) Message-ID: <6f8e0faf-55eb-cf20-e796-a1828197bb23@redhat.com> Date: Sun, 22 Jan 2023 19:19:07 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] c++: Handle structured bindings like anon unions in initializers [PR108474] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <799bfe17-b60d-7353-d676-5296e64b3769@redhat.com> From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 1/22/23 15:50, Jakub Jelinek wrote: > 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 it shouldn't be harmful anywhere, right? > But if you think it is ok, I'll test tonight a version just with > if (!data->genericize && DECL_HAS_VALUE_EXPR_P (stmt) OK with that change. Though, actually, why not instead fix expand_expr_real_1 (and staticp) to look through DECL_VALUE_EXPR? Jason