1 // RUN: %clang_cc1 -std=c++20 %s -verify 2 3 4 template <auto> struct Nothing {}; 5 Nothing<[]() { return 0; }()> nothing; 6 7 template <typename> struct NothingT {}; 8 Nothing<[]() { return 0; }> nothingT; 9 10 template <typename T> 11 concept True = [] { return true; }(); 12 static_assert(True<int>); 13 14 static_assert(sizeof([] { return 0; })); 15 static_assert(sizeof([] { return 0; }())); 16 17 void f() noexcept(noexcept([] { return 0; }())); 18 19 using a = decltype([] { return 0; }); 20 using b = decltype([] { return 0; }()); 21 using c = decltype([]() noexcept(noexcept([] { return 0; }())) { return 0; }); 22 using d = decltype(sizeof([] { return 0; })); 23 24 template <auto T> 25 int unique_test1(); 26 static_assert(&unique_test1<[](){}> != &unique_test1<[](){}>); 27 28 template <class T> 29 auto g(T) -> decltype([]() { T::invalid; } ()); 30 auto e = g(0); // expected-error{{no matching function for call}} 31 // expected-note@-2 {{substitution failure}} 32 33 namespace PR52073 { 34 // OK, these are distinct functions not redefinitions. 35 template<typename> void f(decltype([]{})) {} // expected-note {{candidate}} 36 template<typename> void f(decltype([]{})) {} // expected-note {{candidate}} 37 void use_f() { f<int>({}); } // expected-error {{ambiguous}} 38 39 // Same. 40 template<int N> void g(const char (*)[([]{ return N; })()]) {} // expected-note {{candidate}} 41 template<int N> void g(const char (*)[([]{ return N; })()]) {} // expected-note {{candidate}} 42 // FIXME: We instantiate the lambdas into the context of the function template, 43 // so we think they're dependent and can't evaluate a call to them. 44 void use_g() { g<6>(&"hello"); } // expected-error {{no matching function}} 45 } 46