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.133.124]) by sourceware.org (Postfix) with ESMTPS id F1214385DDC6 for ; Tue, 25 Jun 2024 15:31:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F1214385DDC6 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F1214385DDC6 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719329474; cv=none; b=iJtHFbYryYIv9ZyRpcW5eqWxIqLHWFqi2a2QzKS3yQxCAbebYeAlyneErk5RZg8XoWspw83BifOvNv1iMPHSURLMmI+pJmCN+trgbgI4PuKSESy7Fpe9D81xmmdl7MnmzA6q85t9akGCwICxM5HkNXwPhg1iW0kn/SqWdnixbCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719329474; c=relaxed/simple; bh=uprJyjm+KlPaBAe0s6YwSpXS/maMopeEU6JjDC6UYtI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=a2wZMiD+CqOeiZieTFO8aVQM7r/EOIz6tzKXLg7GlhaUlXyJFihPRv5rOjeX0RT6xcyhmcgnQqIh3IGgxI2Fjv6ftkp5MU1MjgHhvQSoQEtZ8LA9WmltjWpEa+WaPxo01FDdDyjfXZl7mAdLgRR5Zo7wegS2jIKfMzeE+LW9oeI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719329470; 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=GCJjWuZvrjGEbNODrOIgTn+xaR92/eWOhp/e3nip+To=; b=CFrYnDMAqgt2dIxeZUFw9UjHvTKFwYmuZXzIO57O7ZZtL2bWpkMUybzuOXgu2ZRg5Kk+YN LVs9oMRMl/0e1+s16zmiKHJr35et07SxiTOBo5ynO8Dg07qI2LqyUMOdMPETmTsOkpC0Nc 9nYfbVYE0w3mZlvTYW7hncRprFW2GeE= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-332-rmWWlCpbP-eMh7DU5NuyNA-1; Tue, 25 Jun 2024 11:31:08 -0400 X-MC-Unique: rmWWlCpbP-eMh7DU5NuyNA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6b5176fa67eso97768266d6.2 for ; Tue, 25 Jun 2024 08:31:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719329468; x=1719934268; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GCJjWuZvrjGEbNODrOIgTn+xaR92/eWOhp/e3nip+To=; b=GVS5VXtF0Mp1GVn9utLMJ5dZbrr7HFvXSuD0TafZ4gUaAx5pRtIUgF+AUvTV6hemVU o1FVkvhRaf/BEnsvikqvI8a7SChBPwq+zTRK/bGlhqMLN8a6E4DZbx5YPmnGyHI8UGIE Mw7M4K/ojFy/alttCrkCpi14+/DBAzIAy2Bvacf4ytLzHP3MGRYH5fWr00syhiGSKQdz hEGPiCkQT9LL0cJhV1jn6I04S6yW3ebgSVhqNb4l5Djxy0GpQBYJ/jYAyvi6A/GN2eaO 4Vs5EY8jKqQbwiH/HtZNYS0YRNoYRqvPBySpemG/vv1PnLFp8XTG1JZL8jdD/gWcidh8 Jkbg== X-Gm-Message-State: AOJu0YxPJHxjjLHxHXQjoOrLD/yjDfEggl97HKZbeTAzmrAGD775tqkm qDoTQV53REIeGkkPAWh92nHA4jYUQOjX5iqc9OQDs2WffSCObeluGdd+lGfDfsFqU1dkrOwMTrp IHxE9jSuHLqR1n6Q+It8Cdb9D6tS0CN4AeDpTHNSqB8BzpaM8enuILMM= X-Received: by 2002:a05:6214:14f1:b0:6b0:7caa:457c with SMTP id 6a1803df08f44-6b5409ccf4emr65774286d6.24.1719329468100; Tue, 25 Jun 2024 08:31:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1Ja+5Sy0WSRLbTvKZcfvcBlGrbQmUHP85tLCMoYDo2vxOHiwYXfRtlrCr6B7mujYbFnTaKA== X-Received: by 2002:a05:6214:14f1:b0:6b0:7caa:457c with SMTP id 6a1803df08f44-6b5409ccf4emr65774096d6.24.1719329467725; Tue, 25 Jun 2024 08:31:07 -0700 (PDT) Received: from [192.168.1.130] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b51ef4a141sm44694986d6.105.2024.06.25.08.31.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jun 2024 08:31:06 -0700 (PDT) Message-ID: <135ed513-7642-476e-9e7c-1ba916ed3cc7@redhat.com> Date: Tue, 25 Jun 2024 11:31:05 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: decltype of by-ref capture proxy of ref [PR115504] To: Patrick Palka Cc: gcc-patches@gcc.gnu.org References: <20240625010015.122204-1-ppalka@redhat.com> <65a73f98-0be3-44c5-b703-e369da48f459@redhat.com> <7182593d-7f2b-b842-1262-b94ab6c7599d@idea> From: Jason Merrill In-Reply-To: <7182593d-7f2b-b842-1262-b94ab6c7599d@idea> 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=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 6/25/24 11:03, Patrick Palka wrote: > On Mon, 24 Jun 2024, Jason Merrill wrote: > >> On 6/24/24 21:00, Patrick Palka wrote: >>> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK >>> for trunk/14? >>> >>> -- >8 -- >>> >>> The capture proxy handling in finish_decltype_type added in r14-5330 >>> was stripping the reference type of a capture proxy's captured variable, >>> which is desirable for a by-value capture, but not for a by-ref capture >>> (of a reference). >> >> I'm not sure why we would want it for by-value, either; regardless of the >> capture kind, decltype(x) is int&. > > Ah, makes sense. But I guess that means > > void f(int& x) { > [x]() { > decltype(auto) a = x; > } > } > > is ill-formed since decltype(x) is int& but the corresponding closure > member is const? It works if we make the lambda mutable. Yes, and clang agrees. Let's also test that case. > Like so? Bootstrapped and regtested on x86_64-pc-linux-gnu. > > > -- >8 -- > > Subject: [PATCH] c++: decltype of capture proxy of ref [PR115504] > > The capture proxy handling in finish_decltype_type added in r14-5330 > was stripping the reference type of a capture proxy's captured variable. > > PR c++/115504 > > gcc/cp/ChangeLog: > > * semantics.cc (finish_decltype_type): Don't strip the reference > type (if any) of a capture proxy's captured variable. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp1y/decltype-auto8.C: New test. > --- > gcc/cp/semantics.cc | 1 - > gcc/testsuite/g++.dg/cpp1y/decltype-auto8.C | 18 ++++++++++++++++++ > 2 files changed, 18 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/cpp1y/decltype-auto8.C > > diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc > index 6c1813d37c6..6a383c0f7f9 100644 > --- a/gcc/cp/semantics.cc > +++ b/gcc/cp/semantics.cc > @@ -12071,7 +12071,6 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, > { > expr = DECL_CAPTURED_VARIABLE (expr); > type = TREE_TYPE (expr); > - type = non_reference (type); > } > else > { > diff --git a/gcc/testsuite/g++.dg/cpp1y/decltype-auto8.C b/gcc/testsuite/g++.dg/cpp1y/decltype-auto8.C > new file mode 100644 > index 00000000000..1100b94a5b7 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp1y/decltype-auto8.C > @@ -0,0 +1,18 @@ > +// PR c++/115504 > +// { dg-do compile { target c++14 } } > + > +void f(int& x) { > + [&x]() { > + decltype(auto) a = x; > + using type = decltype(x); > + using type = decltype(a); > + using type = int&; // not 'int' > + }; > + > + [x]() mutable { > + decltype(auto) a = x; > + using type = decltype(x); > + using type = decltype(a); > + using type = int&; > + }; > +}