Debian Codegraph @

clang/test/SemaCXX/overload-bitint.cpp

raw
1 // RUN: %clang_cc1 -std=c++20 %s -verify
2 // expected-no-diagnostics
3
4 #include "Inputs/std-compare.h"
5
6 struct S {
7 _BitInt(12) a;
8
9 constexpr operator _BitInt(12)() const { return a; }
10 };
11
12 // None of these used to compile because we weren't adding _BitInt types to the
13 // overload set for builtin operators. See GH82998.
14 static_assert(S{10} < 11);
15 static_assert(S{10} <= 11);
16 static_assert(S{12} > 11);
17 static_assert(S{12} >= 11);
18 static_assert(S{10} == 10);
19 static_assert((S{10} <=> 10) == 0);
20 static_assert(S{10} != 11);
21 static_assert(S{10} + 0 == 10);
22 static_assert(S{10} - 0 == 10);
23 static_assert(S{10} * 1 == 10);
24 static_assert(S{10} / 1 == 10);
25 static_assert(S{10} % 1 == 0);
26 static_assert(S{10} << 0 == 10);
27 static_assert(S{10} >> 0 == 10);
28 static_assert((S{10} | 0) == 10);
29 static_assert((S{10} & 10) == 10);
30 static_assert((S{10} ^ 0) == 10);
31 static_assert(-S{10} == -10);
32 static_assert(+S{10} == +10);
33 static_assert(~S{10} == ~10);
34
35 struct A {
36 _BitInt(12) a;
37
38 bool operator==(const A&) const = default;
39 bool operator!=(const A&) const = default;
40 std::strong_ordering operator<=>(const A&) const = default;
41 };
42