aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-04-23 18:52:35 +0200
committerGitHub <noreply@github.com>2025-04-23 18:52:35 +0200
commit1b6cbaa7b64f54b127d139d653468e213bae007e (patch)
tree056125775fc6227d03bee4e84841b1e7fda2871e /clang/lib/AST/ByteCode/Compiler.cpp
parent83c309b90550aa768ff9aa11b70898ee2c56b71e (diff)
downloadllvm-1b6cbaa7b64f54b127d139d653468e213bae007e.zip
llvm-1b6cbaa7b64f54b127d139d653468e213bae007e.tar.gz
llvm-1b6cbaa7b64f54b127d139d653468e213bae007e.tar.bz2
[clang][bytecode] Refine diagnostics for volatile reads (#136857)
Differentiate between a volarile read via a lvalue-to-rvalue cast of a volatile qualified subexpression and a read from a pointer with a volatile base object.
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 7cba0e8..65d87cd 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -210,6 +210,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
switch (CE->getCastKind()) {
case CK_LValueToRValue: {
+ if (SubExpr->getType().isVolatileQualified())
+ return this->emitInvalidCast(CastKind::Volatile, /*Fatal=*/true, CE);
+
std::optional<PrimType> SubExprT = classify(SubExpr->getType());
// Prepare storage for the result.
if (!Initializing && !SubExprT) {