auto C = CurLSI->getCXXThisCapture();
if (C.isCopyCapture()) {
- ClassType.removeLocalCVRQualifiers(Qualifiers::CVRMask);
if (!CurLSI->Mutable)
ClassType.addConst();
return ASTCtx.getPointerType(ClassType);
while (Closure &&
IsThisCaptured(Closure, IsByCopyCapture, IsConstCapture)) {
if (IsByCopyCapture) {
- ClassType.removeLocalCVRQualifiers(Qualifiers::CVRMask);
if (IsConstCapture)
ClassType.addConst();
return ASTCtx.getPointerType(ClassType);
// The type of the corresponding data member (not a 'this' pointer if 'by
// copy').
- QualType CaptureType = ThisTy;
- if (ByCopy) {
- // If we are capturing the object referred to by '*this' by copy, ignore
- // any cv qualifiers inherited from the type of the member function for
- // the type of the closure-type's corresponding data member and any use
- // of 'this'.
- CaptureType = ThisTy->getPointeeType();
- CaptureType.removeLocalCVRQualifiers(Qualifiers::CVRMask);
- }
+ QualType CaptureType = ByCopy ? ThisTy->getPointeeType() : ThisTy;
bool isNested = NumCapturingClosures > 1;
CSI->addThisCapture(isNested, Loc, CaptureType, ByCopy);
void foo() const { //expected-note{{const}}
auto L = [*this]() mutable {
- static_assert(is_same<decltype(this), X *>);
- ++d;
+ static_assert(is_same<decltype(this), const X *>);
auto M = [this] {
- static_assert(is_same<decltype(this), X *>);
- ++d;
+ static_assert(is_same<decltype(this), const X *>);
auto N = [] {
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const X *>);
};
};
};
};
};
auto M2 = [*this]() mutable {
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const X *>);
auto N = [] {
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const X *>);
};
};
};
};
auto M2 = [*this](auto a) mutable {
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const X *>);
auto N = [](auto b) {
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const X *>);
};
return N;
};
++d; //expected-error{{cannot assign}}
};
auto GL = [*this](auto a) mutable {
- static_assert(is_same<decltype(this), X *>);
- ++d;
+ static_assert(is_same<decltype(this), const X *>);
auto M = [this](auto b) {
- static_assert(is_same<decltype(this), X *>);
- ++d;
+ static_assert(is_same<decltype(this), const X *>);
auto N = [](auto c) {
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const X *>);
};
N(3.14);
};
auto L = [this]() {
static_assert(is_same<decltype(this), const volatile X *>);
auto M = [*this]() mutable {
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const volatile X *>);
auto N = [this] {
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const volatile X *>);
auto M = [] {
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const volatile X *>);
};
};
auto N2 = [*this] {
- static_assert(is_same<decltype(this), const X *>);
+ static_assert(is_same<decltype(this), const volatile X *>);
};
};
auto M2 = [*this]() {
- static_assert(is_same<decltype(this), const X *>);
+ static_assert(is_same<decltype(this), const volatile X *>);
auto N = [this] {
- static_assert(is_same<decltype(this), const X *>);
+ static_assert(is_same<decltype(this), const volatile X *>);
};
};
};
auto L = [*this]() mutable {
auto M = [=](auto a) {
auto N = [this] {
- ++d;
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const X *>);
auto O = [*this] {
static_assert(is_same<decltype(this), const X *>);
};
};
N();
- static_assert(is_same<decltype(this), X *>);
+ static_assert(is_same<decltype(this), const X *>);
};
return M;
};
z(id,3);
}
} // namespace PR45881
+
+
+namespace GH50866 {
+struct S;
+
+void f(S *) = delete; // expected-note {{would lose const qualifier}}
+void f(const S *) = delete; // expected-note {{candidate function has been explicitly deleted}}
+
+struct S {
+ void g() const {
+ [*this]() mutable { f(this); }(); // expected-error {{call to deleted function}}
+ }
+};
+
+void g() {
+ S s{};
+ s.g();
+}
+}