1 // RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++23 -triple %itanium_abi_triple -main-file-name if.cpp %s
2
3 // No crash for following example.
4 // See https://github.com/llvm/llvm-project/issues/45481
5 namespace std {
6 class strong_ordering;
7
8 // Mock how STD defined unspecified parameters for the operators below.
9 struct _CmpUnspecifiedParam {
10 consteval
_CmpUnspecifiedParamstd::_CmpUnspecifiedParam11 _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
12 };
13
14 struct strong_ordering {
15 signed char value;
16
operator ==(strong_ordering v,_CmpUnspecifiedParam)17 friend constexpr bool operator==(strong_ordering v,
18 _CmpUnspecifiedParam) noexcept {
19 return v.value == 0;
20 }
operator <(strong_ordering v,_CmpUnspecifiedParam)21 friend constexpr bool operator<(strong_ordering v,
22 _CmpUnspecifiedParam) noexcept {
23 return v.value < 0;
24 }
operator >(strong_ordering v,_CmpUnspecifiedParam)25 friend constexpr bool operator>(strong_ordering v,
26 _CmpUnspecifiedParam) noexcept {
27 return v.value > 0;
28 }
operator >=(strong_ordering v,_CmpUnspecifiedParam)29 friend constexpr bool operator>=(strong_ordering v,
30 _CmpUnspecifiedParam) noexcept {
31 return v.value >= 0;
32 }
33 static const strong_ordering equal, greater, less;
34 };
35 constexpr strong_ordering strong_ordering::equal = {0};
36 constexpr strong_ordering strong_ordering::greater = {1};
37 constexpr strong_ordering strong_ordering::less = {-1};
38 } // namespace std
39
40 struct S {
41 friend bool operator<(const S&, const S&);
42 friend bool operator==(const S&, const S&);
43 };
44
45 struct MyStruct {
46 friend bool operator==(MyStruct const& lhs, MyStruct const& rhs) = delete;
47 friend std::strong_ordering operator<=>(MyStruct const& lhs, MyStruct const& rhs) = default;
48 S value;
49 };
50
foo(MyStruct bar)51 void foo(MyStruct bar){
52 (void)(bar <=> bar);
53 }
54