+2020-04-08 Marek Polacek <polacek@redhat.com>
+
+ PR c++/94478 - ICE with defaulted comparison operator
+ * method.c (early_check_defaulted_comparison): Give an error when the
+ context is null.
+
2020-04-08 Tobias Burnus <tobias@codesourcery.com>
PR middle-end/94120
return false;
}
+ if (!ctx)
+ {
+ if (DECL_OVERLOADED_OPERATOR_IS (fn, SPACESHIP_EXPR))
+ error_at (loc, "three-way comparison operator can only be defaulted "
+ "in a class definition");
+ else
+ error_at (loc, "equality comparison operator can only be defaulted "
+ "in a class definition");
+ return false;
+ }
+
if (!DECL_OVERLOADED_OPERATOR_IS (fn, SPACESHIP_EXPR)
&& !same_type_p (TREE_TYPE (TREE_TYPE (fn)), boolean_type_node))
{
+2020-04-08 Marek Polacek <polacek@redhat.com>
+
+ PR c++/94478 - ICE with defaulted comparison operator
+ * g++.dg/cpp2a/spaceship-err4.C: New test.
+
2020-04-08 Alexandre Oliva <oliva@adacore.com>
* gcc.target/arm/polytypes.c: Add quotes around
--- /dev/null
+// PR c++/94478 - ICE with defaulted comparison operator.
+// { dg-do compile { target c++2a } }
+
+struct B {};
+bool operator!=(const B&, const B&) = default; // { dg-error "equality comparison operator can only be defaulted in a class definition" }
+bool operator==(const B&, const B&) = default; // { dg-error "equality comparison operator can only be defaulted in a class definition" }
+bool operator<=>(const B&, const B&) = default; // { dg-error "three-way comparison operator can only be defaulted in a class definition" }