From 46e318cff70c1adcb0895092975c72f41f82404c Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 11 Jun 2018 14:38:52 -0400 Subject: [PATCH] PR c++/86094 - wrong code with defaulted move ctor. * tree.c (type_has_nontrivial_copy_init): Fix move ctor handling. From-SVN: r261444 --- 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.30.2