aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2024-02-02 12:04:11 -0500
committerJason Merrill <jason@redhat.com>2024-02-02 13:54:21 -0500
commite17a122d417fc0d606bcb3a3705b93ee81745cab (patch)
treeabd2f42c4198fc2cfbb1c5679076057fc6932801
parent1c3cfb5a95dcc7f797ec2815690a6291878580c4 (diff)
downloadgcc-e17a122d417fc0d606bcb3a3705b93ee81745cab.zip
gcc-e17a122d417fc0d606bcb3a3705b93ee81745cab.tar.gz
gcc-e17a122d417fc0d606bcb3a3705b93ee81745cab.tar.bz2
c++: op== defaulted outside class [PR110084]
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.
-rw-r--r--gcc/cp/pt.cc1
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/spaceship-eq16.C11
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C2
3 files changed, 13 insertions, 1 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 9d30a27..355e960 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -14812,6 +14812,7 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain,
if (DECL_SECTION_NAME (t))
set_decl_section_name (r, t);
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
index 0000000..e5538ea
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-eq16.C
@@ -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;
diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C
index a4d8b32..aaa0264 100644
--- a/gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C
+++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C
@@ -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;
};