89 lines · plain
1// RUN: rm -rf %t2// RUN: split-file %s %t3// RUN: cd %t4//5// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm6// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm \7// RUN: -fmodule-file=a=%t/a.pcm8// 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 -verify10//11// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm12// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -o %t/b.pcm \13// RUN: -fmodule-file=a=%t/a.pcm14// 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 -verify16 17//--- a.cppm18export module a;19 20namespace n {21}22 23//--- ordering.mock.h24namespace 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 std49 50//--- b.cppm51module;52#include "ordering.mock.h"53export module b;54 55import a;56 57namespace n {58 59struct monostate {60 friend constexpr bool operator==(monostate, monostate) = default;61};62 63export 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 71struct monostate2 {72 auto operator<=>(monostate2 const &) const & = default;73};74 75export struct wrapper2 {76 friend bool operator==(wrapper2 const &LHS, wrapper2 const &RHS) = default;77 78 monostate2 m_value;79};80 81} // namespace n82 83//--- use.cc84// expected-no-diagnostics85import b;86 87static_assert(n::wrapper() == n::wrapper());88static_assert(n::wrapper2() == n::wrapper2());89