1 // RUN: %clang_cc1 -std=c++2a -verify %s
2
no_capture()3 void no_capture() {
4 auto x = [] {};
5 decltype(x) y;
6 x = x;
7 x = static_cast<decltype(x)&&>(x);
8 }
9
capture_default(int i)10 void capture_default(int i) {
11 auto x = [=] {}; // expected-note 2{{candidate constructor}} expected-note 2{{lambda expression begins here}}
12 decltype(x) y; // expected-error {{no matching constructor}}
13 x = x; // expected-error {{cannot be assigned}}
14 x = static_cast<decltype(x)&&>(x); // expected-error {{cannot be assigned}}
15 }
16
explicit_capture(int i)17 void explicit_capture(int i) {
18 auto x = [i] {}; // expected-note 2{{candidate constructor}} expected-note 2{{lambda expression begins here}}
19 decltype(x) y; // expected-error {{no matching constructor}}
20 x = x; // expected-error {{cannot be assigned}}
21 x = static_cast<decltype(x)&&>(x); // expected-error {{cannot be assigned}}
22 }
23