When building up *_EXTRA_ARGS for a constexpr if or pack expansion, we need to walk into the body of a lambda to find all the local_specializations that we need to remember, like we do in find_parameter_packs_r. gcc/cp/ChangeLog: PR c++/99201 * pt.c (class el_data): Add visited field. (extract_local_specs): Pass it to cp_walk_tree. (extract_locals_r): Walk into the body of a lambda. gcc/testsuite/ChangeLog: PR c++/99201 * g++.dg/cpp1z/constexpr-if-lambda4.C: New test.
23 lines
464 B
C
23 lines
464 B
C
// PR c++/99201
|
|
// { dg-do compile { target c++17 } }
|
|
|
|
template <typename RefF>
|
|
auto
|
|
make_tester(const RefF& reffun)
|
|
{
|
|
return [=](auto in) {
|
|
auto&& expected = [&](const auto&... vs) {
|
|
if constexpr (sizeof(in) > 0)
|
|
return [&](int i) { return reffun(vs[i]...); }(0);
|
|
else
|
|
return [&](int i) { return reffun(vs[i]...); }(0);
|
|
};
|
|
};
|
|
}
|
|
|
|
int main()
|
|
{
|
|
make_tester([](int x) { return x; })(0);
|
|
return 0;
|
|
}
|