[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / GH60336.cpp
blobe181c2490421770144320b7ca9759efe98403a94
1 // RUN: rm -rf %t
2 // RUN: %clang_cc1 -x c++ -std=c++20 %s -verify -fmodules -fmodules-cache-path=%t
3 // expected-no-diagnostics
5 #pragma clang module build std
6 module std [system] {
7 module concepts [system] {
8 module assignable [system] {
10 export *
12 module functional [system] {
13 export *
17 module type_traits [system] {
18 export *
22 #pragma clang module contents
23 #pragma clang module begin std.type_traits
24 namespace std {
25 template<class _Tp, class _Up>
26 concept same_as = __is_same(_Tp, _Up);
28 template <class...>
29 struct common_reference;
31 template <class _Tp, class _Up> struct common_reference<_Tp, _Up>
33 using type = _Tp;
36 #pragma clang module end // type_traits
38 #pragma clang module begin std.concepts.assignable
39 #pragma clang module import std.type_traits
40 namespace std {
41 template<class _Tp, class _Up>
42 concept common_reference_with =
43 same_as<typename common_reference<_Tp, _Up>::type, typename common_reference<_Up, _Tp>::type>;
45 namespace std {
46 template<class _Lhs, class _Rhs>
47 concept assignable_from =
48 common_reference_with<const __remove_reference_t(_Lhs)&, const __remove_reference_t(_Rhs)&> ;
50 #pragma clang module end // std.concepts.assignable
52 #pragma clang module begin std.functional
53 #pragma clang module import std.concepts.assignable
54 namespace std {
55 template<class _Sp, class _Ip>
56 concept sentinel_for = assignable_from<_Ip&, _Ip>;
57 template <class _Sp, class _Ip>
58 concept nothrow_sentinel_for = sentinel_for<_Sp, _Ip>;
60 #pragma clang module end // std::functional
61 #pragma clang module endbuild // contents
64 #pragma clang module import std.functional
65 constexpr bool ntsf_subsumes_sf(std::nothrow_sentinel_for<char*> auto) requires true {
66 return true;
68 constexpr bool ntsf_subsumes_sf(std::sentinel_for<char*> auto);
69 static_assert(ntsf_subsumes_sf("foo"));