brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · eeed85f Raw
54 lines · cpp
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 %s2 3// No crash for following example.4// See https://github.com/llvm/llvm-project/issues/454815namespace std {6class strong_ordering;7 8// Mock how STD defined unspecified parameters for the operators below.9struct _CmpUnspecifiedParam {10  consteval11  _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}12};13 14struct strong_ordering {15  signed char value;16 17  friend constexpr bool operator==(strong_ordering v,18                                   _CmpUnspecifiedParam) noexcept {19    return v.value == 0;20  }21  friend constexpr bool operator<(strong_ordering v,22                                  _CmpUnspecifiedParam) noexcept {23    return v.value < 0;24  }25  friend constexpr bool operator>(strong_ordering v,26                                  _CmpUnspecifiedParam) noexcept {27    return v.value > 0;28  }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};35constexpr strong_ordering strong_ordering::equal = {0};36constexpr strong_ordering strong_ordering::greater = {1};37constexpr strong_ordering strong_ordering::less = {-1};38} // namespace std39 40struct S {41    friend bool operator<(const S&, const S&);42    friend bool operator==(const S&, const S&);43};44 45struct 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 51void foo(MyStruct bar){52    (void)(bar <=> bar);53}54