================ @@ -13299,7 +13293,18 @@ static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E) { // The declaration must be a variable which is not declared 'const'. VarDecl *var = dyn_cast<VarDecl>(DRE->getDecl()); - if (!var) return NCCK_None; + if (!var) { + // Bindings also can be captured by lambda in C++ + BindingDecl *binding = dyn_cast<BindingDecl>(DRE->getDecl()); + if (!binding || binding->getType().isConstQualified()) + return NCCK_None; + + assert(S.getLangOpts().CPlusPlus && "BindingDecl outside of C++?"); + assert(!isa<BlockDecl>(binding->getDeclContext())); ---------------- cor3ntin wrote:
I would prefer you move the whole code _before_ the cast to Var (L13293) Alternatively, first cast to ValueDecl, deal with the common const-qualified case, then cast to Var https://github.com/llvm/llvm-project/pull/120849 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits