@@ -6094,7 +6094,9 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
{
/* An out-of-class default definition is defined at
the point where it is explicitly defaulted. */
- if (DECL_INITIAL (decl) == error_mark_node)
+ if (DECL_DELETED_FN (decl))
+ maybe_explain_implicit_delete (decl);
+ else if (DECL_INITIAL (decl) == error_mark_node)
synthesize_method (decl);
}
else
@@ -1318,8 +1318,7 @@ maybe_explain_implicit_delete (tree decl)
/* If decl is a clone, get the primary variant. */
decl = DECL_ORIGIN (decl);
gcc_assert (DECL_DELETED_FN (decl));
- if (DECL_DEFAULTED_FN (decl)
- && DECL_INITIAL (decl) == NULL_TREE)
+ if (DECL_DEFAULTED_FN (decl))
{
/* Not marked GTY; it doesn't need to be GC'd or written to PCH. */
static htab_t explained_htab;
new file mode 100644
@@ -0,0 +1,20 @@
+// PR c++/46736
+// { dg-options -std=c++0x }
+
+struct U {
+ U();
+ U(U const&);
+};
+
+struct X {
+ U const u;
+ X();
+ X(X&&);
+};
+
+X::X(X&&)=default; // { dg-error "implicitly deleted" }
+// { dg-error "does not have a move constructor" "" { target *-*-* } 15 }
+
+X f() {
+ return X();
+}