public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-10129] c++: op== defaulted outside class [PR110084] Date: Fri, 2 Feb 2024 19:54:55 +0000 (GMT) [thread overview] Message-ID: <20240202195455.637923858C33@sourceware.org> (raw) https://gcc.gnu.org/g:28f95c81382243fc4e6f1b22741d258f5fd7541f commit r12-10129-g28f95c81382243fc4e6f1b22741d258f5fd7541f Author: Jason Merrill <jason@redhat.com> Date: Fri Feb 2 12:04:11 2024 -0500 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. (cherry picked from commit e17a122d417fc0d606bcb3a3705b93ee81745cab) Diff: --- gcc/cp/pt.cc | 1 + gcc/testsuite/g++.dg/cpp2a/spaceship-eq16.C | 11 +++++++++++ gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index dc8121e1b4b3..ed4dbe06179e 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -14444,6 +14444,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 index 000000000000..e5538ea98901 --- /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 a4d8b32922fb..aaa0264e7b34 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; };
reply other threads:[~2024-02-02 19:54 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240202195455.637923858C33@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).