summaryrefslogtreecommitdiffstats
path: root/test/Parser/cxx0x-lambda-expressions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Parser/cxx0x-lambda-expressions.cpp')
-rw-r--r--test/Parser/cxx0x-lambda-expressions.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/Parser/cxx0x-lambda-expressions.cpp b/test/Parser/cxx0x-lambda-expressions.cpp
index 642c69a..289d03c 100644
--- a/test/Parser/cxx0x-lambda-expressions.cpp
+++ b/test/Parser/cxx0x-lambda-expressions.cpp
@@ -48,4 +48,20 @@ class C {
delete [] { return new int; } (); // expected-error{{expected expression}}
delete [&] { return new int; } (); // ok, lambda
}
+
+ // We support init-captures in C++11 as an extension.
+ int z;
+ void init_capture() {
+ [n(0)] () mutable -> int { return ++n; }; // expected-warning{{extension}}
+ [n{0}] { return; }; // expected-error {{<initializer_list>}} expected-warning{{extension}}
+ [n = 0] { return ++n; }; // expected-error {{captured by copy in a non-mutable}} expected-warning{{extension}}
+ [n = {0}] { return; }; // expected-error {{<initializer_list>}} expected-warning{{extension}}
+ [a([&b = z]{})](){}; // expected-warning 2{{extension}}
+
+ int x = 4;
+ auto y = [&r = x, x = x + 1]() -> int { // expected-warning 2{{extension}}
+ r += 2;
+ return x + 2;
+ } ();
+ }
};
OpenPOWER on IntegriCloud