From dfe8601ce70a97d09e08e14e0ebd0f2ef4608d0f Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 18 Jun 2011 01:58:38 -0400 Subject: [PATCH] re PR c++/49458 ([C++0x][DR 1328] Obvious candidate for conversion to function lvalue rejected) PR c++/49458 * call.c (convert_class_to_reference_1): Allow binding function lvalue to rvalue reference. From-SVN: r175164 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/call.c | 2 ++ gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/rv-func2.C | 10 ++++++++++ 4 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/rv-func2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f3fca847a08..3217c8ffb20 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-06-17 Jason Merrill + PR c++/49458 + * call.c (convert_class_to_reference_1): Allow binding function + lvalue to rvalue reference. + PR c++/43912 Generate proxy VAR_DECLs for better lambda debug info. * cp-tree.h (FUNCTION_NEEDS_BODY_BLOCK): Add lambda operator(). diff --git a/gcc/cp/call.c b/gcc/cp/call.c index b43d078dedd..05bf983f558 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1362,6 +1362,8 @@ convert_class_to_reference_1 (tree reference_type, tree s, tree expr, int flags) /* Don't allow binding of lvalues to rvalue references. */ if (TYPE_REF_IS_RVALUE (reference_type) + /* Function lvalues are OK, though. */ + && TREE_CODE (TREE_TYPE (reference_type)) != FUNCTION_TYPE && !TYPE_REF_IS_RVALUE (TREE_TYPE (TREE_TYPE (cand->fn)))) cand->second_conv->bad_p = true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 805c5b178f1..d7826412ad8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-06-17 Jason Merrill + * g++.dg/cpp0x/rv-func2.C: New. + * g++.dg/debug/dwarf2/lambda1.C: New. * g++.dg/warn/Wshadow-6.C: Adjust. diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-func2.C b/gcc/testsuite/g++.dg/cpp0x/rv-func2.C new file mode 100644 index 00000000000..b792342dada --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-func2.C @@ -0,0 +1,10 @@ +// PR c++/49458 +// { dg-options -std=c++0x } + +typedef void ftype(); + +struct A { + operator ftype&(void); +}; + +ftype &&frvref = A(); -- 2.30.2