mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 18:46:40 +00:00

Previously, a warning that C++20 deprecated implicit capture of 'this' for lambda captures specified with a capture default of '=' was only issued when '-Wdeprecated' or '-Wdeprecated-this-capture' was specified. This change enables the warning by default (it is still only issued when compiling for C++20 or later). This is consistent with gcc which warns by default (MSVC requires '/Wall'). Reviewed By: erichkeane, shafik Differential Revision: https://reviews.llvm.org/D142639
16 lines
403 B
C++
16 lines
403 B
C++
// 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();
|
|
}
|
|
};
|