Commit b24290fb by Jason Merrill Committed by Jason Merrill

PR c++/48457, Core 1238

	PR c++/48457, Core 1238
	* call.c (reference_binding): Allow rvalue reference to bind to
	function lvalue.
	* tree.c (lvalue_kind): Functions are always lvalues.

From-SVN: r172282
parent 1e6d1da0
2011-04-11 Jason Merrill <jason@redhat.com>
PR c++/48457, Core 1238
* call.c (reference_binding): Allow rvalue reference to bind to
function lvalue.
* tree.c (lvalue_kind): Functions are always lvalues.
2011-04-07 Jason Merrill <jason@redhat.com> 2011-04-07 Jason Merrill <jason@redhat.com>
PR c++/48500 PR c++/48500
......
...@@ -1521,8 +1521,10 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags) ...@@ -1521,8 +1521,10 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
actually occurs. */ actually occurs. */
conv->need_temporary_p = true; conv->need_temporary_p = true;
/* Don't allow binding of lvalues to rvalue references. */ /* Don't allow binding of lvalues (other than function lvalues) to
rvalue references. */
if (is_lvalue && TYPE_REF_IS_RVALUE (rto) if (is_lvalue && TYPE_REF_IS_RVALUE (rto)
&& TREE_CODE (to) != FUNCTION_TYPE
&& !(flags & LOOKUP_PREFER_RVALUE)) && !(flags & LOOKUP_PREFER_RVALUE))
conv->bad_p = true; conv->bad_p = true;
......
...@@ -73,7 +73,9 @@ lvalue_kind (const_tree ref) ...@@ -73,7 +73,9 @@ lvalue_kind (const_tree ref)
if (TYPE_REF_IS_RVALUE (TREE_TYPE (ref)) if (TYPE_REF_IS_RVALUE (TREE_TYPE (ref))
&& TREE_CODE (ref) != PARM_DECL && TREE_CODE (ref) != PARM_DECL
&& TREE_CODE (ref) != VAR_DECL && TREE_CODE (ref) != VAR_DECL
&& TREE_CODE (ref) != COMPONENT_REF) && TREE_CODE (ref) != COMPONENT_REF
/* Functions are always lvalues. */
&& TREE_CODE (TREE_TYPE (TREE_TYPE (ref))) != FUNCTION_TYPE)
return clk_rvalueref; return clk_rvalueref;
/* lvalue references and named rvalue references are lvalues. */ /* lvalue references and named rvalue references are lvalues. */
......
2011-04-11 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/rv-func.C: New.
2011-04-11 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2011-04-11 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/torture/pr47917.c: Define _ISO_C_SOURCE=19990L for * gcc.dg/torture/pr47917.c: Define _ISO_C_SOURCE=19990L for
......
// PR c++/48457, Core 1238
// { dg-options -std=c++0x }
template<class T>
T&& create();
template<class T, class Arg>
void test() {
T t(create<Arg>());
(void) t;
}
void f (void (&)());
void f (void (&&)());
int main() {
test<void(&)(), void()>();
test<void(&&)(), void()>();
// This call should choose the lvalue reference overload.
// { dg-final { scan-assembler-not "_Z1fOFvvE" } }
f(create<void()>());
}
2011-04-08 Jason Merrill <jason@redhat.com>
* testsuite/20_util/is_convertible/value.cc: Adjust.
2011-04-11 Paolo Carlini <paolo.carlini@oracle.com> 2011-04-11 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/25_algorithms/inplace_merge/moveable.cc: Actually run * testsuite/25_algorithms/inplace_merge/moveable.cc: Actually run
......
...@@ -93,7 +93,7 @@ void test01() ...@@ -93,7 +93,7 @@ void test01()
const volatile int&>(false)) ); const volatile int&>(false)) );
VERIFY( (test_relationship<is_convertible, volatile int, VERIFY( (test_relationship<is_convertible, volatile int,
volatile int&>(false)) ); volatile int&>(false)) );
VERIFY( (test_relationship<is_convertible, int(int), int(&)(int)>(false)) ); VERIFY( (test_relationship<is_convertible, int(int), int(&)(int)>(true)) );
VERIFY( (test_relationship<is_convertible, int&, ExplicitClass>(false)) ); VERIFY( (test_relationship<is_convertible, int&, ExplicitClass>(false)) );
VERIFY( (test_relationship<is_convertible, void*, ExplicitClass>(false)) ); VERIFY( (test_relationship<is_convertible, void*, ExplicitClass>(false)) );
......
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