P0806R2 Implicit capture of this with a capture-default of [=] is
deprecated.
Add a -Wdeprecated warning for this in C++2a onwards. (In C++17 and
before, there isn't a reasonable alternative because [=,this] is
ill-formed.)
llvm-svn: 336480
diff --git a/clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp b/clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp
index ce69163..652fb8d 100644
--- a/clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp
+++ b/clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -verify %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -std=c++2a -verify %s -Wdeprecated
// This test does two things.
// Deleting the copy constructor ensures that an [=, this] capture doesn't copy the object.
@@ -13,3 +12,12 @@
L();
}
};
+
+struct B {
+ int i;
+ void f() {
+ (void) [=] { // expected-note {{add an explicit capture of 'this'}}
+ return i; // expected-warning {{implicit capture of 'this' with a capture default of '=' is deprecated}}
+ };
+ }
+};