| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
// RUN: cd %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm \ |
| 7 |
// RUN: -fmodule-file=a=%t/a.pcm |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/use.cc -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \ |
| 9 |
// RUN: -fsyntax-only -verify |
| 10 |
// |
| 11 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm |
| 12 |
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -o %t/b.pcm \ |
| 13 |
// RUN: -fmodule-file=a=%t/a.pcm |
| 14 |
// RUN: %clang_cc1 -std=c++20 %t/use.cc -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \ |
| 15 |
// RUN: -fsyntax-only -verify |
| 16 |
|
| 17 |
//--- a.cppm |
| 18 |
export module a; |
| 19 |
|
| 20 |
namespace n { |
| 21 |
} |
| 22 |
|
| 23 |
//--- ordering.mock.h |
| 24 |
namespace std { |
| 25 |
class strong_ordering { |
| 26 |
public: |
| 27 |
int n; |
| 28 |
static const strong_ordering less, equal, greater; |
| 29 |
constexpr bool operator==(int n) const noexcept { return this->n == n;} |
| 30 |
constexpr bool operator!=(int n) const noexcept { return this->n != n;} |
| 31 |
}; |
| 32 |
constexpr strong_ordering strong_ordering::less = {-1}; |
| 33 |
constexpr strong_ordering strong_ordering::equal = {0}; |
| 34 |
constexpr strong_ordering strong_ordering::greater = {1}; |
| 35 |
|
| 36 |
class partial_ordering { |
| 37 |
public: |
| 38 |
long n; |
| 39 |
static const partial_ordering less, equal, greater, equivalent, unordered; |
| 40 |
constexpr bool operator==(long n) const noexcept { return this->n == n;} |
| 41 |
constexpr bool operator!=(long n) const noexcept { return this->n != n;} |
| 42 |
}; |
| 43 |
constexpr partial_ordering partial_ordering::less = {-1}; |
| 44 |
constexpr partial_ordering partial_ordering::equal = {0}; |
| 45 |
constexpr partial_ordering partial_ordering::greater = {1}; |
| 46 |
constexpr partial_ordering partial_ordering::equivalent = {0}; |
| 47 |
constexpr partial_ordering partial_ordering::unordered = {-127}; |
| 48 |
} // namespace std |
| 49 |
|
| 50 |
//--- b.cppm |
| 51 |
module; |
| 52 |
#include "ordering.mock.h" |
| 53 |
export module b; |
| 54 |
|
| 55 |
import a; |
| 56 |
|
| 57 |
namespace n { |
| 58 |
|
| 59 |
struct monostate { |
| 60 |
friend constexpr bool operator==(monostate, monostate) = default; |
| 61 |
}; |
| 62 |
|
| 63 |
export struct wrapper { |
| 64 |
friend constexpr bool operator==(wrapper const &LHS, wrapper const &RHS) { |
| 65 |
return LHS.m_value == RHS.m_value; |
| 66 |
} |
| 67 |
|
| 68 |
monostate m_value; |
| 69 |
}; |
| 70 |
|
| 71 |
struct monostate2 { |
| 72 |
auto operator<=>(monostate2 const &) const & = default; |
| 73 |
}; |
| 74 |
|
| 75 |
export struct wrapper2 { |
| 76 |
friend bool operator==(wrapper2 const &LHS, wrapper2 const &RHS) = default; |
| 77 |
|
| 78 |
monostate2 m_value; |
| 79 |
}; |
| 80 |
|
| 81 |
} // namespace n |
| 82 |
|
| 83 |
//--- use.cc |
| 84 |
// expected-no-diagnostics |
| 85 |
import b; |
| 86 |
|
| 87 |
static_assert(n::wrapper() == n::wrapper()); |
| 88 |
static_assert(n::wrapper2() == n::wrapper2()); |