testsuite: Add testcase for already fixed PR97121
authorJakub Jelinek <jakub@redhat.com>
Tue, 13 Apr 2021 18:42:07 +0000 (20:42 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 13 Apr 2021 18:42:07 +0000 (20:42 +0200)
This was fixed by r11-5866 aka PR96299 fix.

2021-04-13  Jakub Jelinek  <jakub@redhat.com>

PR c++/97121
* g++.dg/cpp2a/spaceship-err6.C: New test.

gcc/testsuite/g++.dg/cpp2a/spaceship-err6.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-err6.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-err6.C
new file mode 100644 (file)
index 0000000..57fbdb3
--- /dev/null
@@ -0,0 +1,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;
+};
+
+int main()
+{
+  MyClass a = 10, b = 15;
+  return (a < b);      // { dg-error "use of deleted function 'constexpr bool MyClass::operator<=>\\\(const MyClass&\\\) const'" }
+}