specifier */
if (LAMBDA_FUNCTION_P (fn))
return true;
- /* -- a defaulted special member function that is not declared with the
+ /* -- a defaulted function that is not declared with the
consteval specifier */
- special_function_kind sfk = special_memfn_p (fn);
- if (sfk != sfk_none && DECL_DEFAULTED_FN (fn))
+ if (DECL_DEFAULTED_FN (fn))
return true;
/* -- a function that results from the instantiation of a templated entity
defined with the constexpr specifier. */
if (DECL_CONSTRUCTOR_P (decl) && !grok_ctor_properties (ctype, decl))
return NULL_TREE;
- /* Don't call check_consteval_only_fn for defaulted special member
- functions. Those are immediate-escalating functions but at this point
- DECL_DEFAULTED_P has not been set. */
- if (initialized != SD_DEFAULTED || special_memfn_p (decl) == sfk_none)
+ /* Don't call check_consteval_only_fn for defaulted functions. Those are
+ immediate-escalating functions but at this point DECL_DEFAULTED_P has
+ not been set. */
+ if (initialized != SD_DEFAULTED)
check_consteval_only_fn (decl);
if (ctype == NULL_TREE || check)
--- /dev/null
+// CWG3153
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+#include <compare>
+
+struct A {
+ decltype (^^::) a = ^^::;
+ consteval A () {}
+ bool operator== (const A &) const = default; // { dg-bogus "function of consteval-only type must be declared 'consteval'" }
+};
+
+template <typename T, T V>
+struct B
+{
+ T b = V;
+ consteval B () {}
+ bool operator== (const B &) const = default;
+};
+
+struct C {
+ decltype (^^::) c= ^^::;
+ int d = 0;
+ consteval C () {}
+ consteval bool operator== (const C &x) const { return d == x.d; }
+ consteval auto operator<=> (const C &x) const { return d <=> x.d; }
+};
+
+struct D : public C {
+ int e = 0;
+ consteval D () {}
+ auto operator<=> (const D &) const = default;
+};
+
+consteval
+{
+ A a;
+ A b;
+ if (a != b) throw 1;
+ B <decltype (^^::), ^^::> c;
+ B <decltype (^^::), ^^::> d;
+ if (c != d) throw 2;
+ D e;
+ D f;
+ if (e != f) throw 3;
+ f.d = 2;
+ if (e >= f) throw 4;
+ f.d = 0;
+ f.e = -1;
+ if (e <= f) throw 5;
+}