[flang] Fix crash in HLFIR generation (#118399)
[llvm-project.git] / clang / test / CXX / expr / expr.prim / expr.prim.lambda / expr.prim.lambda.capture / p17.cpp
blobe2bd513aeffe8f7eb1c82b1200bdc70c586f541d
1 // RUN: %clang_cc1 -std=c++2a -verify %s
3 namespace std_example {
4 namespace std { template<typename T> T &&move(T &); }
6 void g(...);
8 template <class... Args> void f(Args... args) {
9 auto lm = [&, args...] { return g(args...); };
10 lm();
12 auto lm2 = [... xs = std::move(args)] { return g(xs...); };
13 lm2();
17 template<typename ...T> constexpr int f(int k, T ...t) {
18 auto a = [...v = t] (bool b) mutable {
19 if (!b) {
20 ((v += 1), ...);
21 return (__SIZE_TYPE__)0;
23 return (v * ... * 1) + sizeof...(v);
25 for (int i = 0; i != k; ++i)
26 a(false);
27 return a(true);
30 static_assert(f(1, 2, 3, 4) == 3 * 4 * 5 + 3);
31 static_assert(f(5) == 1);
33 auto q = [...x = 0] {}; // expected-error {{does not contain any unexpanded parameter packs}}
35 template<typename ...T> constexpr int nested(T ...t) {
36 return [...a = t] {
37 return [a...] {
38 return (a + ...);
39 }();
40 }();
42 static_assert(nested(1, 2, 3) == 6);