Commit 532c679e by Jason Merrill Committed by Jason Merrill

Core 1148

	Core 1148
	* typeck.c (check_return_expr): Fix conditions for setting
	LOOKUP_PREFER_RVALUE.

From-SVN: r171071
parent e676810e
2011-03-16 Jason Merrill <jason@redhat.com> 2011-03-16 Jason Merrill <jason@redhat.com>
Core 1148
* typeck.c (check_return_expr): Fix conditions for setting
LOOKUP_PREFER_RVALUE.
* call.c (build_over_call): Remove require_complete_type_sfinae call. * call.c (build_over_call): Remove require_complete_type_sfinae call.
PR c++/48132 PR c++/48132
......
...@@ -7760,12 +7760,19 @@ check_return_expr (tree retval, bool *no_warning) ...@@ -7760,12 +7760,19 @@ check_return_expr (tree retval, bool *no_warning)
/* Under C++0x [12.8/16 class.copy], a returned lvalue is sometimes /* Under C++0x [12.8/16 class.copy], a returned lvalue is sometimes
treated as an rvalue for the purposes of overload resolution to treated as an rvalue for the purposes of overload resolution to
favor move constructors over copy constructors. */ favor move constructors over copy constructors.
if ((cxx_dialect != cxx98)
&& named_return_value_okay_p Note that these conditions are similar to, but not as strict as,
/* The variable must not have the `volatile' qualifier. */ the conditions for the named return value optimization. */
&& !CP_TYPE_VOLATILE_P (TREE_TYPE (retval)) if ((cxx_dialect != cxx98)
/* The return type must be a class type. */ && (TREE_CODE (retval) == VAR_DECL
|| 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
(TREE_TYPE (TREE_TYPE (current_function_decl)))))
/* This is only interesting for class type. */
&& CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl)))) && CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
flags = flags | LOOKUP_PREFER_RVALUE; flags = flags | LOOKUP_PREFER_RVALUE;
......
2011-03-16 Jason Merrill <jason@redhat.com> 2011-03-16 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/elision2.C: New.
* g++.dg/cpp0x/constexpr-array3.C: New. * g++.dg/cpp0x/constexpr-array3.C: New.
2011-03-16 Jason Merrill <jason@redhat.com> 2011-03-16 Jason Merrill <jason@redhat.com>
......
// Core 1148: should be able to move from value parameter on return
// { dg-options -std=c++0x }
struct A
{
A(const A&) = delete;
A(A&&);
};
A f (A a)
{
return a;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment