From 6651a52f7f4f542d0717cce50ecdba040b1f5982 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 11 Jun 2018 18:38:52 +0000 Subject: [PATCH] PR c++/86094 - wrong code with defaulted move ctor. * tree.c (type_has_nontrivial_copy_init): Fix move ctor handling. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@261444 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/tree.c | 2 +- gcc/testsuite/g++.dg/abi/invisiref2.C | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/abi/invisiref2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bdf717f82fb..595a08f3d44 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-06-11 Jason Merrill + + PR c++/86094 - wrong code with defaulted move ctor. + * tree.c (type_has_nontrivial_copy_init): Fix move ctor handling. + 2018-06-10 Paolo Carlini * decl.c (grokfndecl): Use the location_t argument in two more places. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index bbbda7e98b6..156d1e469c6 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -4135,7 +4135,7 @@ type_has_nontrivial_copy_init (const_tree type) for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) { tree fn = *iter; - if (copy_fn_p (fn)) + if (copy_fn_p (fn) || move_fn_p (fn)) { saw_copy = true; if (!DECL_DELETED_FN (fn)) diff --git a/gcc/testsuite/g++.dg/abi/invisiref2.C b/gcc/testsuite/g++.dg/abi/invisiref2.C new file mode 100644 index 00000000000..592d212ab11 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/invisiref2.C @@ -0,0 +1,14 @@ +// PR c++/86094 +// { dg-do compile { target c++11 } } +// { dg-additional-options "-Wabi=11 -fdump-tree-gimple" } +// { dg-final { scan-tree-dump-not "struct S &" "gimple" } } + +struct S { + S(S&&) = default; + int i; +}; + +S foo(S s) +{ + return s; +} -- 2.11.4.GIT