diff options
author | Sergei Trofimovich <slyfox@gentoo.org> | 2021-05-28 23:19:31 +0100 |
---|---|---|
committer | Sergei Trofimovich <slyfox@gentoo.org> | 2021-05-28 23:19:31 +0100 |
commit | f3f23b533c01b783dc53023f9b9f8fe343b151dc (patch) | |
tree | ffbc821394a90e4181798288063167f128b717c7 | |
parent | 11.1.0: backport PR100489: union constructor fix (diff) | |
download | gcc-patches-f3f23b53.tar.gz gcc-patches-f3f23b53.tar.bz2 gcc-patches-f3f23b53.zip |
11.1.0: backport PR100644: c++: "perfect" implicitly deleted move
Reported-by: Thomas Deutschmann
Bug: https://bugs.gentoo.org/792705
Bug: https://gcc.gnu.org/PR100644
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
-rw-r--r-- | 11.1.0/gentoo/29_all_perfect-implicit-PR100644.patch | 69 | ||||
-rw-r--r-- | 11.1.0/gentoo/README.history | 1 |
2 files changed, 70 insertions, 0 deletions
diff --git a/11.1.0/gentoo/29_all_perfect-implicit-PR100644.patch b/11.1.0/gentoo/29_all_perfect-implicit-PR100644.patch new file mode 100644 index 0000000..35ee13d --- /dev/null +++ b/11.1.0/gentoo/29_all_perfect-implicit-PR100644.patch @@ -0,0 +1,69 @@ +https://gcc.gnu.org/PR100644 +https://bugs.gentoo.org/792705 + +From 6384e940a6db379b0524465cf6cbbd0996b48485 Mon Sep 17 00:00:00 2001 +From: Jason Merrill <jason@redhat.com> +Date: Tue, 18 May 2021 12:06:36 -0400 +Subject: [PATCH] c++: "perfect" implicitly deleted move [PR100644] + +Here we were ignoring the template constructor because the implicit move +constructor had all perfect conversions. But CWG1402 says that an +implicitly deleted move constructor is ignored by overload resolution; we +implement that instead by preferring any other candidate in joust, to get +better diagnostics, but that means we need to handle that case here as well. + +gcc/cp/ChangeLog: + + PR c++/100644 + * call.c (perfect_candidate_p): An implicitly deleted move + is not perfect. + +gcc/testsuite/ChangeLog: + + * g++.dg/cpp0x/implicit-delete1.C: New test. +--- + gcc/cp/call.c | 5 +++++ + gcc/testsuite/g++.dg/cpp0x/implicit-delete1.C | 20 +++++++++++++++++++ + 2 files changed, 25 insertions(+) + create mode 100644 gcc/testsuite/g++.dg/cpp0x/implicit-delete1.C + +--- a/gcc/cp/call.c ++++ b/gcc/cp/call.c +@@ -5892,6 +5892,11 @@ perfect_candidate_p (z_candidate *cand) + { + if (cand->viable < 1) + return false; ++ /* CWG1402 makes an implicitly deleted move op worse than other ++ candidates. */ ++ if (DECL_DELETED_FN (cand->fn) && DECL_DEFAULTED_FN (cand->fn) ++ && move_fn_p (cand->fn)) ++ return false; + int len = cand->num_convs; + for (int i = 0; i < len; ++i) + if (!perfect_conversion_p (cand->convs[i])) +--- /dev/null ++++ b/gcc/testsuite/g++.dg/cpp0x/implicit-delete1.C +@@ -0,0 +1,20 @@ ++// PR c++/100644 ++// { dg-do compile { target c++11 } } ++ ++struct NonMovable { ++ NonMovable(NonMovable&&) = delete; ++}; ++ ++template <class T> ++struct Maybe { ++ NonMovable mMember; ++ ++ template <typename U> ++ Maybe(Maybe<U>&&); ++}; ++ ++void foo(Maybe<int>); ++ ++void unlucky(Maybe<int>&& x) { ++ Maybe<int> var{(Maybe<int>&&)x}; ++} +-- +2.31.1 + diff --git a/11.1.0/gentoo/README.history b/11.1.0/gentoo/README.history index 27dd8ff..00f2ee7 100644 --- a/11.1.0/gentoo/README.history +++ b/11.1.0/gentoo/README.history @@ -1,6 +1,7 @@ 2 TODO + 27_all_msp430-f2c.patch + 28_all_ctor-union-PR100489.patch + + 29_all_perfect-implicit-PR100644.patch 1 27 Apr 2021 + 01_all_default-fortify-source.patch |