aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/expr/expr.prim/expr.prim.lambda
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-10 17:46:20 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-10 17:46:20 +0000
commit3ac109cd17151bb8ad3a40b0cbb0e1923cd6c4a0 (patch)
tree914a4d80e3d45b83bfcf9045f4ceb45b9125dae3 /test/CXX/expr/expr.prim/expr.prim.lambda
parent67b2c554dc12f589471713b7b01e9c94257ae593 (diff)
Allow implicit capture of 'this' in a lambda even when the capture
default is '=', and reword the warning about explicitly capturing 'this' in such lambdas to indicate that only explicit capture is banned. Introduce Fix-Its for this and other "save the programmer from themself" rules regarding what can be explicitly captured and what must be implicitly captured. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150256 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/expr/expr.prim/expr.prim.lambda')
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
index b897d5f10a..d1384f19dd 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
@@ -8,18 +8,22 @@ class X0 {
(void)[this, this] () {}; // expected-error {{'this' can appear only once}}
(void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}}
(void)[=, &foo] () {};
- (void)[=, this] () {}; // expected-error {{'this' cannot appear}}
+ (void)[=, this] () {}; // expected-error {{'this' cannot be explicitly captured}}
(void)[&, foo] () {};
(void)[&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}}
(void)[&, this] () {};
}
};
-struct S2 { void f(int i); };
+struct S2 {
+ void f(int i);
+ void g(int i);
+};
void S2::f(int i) {
(void)[&, i]{ };
(void)[&, &i]{ }; // expected-error{{'&' cannot precede a capture when the capture default is '&'}}
- (void)[=, this]{ }; // expected-error{{'this' cannot appear in a capture list when the capture default is '='}}
+ (void)[=, this]{ }; // expected-error{{'this' cannot be explicitly captured}}
+ (void)[=]{ this->g(i); };
(void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
}