// RUN: %clang_cc1 -std=c++20 -verify %s // RUN: %clang_cc1 -std=c++20 -verify %s -triple powerpc64-ibm-aix namespace GH57945 { template concept c = true; template auto f = []() requires c { }; void g() { f(); }; } namespace GH57945_2 { template concept c = true; template auto f = [](auto... args) requires c { }; template auto f2 = [](auto... args) requires (sizeof...(args) > 0) {}; void g() { f(); f2(5.0); } } namespace GH57958 { template concept C = true; template constexpr bool v = [](C auto) { return true; }(0); int _ = v<0>; } namespace GH57958_2 { template concept C = true; template constexpr bool v = [](C auto...) { return true; }(0); int _ = v<0>; } namespace GH57971 { template concept any = true; template auto f = [](any auto) { }; using function_ptr = void(*)(int); function_ptr ptr = f; } // GH58368: A lambda defined in a concept requires we store // the concept as a part of the lambda context. namespace LambdaInConcept { using size_t = unsigned long; template struct IdxSeq{}; template concept NotLike = true; template struct AnyExcept { template T> operator T&() const; template T> operator T&&() const; }; template concept ConstructibleWithN = (requires { [] (IdxSeq) requires requires { T{AnyExcept{}}; } { } (IdxSeq<1,2,3>{}); }); struct Foo { int i; double j; char k; }; static_assert(ConstructibleWithN); namespace GH56556 { template inline constexpr It declare (); template typename Template> concept D = requires { { [] (Template &) {}(declare()) }; }; template struct B {}; template struct Adapter; template T> struct Adapter {}; template struct Adapter>; } // namespace GH56556 namespace GH82849 { template concept C = requires(T t) { requires requires (T u) { [](V) { return requires(V v) { [](V w) {}(v); }; }(t); }; }; template struct Widget; template struct Widget { static F create(F from) { return from; } }; template bool foo() { return C; } void bar() { // https://github.com/llvm/llvm-project/issues/49570#issuecomment-1664966972 Widget::create(0); } } // namespace GH82849 } // GH60642 reported an assert being hit, make sure we don't assert. namespace GH60642 { template concept C = requires { Q.template operator()(); }; template concept D = true; static_assert(C<[]{}>); // ok template concept E = C<[]{}>; static_assert(E); // previously Asserted. // ensure we properly diagnose when "D" is false. namespace DIsFalse { template concept C = requires { Q.template operator()(); }; template concept D = false; static_assert(C<[]{}>); // expected-error@-1{{static assertion failed}} // expected-note@-2{{does not satisfy 'C'}} // expected-note@-5{{because 'Q.template operator()()' would be invalid: no matching member function for call to 'operator()'}} template concept E = C<[]{}>; static_assert(E); // expected-error@-1{{static assertion failed}} // expected-note@-2{{because 'int' does not satisfy 'E'}} // expected-note@-4{{does not satisfy 'C'}} // expected-note@-11{{because 'Q.template operator()()' would be invalid: no matching member function for call to 'operator()'}} } } namespace ReturnTypeRequirementInLambda { template concept C1 = true; template concept test = [] { return requires(T t) { { t } -> C1; }; }(); static_assert(test); template concept C2 = true; struct S1 { int f1() { return 1; } }; void foo() { auto make_caller = [] { return [](S1 *ps) { if constexpr (requires { { (ps->*member)() } -> C2; }) ; }; }; auto caller = make_caller.operator()<&S1::f1>(); } } // namespace ReturnTypeRequirementInLambda namespace GH73418 { void foo() { int x; [&x](auto) { return [](auto y) { return [](auto obj, auto... params) requires requires { sizeof...(params); [](auto... pack) { return sizeof...(pack); }(params...); } { return false; }(y); }(x); }(x); } } // namespace GH73418 namespace GH93821 { template concept C = true; template concept D = []() { return true; }(); D auto x = 0; } // namespace GH93821 namespace dependent_param_concept { template void sink(Ts...) {} void dependent_param() { auto L = [](auto... x) { return [](decltype(x)... y) { return [](int z) requires requires { sink(y..., z); } {}; }; }; L(0, 1)(1, 2)(1); } } // namespace dependent_param_concept namespace init_captures { template struct V {}; void sink(V<0>, V<1>, V<2>, V<3>, V<4>) {} void init_capture_pack() { auto L = [](auto... z) { return [=](auto... y) { return [... w = z, y...](auto) requires requires { sink(w..., y...); } {}; }; }; L(V<0>{}, V<1>{}, V<2>{})(V<3>{}, V<4>{})(1); } void dependent_capture_packs() { auto L = [](auto... z) { return [... w = z](auto... y) { return [... c = w](auto) requires requires { sink(c..., y...); } {}; }; }; L(V<0>{}, V<1>{}, V<2>{})(V<3>{}, V<4>{})(1); } } // namespace init_captures namespace GH110721 { template void connect() { int x = N, y = N; [x, y = y]() requires requires { x; } {}(); } void foo() { connect<42>(); } } // namespace GH110721 namespace GH123441 { void test() { auto L = [](auto... x) { return [](decltype(x)... y) requires true {}; }; L(0, 1)(1, 2); } }