}
/* Returns true iff FN is a user-provided function, i.e. user-declared
- and not defaulted at its first declaration. */
+ and not explicitly defaulted or deleted on its first declaration. */
bool
user_provided_p (tree fn)
fn = STRIP_TEMPLATE (fn);
return (!DECL_ARTIFICIAL (fn)
&& !(DECL_INITIALIZED_IN_CLASS_P (fn)
- && (DECL_DEFAULTED_FN (fn) || DECL_DELETED_FN (fn))));
+ && (DECL_DEFAULTED_FN (fn) || DECL_DELETED_FN (fn)))
+ /* At namespace scope,
+ void f () = delete;
+ is *not* user-provided (and any function deleted after its first
+ declaration is ill-formed). */
+ && !(DECL_NAMESPACE_SCOPE_P (fn) && DECL_DELETED_FN (fn)));
}
/* Returns true iff class T has a user-provided constructor. */
eval_is_user_provided (tree r)
{
r = maybe_get_first_fn (r);
- if (TREE_CODE (r) == FUNCTION_DECL
- && user_provided_p (r)
- // TODO: user_provided_p is false for non-members defaulted on
- // first declaration.
- && (!DECL_NAMESPACE_SCOPE_P (r) || !DECL_DELETED_FN (r)))
+ if (TREE_CODE (r) == FUNCTION_DECL && user_provided_p (r))
return boolean_true_node;
else
return boolean_false_node;