Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -11109,8 +11109,16 @@ CaptureType, /*Expr*/ nullptr); } else if (C.capturesThis()) { + QualType ThisTy = CallOperator->getThisType(S.Context); + QualType BaseTy = ThisTy->getPointeeType(); + if (C.getCaptureKind() == LCK_StarThis && + CallOperator->isConst() && + !BaseTy.isConstQualified()) { + BaseTy.addConst(); + ThisTy = S.Context.getPointerType(BaseTy); + } LSI->addThisCapture(/*Nested*/ false, C.getLocation(), - S.getCurrentThisType(), /*Expr*/ nullptr, + ThisTy, /*Expr*/ nullptr, C.getCaptureKind() == LCK_StarThis); } else { LSI->addVLATypeCapture(C.getLocation(), I->getType());