]> gcc.gnu.org Git - gcc.git/commitdiff
DR 1579 PR c++/58051
authorJonathan Wakely <jwakely@redhat.com>
Sat, 28 Jun 2014 07:45:27 +0000 (08:45 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Sat, 28 Jun 2014 07:45:27 +0000 (08:45 +0100)
gcc/cp:
DR 1579
PR c++/58051
* typeck.c (check_return_expr): Lookup as an rvalue even when the
types aren't the same.

gcc/testsuite:
* g++.dg/cpp0x/elision_conv.C: New.

From-SVN: r212099

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/elision_conv.C [new file with mode: 0644]

index 2236a5c948a427255943994c5dd5c0f6114db8e8..c7a0ccbfedb5778ef0e4a0424848ae3cd50d36b2 100644 (file)
@@ -1,3 +1,10 @@
+2014-06-28  Jonathan Wakely  <jwakely@redhat.com>
+
+       DR 1579
+       PR c++/58051
+       * typeck.c (check_return_expr): Lookup as an rvalue even when the
+       types aren't the same.
+
 2014-06-27  Jason Merrill  <jason@redhat.com>
 
        PR c++/61433
index 65dccf7a1b3514d105043be93a7561d5bc42162f..042e600e33f306625516809a26d453948e6132c7 100644 (file)
@@ -8607,7 +8607,7 @@ check_return_expr (tree retval, bool *no_warning)
       if (VOID_TYPE_P (functype))
        return error_mark_node;
 
-      /* Under C++0x [12.8/16 class.copy], a returned lvalue is sometimes
+      /* Under C++11 [12.8/32 class.copy], a returned lvalue is sometimes
         treated as an rvalue for the purposes of overload resolution to
         favor move constructors over copy constructors.
 
@@ -8618,8 +8618,6 @@ check_return_expr (tree retval, bool *no_warning)
              || TREE_CODE (retval) == PARM_DECL)
          && DECL_CONTEXT (retval) == current_function_decl
          && !TREE_STATIC (retval)
-         && same_type_p ((TYPE_MAIN_VARIANT (TREE_TYPE (retval))),
-                         (TYPE_MAIN_VARIANT (functype)))
          /* This is only interesting for class type.  */
          && CLASS_TYPE_P (functype))
        flags = flags | LOOKUP_PREFER_RVALUE;
index c7d90e6cadb7c58472eaa303861b0e2b6024e1e8..df79f3bc88b0fd79c446f84f1cf503fe1e51e8b2 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-28  Jonathan Wakely  <jwakely@redhat.com>
+
+       * g++.dg/cpp0x/elision_conv.C: New.
+
 2014-06-27  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        * gfortran.dg/nint_2.f90: Don't XFAIL for powerpc64le-*-linux*.
diff --git a/gcc/testsuite/g++.dg/cpp0x/elision_conv.C b/gcc/testsuite/g++.dg/cpp0x/elision_conv.C
new file mode 100644 (file)
index 0000000..d778a0b
--- /dev/null
@@ -0,0 +1,18 @@
+// Core 1579 return by converting move constructor
+// PR c++/58051
+// { dg-do compile { target c++11 } }
+
+struct A {
+  A() = default;
+  A(A&&) = default;
+};
+
+struct B {
+  B(A) { }
+};
+
+B f()
+{
+  A a;
+  return a;
+}
This page took 0.105894 seconds and 5 git commands to generate.