xref: /llvm-project/clang/test/Modules/GH60336.cpp (revision 9e9d98aaf503171e2cb229e89966ec1c0adf3804)
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
4 
5 #pragma clang module build std
6 module std   [system] {
7   module concepts     [system] {
8       module assignable         [system] {
9     }
10     export *
11   }
12   module functional     [system] {
13     export *
14   }
15 
16 
17   module type_traits     [system] {
18     export *
19   }
20 }
21 
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);
27 
28 template <class...>
29 struct common_reference;
30 
31 template <class _Tp, class _Up> struct common_reference<_Tp, _Up>
32 {
33     using type = _Tp;
34 };
35 }
36 #pragma clang module end // type_traits
37 
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>;
44 }
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)&> ;
49 }
50 #pragma clang module end // std.concepts.assignable
51 
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>;
59 }
60 #pragma clang module end   // std::functional
61 #pragma clang module endbuild // contents
62 
63 
64 #pragma clang module import std.functional
65 constexpr bool ntsf_subsumes_sf(std::nothrow_sentinel_for<char*> auto) requires true {
66   return true;
67 }
68 constexpr bool ntsf_subsumes_sf(std::sentinel_for<char*> auto);
69 static_assert(ntsf_subsumes_sf("foo"));
70