aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/spaceship-err6.C
blob: 7e36df3ff9f30c089d3cb64a72e430f2d8219364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// PR c++/97121
// { dg-do compile { target c++20 } }

#include <compare>

class MyClass
{
  int mValue;	// { dg-error "three-way comparison of 'MyClass::mValue' has type 'std::strong_ordering', which does not convert to 'bool'" }

public:
  MyClass(int value): mValue(value) {}

  bool operator<=>(const MyClass&) const = default;	// { dg-error "invalid 'static_cast' from type 'const std::strong_ordering' to type 'bool'" }
};

int main()
{
  MyClass a = 10, b = 15;
  return (a < b);	// { dg-error "use of deleted function 'constexpr bool MyClass::operator<=>\\\(const MyClass&\\\) const'" }
}