diff mbox

[C++] Fix return deduction and ref-quals

Message ID 555E4528.6060506@acm.org
State New
Headers show

Commit Message

Nathan Sidwell May 21, 2015, 8:50 p.m. UTC
I've committed this obvious patch to fix PR 60943.  When deducing an auto return 
type we failed to propagate any reference qualification on the function type.

built & tested on x86_64-linux.

nathan
diff mbox

Patch

2015-05-21  Nathan Sidwell  <nathan@acm.org>

	cp/
	PR c++/60943
	* decl2.c (change_return_type): Propagate FUNCTION_REF_QUALIFIED.

	testsuite/
	* g++.dg/cpp1y/pr60943.C: New.

Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 223463)
+++ cp/decl2.c	(working copy)
@@ -195,6 +195,8 @@  change_return_type (tree new_ret, tree f
   else
     newtype = build_method_type_directly
       (class_of_this_parm (fntype), new_ret, TREE_CHAIN (args));
+  if (FUNCTION_REF_QUALIFIED (fntype))
+    newtype = build_ref_qualified_type (newtype, type_memfn_rqual (fntype));
   if (raises)
     newtype = build_exception_variant (newtype, raises);
   if (attrs)
Index: testsuite/g++.dg/cpp1y/pr60943.C
===================================================================
--- testsuite/g++.dg/cpp1y/pr60943.C	(revision 0)
+++ testsuite/g++.dg/cpp1y/pr60943.C	(working copy)
@@ -0,0 +1,16 @@ 
+// { dg-options "-std=c++14" }
+
+struct A {
+  auto f() & {}
+  auto f() && {}
+};
+
+void Foo (A &a)
+{
+  a.f();
+}
+
+void Bar (A &&a)
+{
+  a.f ();
+}