aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-03-06 15:28:47 -0500
committerJason Merrill <jason@gcc.gnu.org>2019-03-06 15:28:47 -0500
commit2de5d0ea90d2e64ff3d345b17228043e08a5d1ac (patch)
tree01a86949dc25de23a741ff5c62c1ea411946c662
parent71b6cb2bbccba8922a8c7e9082a13a02dee7e57d (diff)
downloadgcc-2de5d0ea90d2e64ff3d345b17228043e08a5d1ac.zip
gcc-2de5d0ea90d2e64ff3d345b17228043e08a5d1ac.tar.gz
gcc-2de5d0ea90d2e64ff3d345b17228043e08a5d1ac.tar.bz2
PR c++/89381 - implicit copy and using-declaration.
Here the used base<int>::operator= gets into the list of foo's bindings for operator=, but it shouldn't make the copy ctor deleted. * class.c (classtype_has_move_assign_or_move_ctor_p): Don't consider op= brought in by a using-declaration. From-SVN: r269442
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/class.c4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/implicit16.C37
3 files changed, 46 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b0c1f88..0667dd7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-03-06 Jason Merrill <jason@redhat.com>
+
+ PR c++/89381 - implicit copy and using-declaration.
+ * class.c (classtype_has_move_assign_or_move_ctor_p): Don't consider
+ op= brought in by a using-declaration.
+
2019-03-06 Jakub Jelinek <jakub@redhat.com>
PR c++/87148
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 0d4d35b..a70a852 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5220,7 +5220,9 @@ classtype_has_move_assign_or_move_ctor_p (tree t, bool user_p)
for (ovl_iterator iter (get_class_binding_direct
(t, assign_op_identifier));
iter; ++iter)
- if ((!user_p || !DECL_ARTIFICIAL (*iter)) && move_fn_p (*iter))
+ if ((!user_p || !DECL_ARTIFICIAL (*iter))
+ && DECL_CONTEXT (*iter) == t
+ && move_fn_p (*iter))
return true;
return false;
diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit16.C b/gcc/testsuite/g++.dg/cpp0x/implicit16.C
new file mode 100644
index 0000000..229f2b4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/implicit16.C
@@ -0,0 +1,37 @@
+// PR c++/89381
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+struct base
+{
+ base() { }
+ base(const base&) { }
+ base(base&&) { }
+ base& operator=(const base&) { return *this; }
+ base& operator=(base&&) { return *this; }
+};
+
+struct foo : base<int>
+{
+ using base<int>::base;
+ using base<int>::operator=;
+};
+
+//using workaround = decltype(foo{*static_cast<foo const*>(0)});
+
+struct bar
+{
+ bar& operator=(foo ve)
+ {
+ value = ve;
+ return *this;
+ }
+
+ foo value;
+};
+
+int main()
+{
+ foo a;
+ foo b{a};
+}