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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 20 06:08:40 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();
----------------
AaronBallman wrote:

Should we be doing this for all qualifiers? `const` seems like it should almost certainly behave the same way, but I think it's a more general property of qualifiers that the derived to base cast would keep the qualifiers.

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


More information about the cfe-commits mailing list