commit 29f2248c817fa1469529c8c3089d742c25a0310f
Author: Jason Merrill <jason@redhat.com>
Date: Wed Nov 16 14:25:23 2011 -0500
N3203
* class.c (add_implicitly_declared_members): Update move
conditions.
@@ -2721,6 +2721,13 @@ add_implicitly_declared_members (tree t,
int cant_have_const_cctor,
int cant_have_const_assignment)
{
+ bool move_ok = false;
+
+ if (cxx_dialect >= cxx0x && !CLASSTYPE_DESTRUCTORS (t)
+ && !TYPE_HAS_COPY_CTOR (t) && !TYPE_HAS_COPY_ASSIGN (t)
+ && !type_has_move_constructor (t) && !type_has_move_assign (t))
+ move_ok = true;
+
/* Destructor. */
if (!CLASSTYPE_DESTRUCTORS (t))
{
@@ -2758,7 +2765,7 @@ add_implicitly_declared_members (tree t,
TYPE_HAS_COPY_CTOR (t) = 1;
TYPE_HAS_CONST_COPY_CTOR (t) = !cant_have_const_cctor;
CLASSTYPE_LAZY_COPY_CTOR (t) = 1;
- if (cxx_dialect >= cxx0x && !type_has_move_constructor (t))
+ if (move_ok)
CLASSTYPE_LAZY_MOVE_CTOR (t) = 1;
}
@@ -2771,7 +2778,7 @@ add_implicitly_declared_members (tree t,
TYPE_HAS_COPY_ASSIGN (t) = 1;
TYPE_HAS_CONST_COPY_ASSIGN (t) = !cant_have_const_assignment;
CLASSTYPE_LAZY_COPY_ASSIGN (t) = 1;
- if (cxx_dialect >= cxx0x && !type_has_move_assign (t))
+ if (move_ok)
CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 1;
}
@@ -31,6 +31,7 @@ class tstring : public std::basic_string<char>
public:
tstring() : std::basic_string<char>() {}
tstring(tstring&& s) : std::basic_string<char>(std::move(s)) {}
+ tstring& operator=(tstring&& s) = default;
};
void test01()
@@ -31,6 +31,7 @@ class twstring : public std::basic_string<wchar_t>
public:
twstring() : std::basic_string<wchar_t>() {}
twstring(twstring&& s) : std::basic_string<wchar_t>(std::move(s)) {}
+ twstring& operator=(twstring&&) = default;
};
void test01()
@@ -199,6 +199,7 @@ namespace __gnu_test
struct NoexceptMoveConsClass
{
NoexceptMoveConsClass(NoexceptMoveConsClass&&) noexcept(true);
+ NoexceptMoveConsClass& operator=(NoexceptMoveConsClass&&) = default;
};
struct ExceptMoveConsClass
@@ -220,6 +221,7 @@ namespace __gnu_test
struct NoexceptMoveAssignClass
{
+ NoexceptMoveAssignClass(NoexceptMoveAssignClass&&) = default;
NoexceptMoveAssignClass&
operator=(NoexceptMoveAssignClass&&) noexcept(true);
};