The fix for 80178 was broken, because I forgot that copy_fn_p is false
for move constructors.  As a result, the calling convention for a
class with a trivial move constructor and deleted copy constructor
changed inappropriately.

Tested x86_64-pc-linux-gnu, applying to trunk and 8.
commit d6cc7705f626778cb7e19fccf90117e7ed47d794
Author: Jason Merrill <ja...@redhat.com>
Date:   Mon Jun 11 12:14:27 2018 -0400

            PR c++/86094 - wrong code with defaulted move ctor.
    
            * tree.c (type_has_nontrivial_copy_init): Fix move ctor handling.

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;
+}

Reply via email to