summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-neg.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-neg.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-neg.C19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-neg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-neg.C
new file mode 100644
index 000000000..7e7541ca2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-neg.C
@@ -0,0 +1,19 @@
+// { dg-options "-std=c++0x" }
+
+#include <cassert>
+
+template<typename F>
+void call(const F& f) { f(); }
+
+int main() {
+ call([] () -> void {});
+ call([] () mutable -> void {});
+
+ 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;
+}
+