P2085 clarified that a defaulted comparison operator must be the first
declaration of the function. Rejecting that avoids the ICE trying to
compare the noexcept-specifications.
gcc/cp/ChangeLog
2020-04-24 Jason Merrill <jason@redhat.com>
PR c++/94583
* decl.c (redeclaration_error_message): Reject defaulted comparison
operator that has been previously declared.
+2020-04-24 Jason Merrill <jason@redhat.com>
+
+ PR c++/94583
+ * decl.c (redeclaration_error_message): Reject defaulted comparison
+ operator that has been previously declared.
+
2020-04-25 Patrick Palka <ppalka@redhat.com>
* parser.c (cp_parser_diagnose_invalid_type_name): Suggest enabling
}
}
+ /* [class.compare.default]: A definition of a comparison operator as
+ defaulted that appears in a class shall be the first declaration of
+ that function. */
+ special_function_kind sfk = special_function_p (olddecl);
+ if (sfk == sfk_comparison && DECL_DEFAULTED_FN (newdecl))
+ return G_("comparison operator %q+D defaulted after "
+ "its first declaration");
+
check_abi_tag_redeclaration
(olddecl, lookup_attribute ("abi_tag", DECL_ATTRIBUTES (olddecl)),
lookup_attribute ("abi_tag", DECL_ATTRIBUTES (newdecl)));
--- /dev/null
+// PR c++/94583
+// { dg-do compile { target c++2a } }
+
+namespace std { struct strong_ordering { }; }
+
+bool operator==(const struct Q&, const struct Q&);
+struct Q {
+ // { dg-error "defaulted after its first declaration" "" { target *-*-* } .+1 }
+ friend std::strong_ordering operator<=>(const Q&, const Q&) = default;
+};
+bool b = Q() == Q();