// 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); } // 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