[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaTemplate / cxx2a-constraint-caching.cpp
blobd44a42926891f467a229fd7f418a63fc3875272d
1 // RUN: %clang_cc1 -std=c++2a -verify %s
2 // expected-no-diagnostics
4 template<typename T>
5 concept C = (f(T()), true);
7 template<typename T>
8 constexpr bool foo() { return false; }
10 template<typename T>
11 requires (f(T()), true)
12 constexpr bool foo() requires (f(T()), true) { return true; }
14 namespace a {
15 struct A {};
16 constexpr void f(A a) {}
19 static_assert(C<a::A>);
20 static_assert(foo<a::A>());
22 namespace a {
23 // This makes calls to f ambiguous, but the second check will still succeed
24 // because the constraint satisfaction results are cached.
25 constexpr void f(A a, int = 2) {}
27 static_assert(C<a::A>);
28 static_assert(foo<a::A>());