[clang] [clang][Sema] Propagate qualifiers during derived-to-base conversion (PR #127824)

Antonio Frighetto via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 22 08:06:42 PST 2025


================
@@ -3107,8 +3107,11 @@ Sema::PerformObjectMemberConversion(Expr *From,
                                    /*IgnoreAccess=*/true))
     return ExprError();
 
-  return ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase,
-                           VK, &BasePath);
+  if (FromType.isVolatileQualified())
+    DestType.addVolatile();
----------------
antoniofrighetto wrote:

EDIT: Moving from:
```cpp
DestType = Context.getQualifiedType(DestType, FromType.getQualifiers());
```
To CVR ones for now:
```cpp
DestType.withCVRQualifiers(FromType.getCVRQualifiers());
```
Per CI failure [here](https://buildkite.com/llvm-project/github-pull-requests/builds/149797#01952e46-e199-450d-978b-2f763cd9b9c0), due to incompatibility between address spaces. Not completely sure if we should setAddressSpace of DestType AS one to the one of FromType, before getQualifiedType.

https://github.com/llvm/llvm-project/pull/127824


More information about the cfe-commits mailing list