2012-02-09 09:02:27 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++11 %s
|
2011-08-04 23:30:47 +08:00
|
|
|
|
|
|
|
class C {
|
|
|
|
|
|
|
|
int f() {
|
|
|
|
int foo, bar;
|
|
|
|
|
|
|
|
[]; // expected-error {{expected body of lambda expression}}
|
|
|
|
[+] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
|
|
|
|
[foo+] {}; // expected-error {{expected ',' or ']' in lambda capture list}}
|
|
|
|
[foo,&this] {}; // expected-error {{'this' cannot be captured by reference}}
|
|
|
|
[&this] {}; // expected-error {{'this' cannot be captured by reference}}
|
2011-12-15 08:38:15 +08:00
|
|
|
[&,] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
|
|
|
|
[=,] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
|
2012-02-09 16:26:42 +08:00
|
|
|
[] {};
|
|
|
|
[=] (int i) {};
|
|
|
|
[&] (int) mutable -> void {};
|
|
|
|
[foo,bar] () { return 3; };
|
|
|
|
[=,&foo] () {};
|
|
|
|
[&,foo] () {};
|
|
|
|
[this] () {};
|
2011-08-04 23:30:47 +08:00
|
|
|
|
2012-02-17 05:53:36 +08:00
|
|
|
[] -> int { return 0; }; // expected-error{{lambda requires '()' before return type}}
|
|
|
|
[] mutable -> int { return 0; }; // expected-error{{lambda requires '()' before 'mutable'}}
|
2011-08-04 23:30:47 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|