aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg7.C
blob: f3ef9fe13c07a50d62cf6d2acbf76e6d09ffa12f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// PR c++/118387
// { dg-do compile { target c++20 } }

#include <compare>

struct A {
  int operator<=> (const A &) const;
};

struct B {
  A a;
  int operator<=> (const B &) const = default;	// { dg-message "'constexpr int B::operator<=>\\\(const B&\\\) const' is implicitly deleted because the default definition would be ill-formed:" }
};			// { dg-error "invalid 'static_cast' from type 'const std::strong_ordering' to type 'int'" "" { target *-*-* } .-1 }

struct C {
  int operator<=> (const C &) const = default;	// { dg-message "'constexpr int C::operator<=>\\\(const C&\\\) const' is implicitly deleted because the default definition would be ill-formed:" }
};			// { dg-error "invalid 'static_cast' from type 'const std::strong_ordering' to type 'int'" "" { target *-*-* } .-1 }

struct D {
  auto operator<=> (const D &) const = default;
};

struct E {
  D a;			// { dg-error "three-way comparison of 'E::a' has type 'std::strong_ordering', which does not convert to 'int'" }
  int operator<=> (const E &) const = default;	// { dg-message "'constexpr int E::operator<=>\\\(const E&\\\) const' is implicitly deleted because the default definition would be ill-formed:" }
};			// { dg-error "invalid 'static_cast' from type 'const std::strong_ordering' to type 'int'" "" { target *-*-* } .-1 }

struct F {
  A a;
  int operator<=> (const F &) const = default;
};

struct G {
  int operator<=> (const G &) const = default;
};

struct H {
  D a;
  int operator<=> (const H &) const = default;
};

auto
foo (B a, B b)
{
  return a <=> b;	// { dg-error "use of deleted function 'constexpr int B::operator<=>\\\(const B&\\\) const'" }
}

auto
bar (C a, C b)
{
  return a <=> b;	// { dg-error "use of deleted function 'constexpr int C::operator<=>\\\(const C&\\\) const'" }
}

auto
baz (E a, E b)
{
  return a <=> b;	// { dg-error "use of deleted function 'constexpr int E::operator<=>\\\(const E&\\\) const'" }
}