[libcxx-commits] [clang-tools-extra] [compiler-rt] [llvm] [libc] [libcxx] [flang] [clang] [clang] Avoid -Wshadow warning when init-capture named same as class field (PR #74512)
Mariya Podchishchaeva via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 6 04:13:40 PST 2023
================
@@ -8395,10 +8395,11 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
unsigned WarningDiag = diag::warn_decl_shadow;
SourceLocation CaptureLoc;
- if (isa<VarDecl>(D) && isa<VarDecl>(ShadowedDecl) && NewDC &&
- isa<CXXMethodDecl>(NewDC)) {
+ if (isa<VarDecl>(D) && NewDC && isa<CXXMethodDecl>(NewDC)) {
if (const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->getParent())) {
if (RD->isLambda() && OldDC->Encloses(NewDC->getLexicalParent())) {
+ if (!isa<VarDecl>(ShadowedDecl))
----------------
Fznamznon wrote:
You mean add a comment saying that it is a case when an init-capture references class field?
https://github.com/llvm/llvm-project/pull/74512
More information about the libcxx-commits
mailing list