]> gcc.gnu.org Git - gcc.git/commitdiff
c++: op== defaulted outside class [PR110084]
authorJason Merrill <jason@redhat.com>
Fri, 2 Feb 2024 17:04:11 +0000 (12:04 -0500)
committerJason Merrill <jason@redhat.com>
Fri, 2 Feb 2024 18:56:05 +0000 (13:56 -0500)
defaulted_late_check is for checks that need to happen after the class is
complete; we shouldn't call it sooner.

PR c++/110084

gcc/cp/ChangeLog:

* pt.cc (tsubst_function_decl): Only check a function defaulted
outside the class if the class is complete.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-synth-neg3.C: Check error message.
* g++.dg/cpp2a/spaceship-eq16.C: New test.

(cherry picked from commit e17a122d417fc0d606bcb3a3705b93ee81745cab)

gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp2a/spaceship-eq16.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C

index bcee75b8710a80a4069edb6f3ec40903b874764d..98974ba57549895e1aa241dcf900eec03359cf39 100644 (file)
@@ -14628,6 +14628,7 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain,
     }
   determine_visibility (r);
   if (DECL_DEFAULTED_OUTSIDE_CLASS_P (r)
+      && COMPLETE_TYPE_P (DECL_CONTEXT (r))
       && !processing_template_decl)
     defaulted_late_check (r);
 
diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-eq16.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-eq16.C
new file mode 100644 (file)
index 0000000..e5538ea
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/110084
+// { dg-do compile { target c++20 } }
+
+template <class T>
+class BadTuple {
+  constexpr bool operator==(const BadTuple&) const;
+};
+template<class T>
+constexpr bool BadTuple<T>::operator==(const BadTuple<T>&) const = default;
+
+BadTuple<int> a;
index a4d8b32922fba9e904ddbe5a236a3559f882a088..aaa0264e7b34362b0d1255725510ad77206d440a 100644 (file)
@@ -5,7 +5,7 @@ template<auto V>
 struct A {};
 
 struct B {
-    constexpr auto operator<=>(const B&) const = default; // { dg-error "" }
+    constexpr auto operator<=>(const B&) const = default; // { dg-error "strong_ordering" }
     int value;
 };
 
This page took 0.094248 seconds and 5 git commands to generate.