Revert "Reland '[flang] Allow to pass an async id to allocate the descriptor (#118713...
[llvm-project.git] / clang / test / CXX / temp / temp.decls / temp.variadic / init-capture.cpp
blobb4e100a76a08132dc212a685f725cebfbce2548b
1 // RUN: %clang_cc1 -std=c++2a -verify %s
3 namespace p3 {
4 void bar(...);
5 template <typename... Args> void foo(Args... args) {
6 (void)[... xs = args] {
7 bar(xs...);
8 };
11 void use() {
12 foo();
13 foo(1);
17 template<typename ...T> void f(T ...t) {
18 (void)[&...x = t] {
19 x; // expected-error {{unexpanded parameter pack 'x'}}
22 // Not OK: can't expand 'x' outside its scope.
23 weird((void)[&...x = t] {
24 return &x; // expected-error {{unexpanded parameter pack 'x'}}
25 }... // expected-error {{does not contain any unexpanded}}
28 // OK, capture only one 'slice' of 'x'.
29 weird((void)[&x = t] {
30 return &x;
31 }...
34 // 'x' is not expanded by the outer '...', but 'T' is.
35 weird((void)[&... x = t] {
36 return T() + &x; // expected-error {{unexpanded parameter pack 'x'}}
37 }... // expected-error {{does not contain any unexpanded}}
41 template<int ...a> constexpr auto x = [...z = a] (auto F) { return F(z...); };
42 static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 123);
43 static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 124); // expected-error {{failed}} \
44 // expected-note {{evaluates to '123 == 124'}}
46 template<int ...a> constexpr auto y = [z = a...] (auto F) { return F(z...); }; // expected-error {{must appear before the name of the capture}}
47 static_assert(y<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 123);
48 static_assert(y<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 124); // expected-error {{failed}} \
49 // expected-note {{evaluates to '123 == 124'}}