2018-09-28 06:47:04 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++2a -verify %s
|
|
|
|
|
2019-07-09 07:24:41 +08:00
|
|
|
void no_capture() {
|
|
|
|
auto x = [] {};
|
|
|
|
decltype(x) y;
|
|
|
|
x = x;
|
|
|
|
x = static_cast<decltype(x)&&>(x);
|
2018-09-28 06:47:04 +08:00
|
|
|
}
|
|
|
|
|
2019-07-09 07:24:41 +08:00
|
|
|
void capture_default(int i) {
|
|
|
|
auto x = [=] {}; // expected-note 2{{candidate constructor}} expected-note 2{{lambda expression begins here}}
|
|
|
|
decltype(x) y; // expected-error {{no matching constructor}}
|
|
|
|
x = x; // expected-error {{cannot be assigned}}
|
|
|
|
x = static_cast<decltype(x)&&>(x); // expected-error {{cannot be assigned}}
|
2018-09-28 06:47:04 +08:00
|
|
|
}
|
|
|
|
|
2019-07-09 07:24:41 +08:00
|
|
|
void explicit_capture(int i) {
|
|
|
|
auto x = [i] {}; // expected-note 2{{candidate constructor}} expected-note 2{{lambda expression begins here}}
|
|
|
|
decltype(x) y; // expected-error {{no matching constructor}}
|
|
|
|
x = x; // expected-error {{cannot be assigned}}
|
|
|
|
x = static_cast<decltype(x)&&>(x); // expected-error {{cannot be assigned}}
|
2018-09-28 06:47:04 +08:00
|
|
|
}
|