xref: /llvm-project/clang/test/CodeGenCXX/p2085.cpp (revision 5fbe21a7748f91adbd1b16c95bbfe180642320a3)
1*5fbe21a7SNathan Sidwell // RUN: %clang_cc1 --std=c++20 %s -emit-llvm -o - -triple x86_64-linux | FileCheck %s
2*5fbe21a7SNathan Sidwell 
3*5fbe21a7SNathan Sidwell namespace std {
4*5fbe21a7SNathan Sidwell struct strong_ordering {
5*5fbe21a7SNathan Sidwell   int n;
operator intstd::strong_ordering6*5fbe21a7SNathan Sidwell   constexpr operator int() const { return n; }
7*5fbe21a7SNathan Sidwell   static const strong_ordering equal, greater, less;
8*5fbe21a7SNathan Sidwell };
9*5fbe21a7SNathan Sidwell constexpr inline strong_ordering strong_ordering::equal = {0};
10*5fbe21a7SNathan Sidwell constexpr inline strong_ordering strong_ordering::greater = {1};
11*5fbe21a7SNathan Sidwell constexpr inline strong_ordering strong_ordering::less = {-1};
12*5fbe21a7SNathan Sidwell } // namespace std
13*5fbe21a7SNathan Sidwell 
14*5fbe21a7SNathan Sidwell struct Space {
15*5fbe21a7SNathan Sidwell   int i, j;
16*5fbe21a7SNathan Sidwell 
17*5fbe21a7SNathan Sidwell   std::strong_ordering operator<=>(Space const &other) const;
18*5fbe21a7SNathan Sidwell   bool operator==(Space const &other) const;
19*5fbe21a7SNathan Sidwell };
20*5fbe21a7SNathan Sidwell 
21*5fbe21a7SNathan Sidwell // Make sure these cause emission
22*5fbe21a7SNathan Sidwell std::strong_ordering Space::operator<=>(Space const &other) const = default;
23*5fbe21a7SNathan Sidwell // CHECK-LABEL: define{{.*}} @_ZNK5SpacessERKS_
24*5fbe21a7SNathan Sidwell bool Space::operator==(Space const &) const = default;
25*5fbe21a7SNathan Sidwell // CHECK-LABEL: define{{.*}} @_ZNK5SpaceeqERKS_
26*5fbe21a7SNathan Sidwell 
27*5fbe21a7SNathan Sidwell struct Water {
28*5fbe21a7SNathan Sidwell   int i, j;
29*5fbe21a7SNathan Sidwell 
30*5fbe21a7SNathan Sidwell   std::strong_ordering operator<=>(Water const &other) const;
31*5fbe21a7SNathan Sidwell   bool operator==(Water const &other) const;
32*5fbe21a7SNathan Sidwell };
33*5fbe21a7SNathan Sidwell 
34*5fbe21a7SNathan Sidwell // Make sure these do not cause emission
35*5fbe21a7SNathan Sidwell inline std::strong_ordering Water::operator<=>(Water const &other) const = default;
36*5fbe21a7SNathan Sidwell // CHECK-NOT: define{{.*}} @_ZNK5WaterssERKS_
37*5fbe21a7SNathan Sidwell inline bool Water::operator==(Water const &) const = default;
38*5fbe21a7SNathan Sidwell // CHECK-NOT: define{{.*}} @_ZNK5WatereqERKS_
39