This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]