[clang][Sema] Propagate qualifiers during derived-to-base conversion by antoniofrighetto · Pull Request #127824 · llvm/llvm-project (original) (raw)

@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Antonio Frighetto (antoniofrighetto)

Changes

A miscompilation issue has been addressed with improved handling.

Fixes: #127683.


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

2 Files Affected:

diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 191912ca7d800..3bba142f2b96e 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -5403,8 +5403,12 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { // TODO: Support accesses to members of base classes in TBAA. For now, we // conservatively pretend that the complete object is of the base class // type.

} case CK_ToUnion: return EmitAggExprToLValue(E); diff --git a/clang/test/CodeGenCXX/derived-to-base.cpp b/clang/test/CodeGenCXX/derived-to-base.cpp index c8dbd5bf5cb05..37a8e6f7ea6b6 100644 --- a/clang/test/CodeGenCXX/derived-to-base.cpp +++ b/clang/test/CodeGenCXX/derived-to-base.cpp @@ -46,4 +46,23 @@ namespace test3 { } }

+// Ensure volatile is preserved during derived-to-base conversion. +namespace PR127683 { + +struct Base {