[PATCH] D33875: PR27037: Use correct CVR qualifier on an upcast on method pointer call

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 5 15:17:23 PDT 2017


rsmith added inline comments.


================
Comment at: lib/Sema/SemaExprCXX.cpp:5108
     QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
+    UseType = UseType.withCVRQualifiers(LHS.get()->getType().getCVRQualifiers());
     ExprValueKind VK = isIndirect ? VK_RValue : LHS.get()->getValueKind();
----------------
In the "indirect" case, the cv-qualifiers should be taken from the pointee type of the LHS and applied to the pointee type of UseType. I believe this patch will not be enough to cause us to reject the indirect version of your testcase:

```
  ((&b)->*&B::f)();  // expected-error{{drops 'const' qualifier}}
```

Moreover, we should be preserving all qualifiers, not just cvr-qualifiers; for example, this should also preserve the address space.


https://reviews.llvm.org/D33875





More information about the cfe-commits mailing list