1a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify 2a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 3a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregorvoid print(); 4a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 5a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregortemplate<typename T, typename... Ts> 6a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregorvoid print(T first, Ts... rest) { 7a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor (void)first; 8a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor print(rest...); 9a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor} 10a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 11a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregortemplate<typename... Ts> 12a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregorvoid unsupported(Ts ...values) { 13a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor auto unsup = [values] {}; // expected-error{{unexpanded function parameter pack capture is unsupported}} 14a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor} 15a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 16a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregortemplate<typename... Ts> 17a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregorvoid implicit_capture(Ts ...values) { 18a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor auto implicit = [&] { print(values...); }; 19a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor implicit(); 20a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor} 21a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 22a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregortemplate<typename... Ts> 23a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregorvoid do_print(Ts... values) { 24a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor auto bycopy = [values...]() { print(values...); }; 25a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor bycopy(); 26a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor auto byref = [&values...]() { print(values...); }; 27a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor byref(); 28a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 29a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor auto bycopy2 = [=]() { print(values...); }; 30a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor bycopy2(); 31a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor auto byref2 = [&]() { print(values...); }; 32a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor byref2(); 33a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor} 34a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 35a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregortemplate void do_print(int, float, double); 36a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 37a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregortemplate<typename T, int... Values> 38a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregorvoid bogus_expansions(T x) { 39a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor auto l1 = [x...] {}; // expected-error{{pack expansion does not contain any unexpanded parameter packs}} 40a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor auto l2 = [Values...] {}; // expected-error{{'Values' in capture list does not name a variable}} 41a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor} 42a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 43a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregorvoid g(int*, float*, double*); 44a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 45a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregortemplate<class... Args> 46a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregorvoid std_example(Args... args) { 47a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor auto lm = [&, args...] { return g(args...); }; 48a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor}; 49a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 50a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregortemplate void std_example(int*, float*, double*); 51a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 52a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregortemplate<typename ...Args> 53a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregorvoid variadic_lambda(Args... args) { 54a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor auto lambda = [](Args... inner_args) { return g(inner_args...); }; 55a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor lambda(args...); 56a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor} 57a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregor 58a73652465bcc4c0f6cb7d933ad84e002b527a643Douglas Gregortemplate void variadic_lambda(int*, float*, double*); 59