mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 12:00:11 -05:00
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>
23 lines
358 B
C
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);
|
|
};
|
|
}
|