Files
gcc-reflection/gcc/testsuite/g++.dg/cpp1y/lambda-init20.C
Patrick Palka 705ab7927c c++: decltype of capture proxy [PR79378, PR96917]
We typically don't see capture proxies in finish_decltype_type because
process_outer_var_ref is a no-op within an unevaluated context and so a
use of a captured variable within decltype resolves to the captured
variable, not the capture.  But we can see them during decltype(auto)
deduction and for decltype of an init-capture, which suggests we need to
handle capture proxies specially within finish_decltype_type after all.
This patch adds such handling.

	PR c++/79378
	PR c++/96917

gcc/cp/ChangeLog:

	* semantics.cc (finish_decltype_type): Handle an id-expression
	naming a capture proxy specially.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/decltype-auto7.C: New test.
	* g++.dg/cpp1y/lambda-init20.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2023-11-10 10:58:04 -05:00

23 lines
358 B
C

// PR c++/79378
// { dg-do compile { target c++14 } }
int main() {
int x = 0;
[x=x, &r=x] {
using ty1 = int;
using ty1 = decltype(x);
using ty2 = int&;
using ty2 = decltype(r);
};
const int cx = 0;
[x=cx, &r=cx] {
using ty1 = int;
using ty1 = decltype(x);
using ty2 = const int&;
using ty2 = decltype(r);
};
}