================
@@ -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()));
----------------
TilakChad wrote:

I've added the commit based on your suggestion. 
Thank you for the review. :smile:  

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

Reply via email to