+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
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);
}
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);
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. */
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);
}
--- /dev/null
+// 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);
+}