================ @@ -8236,11 +8236,14 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, DeclContext *NewDC = D->getDeclContext(); if (FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) { - // Fields are not shadowed by variables in C++ static methods. - if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDC)) + if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDC)) { + // Fields are not shadowed by variables in C++ static methods. if (MD->isStatic()) return; + if (!MD->getParent()->isLambda() && MD->isExplicitObjectMemberFunction()) + return; ---------------- a-tarasyuk wrote:
@Sirraide Thanks for the feedback. I've added an additional test. > Maybe this also warrants a comment, because at first it wasn’t immediately > obvious to me why we’d want to ignore lambda call operators here. Thanks for bringing that to my attention. In such cases ```cpp struct C { int b = 5; int foo() { return [a = b]() { return [=, b = a]() { return b; }(); }(); } }; ``` depending exclusively on `isExplicitObjectMemberFunction` isn’t safe, as it could lead to assertion failures during type resolution https://github.com/llvm/llvm-project/blob/1a590870b6b3452934ecc245e01957fdab48909c/clang/lib/AST/Decl.cpp#L3699-L3702 There’s an option to restrict the null type or to validate the parent scope. I've been trying to find a suitable utility to do this, but I haven’t had any luck. If there’s one available, I’d appreciate it if you could point me to it. thanks https://github.com/llvm/llvm-project/pull/114813 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits