summaryrefslogtreecommitdiff
path: root/test/SemaCXX/cxx2a-lambda-equals-this.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/cxx2a-lambda-equals-this.cpp')
-rw-r--r--test/SemaCXX/cxx2a-lambda-equals-this.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/SemaCXX/cxx2a-lambda-equals-this.cpp b/test/SemaCXX/cxx2a-lambda-equals-this.cpp
new file mode 100644
index 000000000000..ce6916322e5d
--- /dev/null
+++ b/test/SemaCXX/cxx2a-lambda-equals-this.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+// expected-no-diagnostics
+
+// This test does two things.
+// Deleting the copy constructor ensures that an [=, this] capture doesn't copy the object.
+// Accessing a member variable from the lambda ensures that the capture actually works.
+class A {
+ A(const A &) = delete;
+ int i;
+
+ void func() {
+ auto L = [=, this]() -> int { return i; };
+ L();
+ }
+};