int friendp,
int publicp,
int inlinep,
- bool deletedp,
+ int initialized,
bool xobj_func_p,
special_function_kind sfk,
bool funcdef_flag,
= !xobj_func_p && ctype && TREE_CODE (type) == FUNCTION_TYPE;
DECL_FUNCTION_XOBJ_FLAG (decl) = xobj_func_p;
- if (deletedp)
+ if (initialized == SD_DELETED)
DECL_DELETED_FN (decl) = 1;
if (ctype && funcdef_flag)
if (DECL_CONSTRUCTOR_P (decl) && !grok_ctor_properties (ctype, decl))
return NULL_TREE;
- check_consteval_only_fn (decl);
+ /* 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)
+ check_consteval_only_fn (decl);
if (ctype == NULL_TREE || check)
return decl;
friendp ? -1 : 0, friendp, publicp,
inlinep | (2 * constexpr_p) | (4 * concept_p)
| (8 * consteval_p),
- initialized == SD_DELETED,
+ initialized,
is_xobj_member_function, sfk,
funcdef_flag, late_return_type_p,
template_count, in_namespace,
publicp,
inlinep | (2 * constexpr_p) | (4 * concept_p)
| (8 * consteval_p),
- initialized == SD_DELETED,
+ initialized,
is_xobj_member_function, sfk,
funcdef_flag,
late_return_type_p,
--- /dev/null
+// PR c++/123404
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+struct S {
+ decltype (^^::) a = ^^::;
+ consteval S () {}
+ S (const S &) = default; // { dg-bogus "function of consteval-only type must be declared 'consteval'" }
+ S (S &&) = default; // { dg-bogus "function of consteval-only type must be declared 'consteval'" }
+ S &operator= (const S &) = default; // { dg-bogus "function of consteval-only type must be declared 'consteval'" }
+ S &operator= (S &&) = default; // { dg-bogus "function of consteval-only type must be declared 'consteval'" }
+ consteval const char *what () { return "what"; }
+};
+
+template <typename T, T V>
+struct U
+{
+ T a = V;
+ consteval U () {}
+ U (const U &) = default; // { dg-bogus "function of consteval-only type must be declared 'consteval'" }
+ U (U &&) = default; // { dg-bogus "function of consteval-only type must be declared 'consteval'" }
+ U &operator= (const U &) = default; // { dg-bogus "function of consteval-only type must be declared 'consteval'" }
+ U &operator= (U &&) = default; // { dg-bogus "function of consteval-only type must be declared 'consteval'" }
+ consteval const char *what () { return "what"; }
+};
+
+consteval
+{
+ S s;
+ S t;
+ t = s;
+ S u = t;
+ u.what ();
+ U <decltype (^^::), ^^::> v;
+ U <decltype (^^::), ^^::> w;
+ w = v;
+ U <decltype (^^::), ^^::> x = w;
+ x.what ();
+}