1 // RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-but-set-variable -Wno-unused-lambda-capture -verify
9 static void static_foo() {
10 (void)[this](){}; // expected-error{{'this' cannot be captured in this context}}
28 static void static_bar() {
29 (void)[this](){}; // expected-error{{'this' cannot be captured in this context}}
30 (void)[&](){i
= 7; }; // expected-error{{invalid use of member 'i' in static member function}}
36 void immediately_enclosing(int i
) { // expected-note{{'i' declared here}}
45 []() { // expected-note{{lambda expression begins here}} expected-note 2 {{capture 'i' by}} expected-note 2 {{default capture by}}
46 [i
] {}(); // expected-error{{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
50 void f1(int i
) { // expected-note{{declared here}}
64 void work(int n
) { // expected-note{{declared here}}
66 int j
= 40; // expected-note{{declared here}}
67 auto m3
= [this, m
] { // expected-note 3{{lambda expression begins here}} expected-note 2 {{capture 'i' by}} expected-note 2 {{capture 'j' by}} expected-note 2 {{capture 'n' by}}
68 auto m4
= [&,j
] { // expected-error{{variable 'j' cannot be implicitly captured in a lambda with no capture-default specified}}
69 int x
= n
; // expected-error{{variable 'n' cannot be implicitly captured in a lambda with no capture-default specified}}
71 x
+= i
; // expected-error{{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}