2013-07-09 Jason Merrill <jason@redhat.com>
+ PR c++/57437
+ * typeck.c (check_return_expr): Lambda proxies aren't eligible
+ for nrv or return by move.
+
PR c++/57532
* parser.c (cp_parser_ref_qualifier_opt): Don't tentatively parse
a ref-qualifier in C++98 mode.
&& VAR_P (retval)
&& DECL_CONTEXT (retval) == current_function_decl
&& ! TREE_STATIC (retval)
- && ! DECL_ANON_UNION_VAR_P (retval)
+ /* And not a lambda or anonymous union proxy. */
+ && !DECL_HAS_VALUE_EXPR_P (retval)
&& (DECL_ALIGN (retval) <= DECL_ALIGN (result))
/* The cv-unqualified type of the returned value must be the
same as the cv-unqualified return type of the
Note that these conditions are similar to, but not as strict as,
the conditions for the named return value optimization. */
if ((cxx_dialect != cxx98)
- && (VAR_P (retval)
+ && ((VAR_P (retval) && !DECL_HAS_VALUE_EXPR_P (retval))
|| TREE_CODE (retval) == PARM_DECL)
&& DECL_CONTEXT (retval) == current_function_decl
&& !TREE_STATIC (retval)
--- /dev/null
+// PR c++/57437
+// { dg-require-effective-target c++11 }
+
+struct A {
+ int i;
+
+ A(): i(42) {}
+ A(const A&) = default;
+ A(A&& a): i(a.i) { a.i = 0; }
+};
+
+int main()
+{
+ A x;
+
+ auto y = [x] () mutable {
+ x.i++;
+ return x;
+ };
+
+ if (y().i != 43)
+ __builtin_abort ();
+
+ if (y().i != 44)
+ __builtin_abort ();
+}