126f4b32fSDouglas Gregor // RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++11 %s 2db0b9f12SDouglas Gregor 3*bfdb108fSRichard Smith enum E { e }; 4*bfdb108fSRichard Smith 5db0b9f12SDouglas Gregor class C { 6db0b9f12SDouglas Gregor 7db0b9f12SDouglas Gregor int f() { 8db0b9f12SDouglas Gregor int foo, bar; 9db0b9f12SDouglas Gregor 10db0b9f12SDouglas Gregor []; // expected-error {{expected body of lambda expression}} 11db0b9f12SDouglas Gregor [+] {}; // expected-error {{expected variable name or 'this' in lambda capture list}} 12db0b9f12SDouglas Gregor [foo+] {}; // expected-error {{expected ',' or ']' in lambda capture list}} 13db0b9f12SDouglas Gregor [foo,&this] {}; // expected-error {{'this' cannot be captured by reference}} 14db0b9f12SDouglas Gregor [&this] {}; // expected-error {{'this' cannot be captured by reference}} 15db0b9f12SDouglas Gregor [&,] {}; // expected-error {{expected variable name or 'this' in lambda capture list}} 16db0b9f12SDouglas Gregor [=,] {}; // expected-error {{expected variable name or 'this' in lambda capture list}} 17656bc62aSDouglas Gregor [] {}; 18656bc62aSDouglas Gregor [=] (int i) {}; 19656bc62aSDouglas Gregor [&] (int) mutable -> void {}; 20656bc62aSDouglas Gregor [foo,bar] () { return 3; }; 21656bc62aSDouglas Gregor [=,&foo] () {}; 22656bc62aSDouglas Gregor [&,foo] () {}; 23656bc62aSDouglas Gregor [this] () {}; 24*bfdb108fSRichard Smith [] () -> class C { return C(); }; 25*bfdb108fSRichard Smith [] () -> enum E { return e; }; 26db0b9f12SDouglas Gregor 276746c5d4SDouglas Gregor [] -> int { return 0; }; // expected-error{{lambda requires '()' before return type}} 286746c5d4SDouglas Gregor [] mutable -> int { return 0; }; // expected-error{{lambda requires '()' before 'mutable'}} 29db0b9f12SDouglas Gregor return 1; 30db0b9f12SDouglas Gregor } 31db0b9f12SDouglas Gregor 32a80cae11SDouglas Gregor void designator_or_lambda() { 33a80cae11SDouglas Gregor typedef int T; 34a80cae11SDouglas Gregor const int b = 0; 35a80cae11SDouglas Gregor const int c = 1; 36a80cae11SDouglas Gregor int a1[1] = {[b] (T()) {}}; // expected-error{{no viable conversion from 'C::<lambda}} 37a80cae11SDouglas Gregor int a2[1] = {[b] = 1 }; 38a80cae11SDouglas Gregor int a3[1] = {[b,c] = 1 }; // expected-error{{expected body of lambda expression}} 39a80cae11SDouglas Gregor int a4[1] = {[&b] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'const int *'}} 40a80cae11SDouglas Gregor int a5[3] = { []{return 0;}() }; 41a80cae11SDouglas Gregor int a6[1] = {[this] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'C *'}} 42a80cae11SDouglas Gregor } 43db0b9f12SDouglas Gregor }; 44