summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const.C20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const.C
new file mode 100644
index 000000000..5f6f0b3dc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const.C
@@ -0,0 +1,20 @@
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+#include <cassert>
+
+template<typename F>
+void call(const F& f) { f(); }
+
+int main() {
+ call([] () -> void {});
+ //call([] () mutable -> void {}); // { dg-error: "`f' does not have const `operator()'" }
+
+ int i = -1;
+ call([&i] () -> void { i = 0; });
+ assert(i == 0);
+ //call([i] () -> void { i = 0; }); // { dg-error: "assignment to non-reference capture in const lambda" }
+
+ return 0;
+}
+