2 // RUN: %clang_cc1 -x c++ -std=c++20 %s -verify -fmodules -fmodules-cache-path=%t
3 #pragma clang module build std
5 module concepts
[system
] {
6 module assignable
[system
] {
10 module functional
[system
] {
15 module type_traits
[system
] {
20 #pragma clang module contents
21 #pragma clang module begin std.type_traits
23 template<class _Tp
, class _Up
>
24 concept same_as
= __is_same(_Tp
, _Up
);
27 struct common_reference
;
29 template <class _Tp
, class _Up
> struct common_reference
<_Tp
, _Up
>
34 #pragma clang module end // type_traits
36 #pragma clang module begin std.concepts.assignable
37 #pragma clang module import std.type_traits
39 template<class _Tp
, class _Up
>
40 concept common_reference_with
=
41 same_as
<typename common_reference
<_Tp
, _Up
>::type
, typename common_reference
<_Up
, _Tp
>::type
>;
44 template<class _Lhs
, class _Rhs
>
45 concept assignable_from
=
46 common_reference_with
<const __remove_reference_t(_Lhs
)&, const __remove_reference_t(_Rhs
)&> ;
48 #pragma clang module end // std.concepts.assignable
50 #pragma clang module begin std.functional
51 #pragma clang module import std.concepts.assignable
53 template<class _Sp
, class _Ip
>
54 concept sentinel_for
= assignable_from
<_Ip
&, _Ip
>;
55 template <class _Sp
, class _Ip
>
56 concept nothrow_sentinel_for
= sentinel_for
<_Sp
, _Ip
>;
58 #pragma clang module end // std::functional
59 #pragma clang module endbuild // contents
62 #pragma clang module import std.functional
63 constexpr bool ntsf_subsumes_sf(std::nothrow_sentinel_for
<char*> auto) requires
true {
66 constexpr bool ntsf_subsumes_sf(std::sentinel_for
<char*> auto);
67 static_assert(ntsf_subsumes_sf("foo"));
69 // Note: Doing diagnostics verify lines in the individual modules isn't
70 // permitted, and using 'bookmarks' in a module also doesn't work, so we're
71 // forced to diagnose this by line-number.
73 // Check to ensure that this error happens, prior to a revert of a concepts
74 // sugaring patch, this diagnostic didn't happen correctly.
76 // expected-error@* {{partial specialization of 'common_reference<_Tp, _Up>' must be imported from module 'std.type_traits' before it is required}}
77 // expected-note@63 {{while substituting into concept arguments here}}
78 // expected-note@*{{partial specialization declared here is not reachable}}