23 lines · cpp
1// RUN: %clang_cc1 -std=c++2a -verify %s2 3void no_capture() {4 auto x = [] {};5 decltype(x) y;6 x = x;7 x = static_cast<decltype(x)&&>(x);8}9 10void 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 17void 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