Commit bd28a34f by Jason Merrill Committed by Jason Merrill

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

	PR c++/69842
	* method.c (forward_parm): Handle parameter packs.
	* lambda.c (maybe_add_lambda_conv_op): Use it for them.

From-SVN: r233719
parent 6a0cc1cd
2016-02-25 Jason Merrill <jason@redhat.com> 2016-02-25 Jason Merrill <jason@redhat.com>
PR c++/69842
* method.c (forward_parm): Handle parameter packs.
* lambda.c (maybe_add_lambda_conv_op): Use it for them.
PR c++/67364 PR c++/67364
* constexpr.c (cxx_eval_component_reference): Don't complain about * constexpr.c (cxx_eval_component_reference): Don't complain about
unevaluated empty classes. unevaluated empty classes.
......
...@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "cgraph.h" #include "cgraph.h"
#include "tree-iterator.h" #include "tree-iterator.h"
#include "toplev.h" #include "toplev.h"
#include "gimplify.h"
/* Constructor for a lambda expression. */ /* Constructor for a lambda expression. */
...@@ -952,23 +953,18 @@ maybe_add_lambda_conv_op (tree type) ...@@ -952,23 +953,18 @@ maybe_add_lambda_conv_op (tree type)
if (generic_lambda_p) if (generic_lambda_p)
{ {
if (DECL_PACK_P (tgt)) ++processing_template_decl;
{ tree a = forward_parm (tgt);
tree a = make_pack_expansion (tgt); --processing_template_decl;
if (decltype_call)
CALL_EXPR_ARG (decltype_call, ix) = copy_node (a); CALL_EXPR_ARG (call, ix) = a;
PACK_EXPANSION_LOCAL_P (a) = true; if (decltype_call)
CALL_EXPR_ARG (call, ix) = a; CALL_EXPR_ARG (decltype_call, ix) = unshare_expr (a);
}
else if (PACK_EXPANSION_P (a))
{ /* Set this after unsharing so it's not in decltype_call. */
++processing_template_decl; PACK_EXPANSION_LOCAL_P (a) = true;
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);
}
++ix; ++ix;
} }
else else
......
...@@ -481,9 +481,12 @@ tree ...@@ -481,9 +481,12 @@ tree
forward_parm (tree parm) forward_parm (tree parm)
{ {
tree exp = convert_from_reference (parm); tree exp = convert_from_reference (parm);
if (TREE_CODE (TREE_TYPE (parm)) != REFERENCE_TYPE tree type = TREE_TYPE (parm);
|| TYPE_REF_IS_RVALUE (TREE_TYPE (parm))) if (DECL_PACK_P (parm))
exp = move (exp); type = PACK_EXPANSION_PATTERN (type);
exp = build_static_cast (type, exp, tf_warning_or_error);
if (DECL_PACK_P (parm))
exp = make_pack_expansion (exp);
return exp; return exp;
} }
......
// PR c++/69842
// { dg-do compile { target c++14 } }
template <class T, class U> struct assert_same;
template <class T> struct assert_same<T,T> {};
template<typename T>
void sink(T &&)
{
assert_same<int,T> a;
}
int main()
{
auto const g([](auto &&... _var) {
sink(static_cast<decltype(_var)>(_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