8sa1-gcc/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic2.C
Jason Merrill 2993d08a0f Core DR 904 PR c++/41933
Core DR 904
	PR c++/41933
	* parser.c (cp_parser_lambda_introducer): Handle variadic capture.
	* lambda.c (add_capture): Handle variadic capture.
	(add_default_capture, lambda_capture_field_type): Likewise.
	(build_capture_proxy, register_capture_members): Likewise.
	* pt.c (register_specialization): Allow FIELD_DECL.
	(retrieve_specialization): Likewise.
	(find_parameter_packs_r): Handle FIELD_DECL and VAR_DECL.
	(tsubst_pack_expansion): Handle FIELD_DECL packs.
	(gen_elem_of_pack_expansion_instantiation): Likewise.
	(instantiate_class_template_1): Likewise.
	(tsubst_decl, tsubst_copy): Likewise.
	(tsubst_expr) [DECL_EXPR]: Handle capture proxy packs.
	(tsubst_copy_and_build) [VAR_DECL]: Likewise.
	* semantics.c (finish_non_static_data_member): Don't try to represent
	the type of a COMPOUND_REF of a FIELD_DECL pack.

From-SVN: r202605
2013-09-15 15:34:42 -04:00

58 lines
851 B
C

// { dg-do run { target c++11 } }
int g() { return 0; }
template <class T, class... U>
int g(T t, U... u)
{
return t + g(u...);
}
template <class... T>
int f1(T... t)
{
return [t...] {
return g(t...);
}();
}
template <class... T>
int f2(T... t)
{
return [&t...] {
return g(t...);
}();
}
template <class... T>
int f3(T... t)
{
return [=] {
return g(t...);
}();
}
template <class... T>
int f4(T... t)
{
return [&] {
return g(t...);
}();
}
#define assert(E) do { if (!(E)) __builtin_abort(); } while(0)
int main()
{
assert (f1() == 0);
assert (f2() == 0);
assert (f3() == 0);
assert (f4() == 0);
assert (f1(42) == 42);
assert (f2(42) == 42);
assert (f3(42) == 42);
assert (f4(42) == 42);
assert (f1(1,2,3) == 6);
assert (f2(1,2,3) == 6);
assert (f3(1,2,3) == 6);
assert (f4(1,2,3) == 6);
}