// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s namespace GH85667 { template struct identity { using type = T; }; template using ElementType = int; template void f() { static_assert([](Is... x) { return ([I(x)] { return I; }() + ...); }(1, 2) == 3); [](Is... x) { return ([](auto y = Is()) { return y + 1; }() + ...); // expected-error {{no matching function}} \ // expected-note {{couldn't infer template argument 'y:auto'}} \ // expected-note@-1 {{requested here}} // expected-note@#instantiate-f {{requested here}} }(1); []() { ([](Is) noexcept(bool(Is())) {}(Is()), ...); }.template operator()(); static_assert(__is_same(decltype([]() { return ([]() -> decltype(Is()) { return {}; }(), ...); }.template operator()()), char)); []() { return ([]() -> decltype(Is()) { return Ts(); }() + ...); // expected-error@-1 {{unexpanded parameter pack 'Ts'}} }.template operator()(); // https://github.com/llvm/llvm-project/issues/56852 [](Is...) { ([] { using T = identity::type; }(), ...); }(1, 2); [](Is...) { ([] { using T = ElementType; }(), ...); }(1); [](auto ...y) { ([y] { }(), ...); }(); [](auto ...x) { ([&](auto ...y) { ([x..., y] { }(), ...); })(1); }(2, 'b'); #if 0 // FIXME: https://github.com/llvm/llvm-project/issues/18873 [](auto ...x) { // #1 ([&](auto ...y) { // #2 ([x, y] { }(), ...); // #3 })(1, 'a'); // #4 }(2, 'b'); // #5 // We run into another crash for the above lambda because of the absence of a // mechanism that rebuilds an unexpanded pack from an expanded Decls. // // Basically, this happens after `x` at #1 being expanded when the template // arguments at #5, deduced as , are ready. When we want to // instantiate the body of #1, we first instantiate the CallExpr at #4, which // boils down to the lambda's instantiation at #2. To that end, we have to // instantiate the body of it, which turns out to be #3. #3 is a CXXFoldExpr, // and we immediately have to hold off on the expansion because we don't have // corresponding template arguments (arguments at #4 are not transformed yet) for it. // Therefore, we want to rebuild a CXXFoldExpr, which requires another pattern // transformation of the lambda inside #3. Then we need to find an unexpanded form // of such a Decl of x at the time of transforming the capture, which is impossible // because the instantiated form has been expanded at #1! [](auto ...x) { // #outer ([&](auto ...y) { // #inner ([x, y] { }(), ...); // expected-error@-1 {{parameter pack 'y' that has a different length (4 vs. 3) from outer parameter packs}} // expected-note-re@#inner {{function template specialization {{.*}} requested here}} // expected-note-re@#outer {{function template specialization {{.*}} requested here}} // expected-note-re@#instantiate-f {{function template specialization {{.*}} requested here}} })('a', 'b', 'c'); }(0, 1, 2, 3); #endif } template void f(); // #instantiate-f } // namespace GH85667 namespace GH99877 { struct tuple { int x[3]; }; template int apply(F f, tuple v) { return f(v.x[0], v.x[1], v.x[2]); } int Cartesian1(auto x, auto y) { return apply( [&](auto... xs) { return (apply([xs](auto... ys) { return (ys + ...); }, y) + ...); }, x); } int Cartesian2(auto x, auto y) { return apply( [&](auto... xs) { return (apply([zs = xs](auto... ys) { return (ys + ...); }, y) + ...); }, x); } template struct Ints {}; template struct Choose { template struct Templ; }; template int Cartesian3(auto y) { return [&](Ints) { // check in default template arguments for // - type template parameters, (void)(apply([](auto... ys) { return (ys + ...); }, y) + ...); // - template template parameters. (void)(apply([]