1 // RUN: %clang_cc1 -std=c++1y %s -verify -emit-llvm-only
3 namespace variadic_expansion {
4 int f(int &, char &) { return 0; }
5 template<class ... Ts> char fv(Ts ... ts) { return 0; }
6 // FIXME: why do we get 2 error messages
7 template <typename ... T> void g(T &... t) { //expected-note3{{declared here}}
8 f([&a(t)]()->decltype(auto) {
12 auto L = [x = f([&a(t)]()->decltype(auto) { return a; }()...)]() { return x; };
15 &z = y](T& ... t) { };
18 o = f([&a(t)](T& ... t)->decltype(auto) { return a; }(t...)...), t...](T& ... s) {
19 fv([&a(t)]()->decltype(auto) {
23 auto N2 = [x = y, //expected-note3{{begins here}}
25 o = f([&a(t)](T& ... t)->decltype(auto) { return a; }(t...)...)](T& ... s) {
26 fv([&a(t)]()->decltype(auto) { //expected-error 3{{captured}}
33 void h(int i, char c) { g(i, c); } //expected-note{{in instantiation}}
36 namespace odr_use_within_init_capture {
42 auto L = [z = x + 2](int a) {
43 auto M = [y = x - 2](char b) {
50 { // should not capture
52 auto L = [&z = x](int a) {
59 auto L = [k = x](char a) { //expected-note {{declared}}
60 return [](int b) { //expected-note {{begins}}
61 return [j = k](int c) { //expected-error {{cannot be implicitly captured}}
69 auto L = [k = x](char a) {
71 return [j = k](int c) {
79 auto L = [k = x](char a) {
81 return [j = k](int c) {
95 namespace odr_use_within_init_capture_template {
97 template<class T = int>
102 auto L = [z = x](char a) {
103 auto M = [y = x](T b) {
110 { // should not capture
112 auto L = [&z = x](T a) {
117 { // will need to capture x in outer lambda
118 const T x = 10; //expected-note {{declared}}
119 auto L = [z = x](char a) { //expected-note {{begins}}
120 auto M = [&y = x](T b) { //expected-error {{cannot be implicitly captured}}
127 { // will need to capture x in outer lambda
129 auto L = [=,z = x](char a) {
130 auto M = [&y = x](T b) {
137 { // will need to capture x in outer lambda
139 auto L = [x, z = x](char a) {
140 auto M = [&y = x](T b) {
146 { // will need to capture x in outer lambda
147 const int x = 10; //expected-note 2{{declared}}
148 auto L = [z = x](char a) { //expected-note 2{{begins}}
149 auto M = [&y = x](T b) { //expected-error 2{{cannot be implicitly captured}}
159 [z = x, &y = x](char a) { return z + y; }('a')](char a)
167 int run = test(); //expected-note {{instantiation}}