c++: capture folding and lvalueness checking [PR125408]

Here after the recursive mark_rvalue_use we end up with a VAR_DECL in r, so
the assert fails.  But in that case r is still an lvalue, so we don't need
to do any adjustment.

Fixed by adjusting the condition to detect the case we actually need to fix
up, i.e. when ref is an lvalue and r is not.  The previous !rvalue_p
condition doesn't make much sense; rvalue_p indicates whether we want to do
an lvalue-rvalue conversion on expr, not whether expr was already an rvalue.

The error_mark_node handling comes from r17-607-gefb9667e2fb81d.

	PR c++/125408

gcc/cp/ChangeLog:

	* expr.cc (mark_use): Fix condition for changing rvalue to lvalue.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-targ34.C: New test.

(cherry picked from commit 4073a7927b1644f5b56b83f04f92e81b31f6517b)
2 files changed