This revision was automatically updated to reflect the committed changes. Closed by commit rGecd0be100bed: [clang] Warn by default that implicit capture of 'this' is deprecated in C++20… (authored by tahonermann).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D142639/new/ https://reviews.llvm.org/D142639 Files: clang/docs/ReleaseNotes.rst clang/include/clang/Basic/DiagnosticSemaKinds.td clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp clang/test/SemaCXX/lambda-implicit-this-capture.cpp Index: clang/test/SemaCXX/lambda-implicit-this-capture.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/lambda-implicit-this-capture.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -std=c++11 -verify=cxx11 %s +// RUN: %clang_cc1 -std=c++2a -verify=cxx2a %s +// RUN: %clang_cc1 -std=c++2a -verify=cxx2a-no-deprecated %s -Wno-deprecated +// cxx11-no-diagnostics +// cxx2a-no-deprecated-no-diagnostics + +struct A { + int i; + void f() { + (void) [=] { // cxx2a-note {{add an explicit capture of 'this'}} + return i; // cxx2a-warning {{implicit capture of 'this' with a capture default of '=' is deprecated}} + }; + } +}; Index: clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp =================================================================== --- clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp +++ clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -std=c++2a -verify %s -Wdeprecated +// 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. @@ -12,12 +13,3 @@ 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}} - }; - } -}; Index: clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp =================================================================== --- clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp +++ clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -emit-llvm-only %s -// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only -fblocks -emit-llvm-only %s +// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only -fblocks -emit-llvm-only -Wno-deprecated-this-capture %s // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -emit-llvm-only -triple i386-windows-pc %s -// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only -fblocks -emit-llvm-only -triple i386-windows-pc %s +// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only -fblocks -emit-llvm-only -triple i386-windows-pc -Wno-deprecated-this-capture %s // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fms-extensions %s -DMS_EXTENSIONS // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -7906,7 +7906,7 @@ "is a C++20 extension">, InGroup<CXX20>; def warn_deprecated_this_capture : Warning< "implicit capture of 'this' with a capture default of '=' is deprecated">, - InGroup<DeprecatedThisCapture>, DefaultIgnore; + InGroup<DeprecatedThisCapture>; def note_deprecated_this_capture : Note< "add an explicit capture of 'this' to capture '*this' by reference">; Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -70,6 +70,9 @@ - We now generate a diagnostic for signed integer overflow due to unary minus in a non-constant expression context. This fixes `Issue 31643 <https://github.com/llvm/llvm-project/issues/31643>`_ +- Clang now warns by default for C++20 and later about deprecated capture of + ``this`` with a capture default of ``=``. This warning can be disabled with + ``-Wno-deprecated-this-capture``. Non-comprehensive list of changes in this release -------------------------------------------------
Index: clang/test/SemaCXX/lambda-implicit-this-capture.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/lambda-implicit-this-capture.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -std=c++11 -verify=cxx11 %s +// RUN: %clang_cc1 -std=c++2a -verify=cxx2a %s +// RUN: %clang_cc1 -std=c++2a -verify=cxx2a-no-deprecated %s -Wno-deprecated +// cxx11-no-diagnostics +// cxx2a-no-deprecated-no-diagnostics + +struct A { + int i; + void f() { + (void) [=] { // cxx2a-note {{add an explicit capture of 'this'}} + return i; // cxx2a-warning {{implicit capture of 'this' with a capture default of '=' is deprecated}} + }; + } +}; Index: clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp =================================================================== --- clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp +++ clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -std=c++2a -verify %s -Wdeprecated +// 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. @@ -12,12 +13,3 @@ 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}} - }; - } -}; Index: clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp =================================================================== --- clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp +++ clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -emit-llvm-only %s -// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only -fblocks -emit-llvm-only %s +// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only -fblocks -emit-llvm-only -Wno-deprecated-this-capture %s // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -emit-llvm-only -triple i386-windows-pc %s -// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only -fblocks -emit-llvm-only -triple i386-windows-pc %s +// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only -fblocks -emit-llvm-only -triple i386-windows-pc -Wno-deprecated-this-capture %s // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fms-extensions %s -DMS_EXTENSIONS // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -7906,7 +7906,7 @@ "is a C++20 extension">, InGroup<CXX20>; def warn_deprecated_this_capture : Warning< "implicit capture of 'this' with a capture default of '=' is deprecated">, - InGroup<DeprecatedThisCapture>, DefaultIgnore; + InGroup<DeprecatedThisCapture>; def note_deprecated_this_capture : Note< "add an explicit capture of 'this' to capture '*this' by reference">; Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -70,6 +70,9 @@ - We now generate a diagnostic for signed integer overflow due to unary minus in a non-constant expression context. This fixes `Issue 31643 <https://github.com/llvm/llvm-project/issues/31643>`_ +- Clang now warns by default for C++20 and later about deprecated capture of + ``this`` with a capture default of ``=``. This warning can be disabled with + ``-Wno-deprecated-this-capture``. Non-comprehensive list of changes in this release -------------------------------------------------
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits