101 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-module-interface -o %t/m-a.pcm6// RUN: %clang_cc1 -std=c++23 %t/b.cppm -emit-module-interface -o %t/m-b.pcm7// RUN: %clang_cc1 -std=c++23 %t/m.cppm -emit-module-interface -o %t/m.pcm \8// RUN: -fprebuilt-module-path=%t9// RUN: %clang_cc1 -std=c++23 %t/pr63544.cpp -fprebuilt-module-path=%t -fsyntax-only -verify10 11// Test again with reduced BMI.12// RUN: rm -rf %t13// RUN: mkdir -p %t14// RUN: split-file %s %t15//16// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-reduced-module-interface -o %t/m-a.pcm17// RUN: %clang_cc1 -std=c++23 %t/b.cppm -emit-reduced-module-interface -o %t/m-b.pcm18// RUN: %clang_cc1 -std=c++23 %t/m.cppm -emit-reduced-module-interface -o %t/m.pcm \19// RUN: -fprebuilt-module-path=%t20// RUN: %clang_cc1 -std=c++23 %t/pr63544.cpp -fprebuilt-module-path=%t -fsyntax-only -verify21 22 23//--- foo.h24 25namespace std {26struct strong_ordering {27 int n;28 constexpr operator int() const { return n; }29 static const strong_ordering equal, greater, less;30};31constexpr strong_ordering strong_ordering::equal = {0};32constexpr strong_ordering strong_ordering::greater = {1};33constexpr strong_ordering strong_ordering::less = {-1};34} // namespace std35 36namespace std {37template <typename _Tp>38class optional {39private:40 using value_type = _Tp;41 value_type __val_;42 bool __engaged_;43public:44 constexpr bool has_value() const noexcept45 {46 return this->__engaged_;47 }48 49 constexpr const value_type& operator*() const& noexcept50 {51 return __val_;52 }53 54 optional(_Tp v) : __val_(v) {55 __engaged_ = true;56 }57};58 59template <class _Tp>60concept __is_derived_from_optional = requires(const _Tp& __t) { []<class __Up>(const optional<__Up>&) {}(__t); };61 62template <class _Tp, class _Up>63 requires(!__is_derived_from_optional<_Up>)64constexpr strong_ordering65operator<=>(const optional<_Tp>& __x, const _Up& __v) {66 return __x.has_value() ? *__x <=> __v : strong_ordering::less;67}68} // namespace std69 70//--- a.cppm71module;72#include "foo.h"73export module m:a;74export namespace std {75 using std::optional;76 using std::operator<=>;77}78 79//--- b.cppm80module;81#include "foo.h"82export module m:b;83export namespace std {84 using std::optional;85 using std::operator<=>;86}87 88//--- m.cppm89export module m;90export import :a;91export import :b;92 93//--- pr63544.cpp94// expected-no-diagnostics95import m;96int pr63544() {97 std::optional<int> a(43);98 int t{3};99 return a<=>t;100}101