Commit 0f02dd56 by Jason Merrill Committed by Jason Merrill

re PR c++/69842 (Parameter deduction in polymorphic lambdas)

	PR c++/69842
	* method.c (forward_parm): Split out from...
	(add_one_base_init): ...here.
	* lambda.c (maybe_add_lambda_conv_op): Use it.

From-SVN: r233506
parent 9bfcbdee
2016-02-17 Jason Merrill <jason@redhat.com>
PR c++/69842
* method.c (forward_parm): Split out from...
(add_one_base_init): ...here.
* lambda.c (maybe_add_lambda_conv_op): Use it.
2016-02-16 Jason Merrill <jason@redhat.com>
PR c++/10200
......
......@@ -6013,6 +6013,7 @@ extern tree make_thunk (tree, bool, tree, tree);
extern void finish_thunk (tree);
extern void use_thunk (tree, bool);
extern bool trivial_fn_p (tree);
extern tree forward_parm (tree);
extern bool is_trivially_xible (enum tree_code, tree, tree);
extern tree get_defaulted_eh_spec (tree);
extern tree unevaluated_noexcept_spec (void);
......
......@@ -962,7 +962,9 @@ maybe_add_lambda_conv_op (tree type)
}
else
{
tree a = convert_from_reference (tgt);
++processing_template_decl;
tree a = forward_parm (tgt);
--processing_template_decl;
CALL_EXPR_ARG (call, ix) = a;
if (decltype_call)
CALL_EXPR_ARG (decltype_call, ix) = copy_node (a);
......
......@@ -474,6 +474,19 @@ trivial_fn_p (tree fn)
return type_has_trivial_fn (DECL_CONTEXT (fn), special_function_p (fn));
}
/* PARM is a PARM_DECL for a function which we want to forward to another
function without changing its value category, a la std::forward. */
tree
forward_parm (tree parm)
{
tree exp = convert_from_reference (parm);
if (TREE_CODE (TREE_TYPE (parm)) != REFERENCE_TYPE
|| TYPE_REF_IS_RVALUE (TREE_TYPE (parm)))
exp = move (exp);
return exp;
}
/* Subroutine of do_build_copy_constructor: Add a mem-initializer for BINFO
given the parameter or parameters PARM, possibly inherited constructor
base INH, or move flag MOVE_P. */
......@@ -494,10 +507,7 @@ add_one_base_init (tree binfo, tree parm, bool move_p, tree inh,
init = NULL_TREE;
for (; parm; parm = DECL_CHAIN (parm))
{
tree exp = convert_from_reference (parm);
if (TREE_CODE (TREE_TYPE (parm)) != REFERENCE_TYPE
|| TYPE_REF_IS_RVALUE (TREE_TYPE (parm)))
exp = move (exp);
tree exp = forward_parm (parm);
*p = build_tree_list (NULL_TREE, exp);
p = &TREE_CHAIN (*p);
}
......
// PR c++/69842
// { dg-do compile { target c++14 } }
template <class T, class U> struct same;
template <class T> struct same<T,T> {};
int main()
{
auto g = [](auto && _var) {
same<int&&,decltype(_var)>();
};
g(0);
}
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