// RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify %s namespace lambda_calls { template concept True = true; template concept False = false; // #False template struct S { template using type = decltype([](U...) {}(U()...)); template using type2 = decltype([](auto) {}(1)); template using type3 = decltype([](True auto) {}(1)); template using type4 = decltype([](auto... pack) { return sizeof...(pack); }(1, 2)); template using type5 = decltype([](False auto...) {}(1)); // #Type5 template using type6 = decltype([] {}.template operator()()); template using type7 = decltype([] {}.template operator()()); // #Type7 template using type8 = decltype([]() // #Type8 requires(sizeof(U) == 32) // #Type8-requirement {}()); template using type9 = decltype([](U...) {}.template operator()(U()...)); // https://github.com/llvm/llvm-project/issues/76674 template using type10 = decltype([] { return V(); }.template operator()()); template using type11 = decltype([] { return U{}; }); }; template using Meow = decltype([] {}.template operator()()); template using MeowMeow = decltype([](U...) {}.template operator()(U()...)); // https://github.com/llvm/llvm-project/issues/70601 template using U = decltype([] {}.template operator()()); U foo(); void bar() { using T = S::type; using T2 = S::type2; using T3 = S::type3; using T4 = S::type4; using T5 = S::type5; // #T5 // expected-error@#Type5 {{no matching function for call}} // expected-note@#T5 {{type alias 'type5' requested here}} // expected-note@#Type5 {{constraints not satisfied [with auto:1 = ]}} // expected-note@#Type5 {{because 'int' does not satisfy 'False'}} // expected-note@#False {{because 'false' evaluated to false}} using T6 = S::type6; using T7 = S::type7; // #T7 // expected-error@#Type7 {{no matching member function for call}} // expected-note@#T7 {{type alias 'type7' requested here}} // expected-note@#Type7 {{constraints not satisfied [with $0 = char]}} // expected-note@#Type7 {{because 'char' does not satisfy 'False'}} // expected-note@#False {{because 'false' evaluated to false}} using T8 = S::type8; // #T8 // expected-error@#Type8 {{no matching function for call}} // expected-note@#T8 {{type alias 'type8' requested here}} // expected-note@#Type8 {{constraints not satisfied}} // expected-note@#Type8-requirement {{because 'sizeof(char) == 32' (1 == 32) evaluated to false}} using T9 = S::type9; using T10 = S::type10; using T11 = S::type11; int x = T11()(); using T12 = Meow; using T13 = MeowMeow; static_assert(__is_same(T, void)); static_assert(__is_same(T2, void)); static_assert(__is_same(T3, void)); static_assert(__is_same(T4, decltype(sizeof(0)))); static_assert(__is_same(T6, void)); static_assert(__is_same(T9, void)); static_assert(__is_same(T10, int)); static_assert(__is_same(T12, void)); static_assert(__is_same(T13, void)); } namespace GH82104 { template constexpr int Value = sizeof...(D); template using T14 = decltype([](auto Param) { return Value + V + (int)sizeof(Param); }("hello")); template using T15 = T14; static_assert(__is_same(T15, int)); // FIXME: This still crashes because we can't extract template arguments T and U // outside of the instantiation context of T16. #if 0 template using T16 = decltype([](auto Param) requires (sizeof(Param) != 1 && sizeof...(U) > 0) { return Value + sizeof(Param); }); static_assert(T16()(42) == 2 + sizeof(42)); #endif } // namespace GH82104 namespace GH89853 { template static constexpr auto innocuous = [] { return m; }; template > using broken = decltype(Pred.template operator()<42>()); broken<> *boom; template { (void)static_cast(c); }> using broken2 = decltype(Pred.template operator()<42>()); broken2<> *boom2; template { return m; }> using broken3 = decltype(Pred.template operator()<42>()); broken3<> *boom3; static constexpr auto non_default = [](True auto) { (void) static_cast(c); }; template using broken4 = decltype(Pred.template operator()<42>(Pred)); broken4* boom4; } // namespace GH89853 namespace GH105885 { template using test = decltype([](auto...) { }()); static_assert(__is_same(test<0>, void)); } // namespace GH105885 namespace GH102760 { auto make_tuple = []< class Tag, class... Captures>(Tag, Captures...) { return []< class _Fun >( _Fun) -> void requires requires { 0; } {}; }; template < class, class... _As > using Result = decltype(make_tuple(0)(_As{}...)); using T = Result; } // namespace GH102760 } // namespace lambda_calls