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 60DC2384AB52 for ; Tue, 25 Jun 2024 01:48:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60DC2384AB52 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 60DC2384AB52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719280128; cv=none; b=B7SVlqKsuxgYRPVpyhXFB0o0NcDYbUYeklhiTiPbuUNrKa5SZRMxINJJjyBSG6JnPh+/hgiTT5JcVvDvVHqkgJn3CTfia0R5Tn/WQ7np5L8e2vXyKqMuiheZl1YJxac+t4mFBxeAHoZ66OmqTO0LNiI2qO1VqxdxyHckzlUDDcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719280128; c=relaxed/simple; bh=C9c1HgdDJSEcp9srXckPP0QELMzosK2HH1o9vJou0IU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=l5x8idFP1QAySqArCeuEKM2cBIEoVFx9DRL467i1CjycqbvAMezpHMlQ4D9H1hGgGN0i3gQ8xsW4F7vVXtzZvOYL8HIIZpB9XzlBEJxaLxSd8SW+7lW13UxsrRXRmvCwnN0FMFqEGRS9t9nY+IEXNEXek0QwyQGpDn9tx05RbWE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719280122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j8Y6hwFBSsX1fhO2DLuOkjPaiOE/PPLtWQQ+U7rvNRI=; b=ClLYR7Y0+eCW10V6HTLmLwHpKApPlrftpIY/zjyHtrgnlEtem4NFP2f/QF0qa6Ymgxpxde Q0KHR0V1nYokXf0hCON7rGOheEGWjZTJS0/Lt8TNcXgG1v/vge0d/ywH35hWWiEr1+Ga8t /nq5sQoAA/9/72S8QWTZRJ+q5oSG2n4= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-97-2ov5CsPZOW6ZgOeHXq6Y5g-1; Mon, 24 Jun 2024 21:48:40 -0400 X-MC-Unique: 2ov5CsPZOW6ZgOeHXq6Y5g-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-63bb7fb3229so107531377b3.2 for ; Mon, 24 Jun 2024 18:48:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719280119; x=1719884919; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=j8Y6hwFBSsX1fhO2DLuOkjPaiOE/PPLtWQQ+U7rvNRI=; b=Trs4vznZEybk6lO8XC69YFVetj4EoXYTtTYwxVNoYTozTtYmaF88w8NKK9VeIA4Ows BSli6MN5z7tguP4RNO5svsSY9qxKgaX+iW+fY3y6o7IaOAhRojt8oKkCoYywBuJjiFfm e5EcEYuPi47AUqnUF0ybxbuo52y6eGUjw6w4DMxvD5mxGUUPYF1U9xnf77pTk+14qCaF b/WtwKy0l2XaTb/xsGxwbs5Qy8NnErrZuG+Jg1seVkO9jVxV8VZTlRN0YopGhmesQsVY 8uuN0xF6DE3Q+4brsXPWHBpdlzjGtc08YPWtucMdCc2+DqT0UnHUHImY6IzpCNIyhd/D l28Q== X-Forwarded-Encrypted: i=1; AJvYcCX3suSMpoD5spjHE6s001CS37DyinOhggtPAcwvvBQIQvtJPZvUl6QWXa8XPYc0KWpQvdC9I53KggPfJ1F/xa1re+x5RwzzSw== X-Gm-Message-State: AOJu0Yzwl7+/fZw4mtNXlDpPt+6eN1ai73ZVYzp+P6yjN7E+n9L8tjRI mKgHAi7Jo1Jk8IrRFim1p485TtPEcJDvBhEPNdfmucW7/DL8OBFavRAU1bwoX4eoXiEP2eG+Uye 2pRs1DJ2CKvFD4ENdNLRo1Ux0MyXq7LQnZIHeQ8xvSf7wz9tcHwwIR2E= X-Received: by 2002:a81:a514:0:b0:615:20db:4a4d with SMTP id 00721157ae682-643abe46142mr59738497b3.35.1719280119580; Mon, 24 Jun 2024 18:48:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxjyYVEEJzubwJsvS+X7ADPEQD12U0huLyueWPVBcj01NpUJA3yik3j6BlG2nrP7lyCnbVDA== X-Received: by 2002:a81:a514:0:b0:615:20db:4a4d with SMTP id 00721157ae682-643abe46142mr59738417b3.35.1719280119223; Mon, 24 Jun 2024 18:48:39 -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 d75a77b69052e-444c2b8d984sm49224161cf.46.2024.06.24.18.48.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jun 2024 18:48:38 -0700 (PDT) Message-ID: <65a73f98-0be3-44c5-b703-e369da48f459@redhat.com> Date: Mon, 24 Jun 2024 21:48:38 -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 , gcc-patches@gcc.gnu.org References: <20240625010015.122204-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20240625010015.122204-1-ppalka@redhat.com> 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.4 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/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&. > PR c++/115504 > > gcc/cp/ChangeLog: > > * semantics.cc (finish_decltype_type): For a by-reference > capture proxy, don't strip the reference type (if any) of > the captured variable. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp1y/decltype-auto8.C: New test. > --- > gcc/cp/semantics.cc | 4 +++- > gcc/testsuite/g++.dg/cpp1y/decltype-auto8.C | 11 +++++++++++ > 2 files changed, 14 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 08f5f245e7d..b4f626924af 100644 > --- a/gcc/cp/semantics.cc > +++ b/gcc/cp/semantics.cc > @@ -12076,9 +12076,11 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, > { > if (is_normal_capture_proxy (expr)) > { > + bool by_ref = TYPE_REF_P (TREE_TYPE (expr)); > expr = DECL_CAPTURED_VARIABLE (expr); > type = TREE_TYPE (expr); > - type = non_reference (type); > + if (!by_ref) > + 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..9a5e435f14f > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp1y/decltype-auto8.C > @@ -0,0 +1,11 @@ > +// 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' > + }; > +}