18e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify 28e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor 38e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor 48e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregorstruct X { 5999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor X(const X&) = delete; // expected-note 2{{explicitly marked deleted}} 68e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor X(X&); 78e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor}; 88e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor 98e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregorvoid test_capture(X x) { 108e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor [x] { }(); // okay: non-const copy ctor 118e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor 128e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor [x] { 13999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor [x] { // expected-error{{call to deleted constructor of 'X'}} 14999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor }(); 15999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor }(); 16999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor 17999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor [x] { 18999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor [&x] { 19999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor [x] { // expected-error{{call to deleted constructor of 'const X'}} 20999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor }(); 218e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor }(); 228e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor }(); 2368932845a432d2a1dbbc57a84fd85bbb37c90487Douglas Gregor 2468932845a432d2a1dbbc57a84fd85bbb37c90487Douglas Gregor int a; 25999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor [=]{ 26999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor [&] { 27999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor int &x = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}} 28999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor int &x2 = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}} 29999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor }(); 30999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor }(); 31999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor 32999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor [=]{ 33999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor [&a] { 34999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor [&] { 35999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor int &x = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}} 36999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor int &x2 = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}} 37999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor }(); 38999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor }(); 39999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor }(); 408e9314fd846936ce04b92b2b72c6aba2cffab916Douglas Gregor} 41