duplicate_decls assumed that any TREE_ARTIFICIAL function at namespace scope
was a built-in function, but now in C++20 it's possible to have an
implicitly declared hidden friend operator==. We just need to move the
assert into the if condition.
gcc/cp/ChangeLog
2020-04-06 Jason Merrill <jason@redhat.com>
PR c++/94462
* decl.c (duplicate_decls): Fix handling of DECL_HIDDEN_FRIEND_P.
+2020-04-06 Jason Merrill <jason@redhat.com>
+
+ PR c++/94462
+ * decl.c (duplicate_decls): Fix handling of DECL_HIDDEN_FRIEND_P.
+
2020-04-04 Marek Polacek <polacek@redhat.com>
Jason Merrill <jason@redhat.com>
/* Check for redeclaration and other discrepancies. */
if (TREE_CODE (olddecl) == FUNCTION_DECL
- && DECL_ARTIFICIAL (olddecl))
+ && DECL_ARTIFICIAL (olddecl)
+ /* A C++20 implicit friend operator== uses the normal path (94462). */
+ && !DECL_HIDDEN_FRIEND_P (olddecl))
{
- gcc_assert (!DECL_HIDDEN_FRIEND_P (olddecl));
if (TREE_CODE (newdecl) != FUNCTION_DECL)
{
/* Avoid warnings redeclaring built-ins which have not been
--- /dev/null
+// PR c++/94462
+// { dg-do compile { target c++2a } }
+
+namespace std {
+ struct strong_ordering { };
+}
+
+namespace Synth {
+ struct B {
+ friend std::strong_ordering operator<=>(B, B) = default;
+ };
+
+ struct C {
+ friend bool operator==(C, C);
+ };
+}
+