From 1b6cbaa7b64f54b127d139d653468e213bae007e Mon Sep 17 00:00:00 2001 From: Timm Baeder Date: Wed, 23 Apr 2025 18:52:35 +0200 Subject: [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. --- clang/lib/AST/ByteCode/Compiler.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang/lib/AST/ByteCode/Compiler.cpp') 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::VisitCastExpr(const CastExpr *CE) { switch (CE->getCastKind()) { case CK_LValueToRValue: { + if (SubExpr->getType().isVolatileQualified()) + return this->emitInvalidCast(CastKind::Volatile, /*Fatal=*/true, CE); + std::optional SubExprT = classify(SubExpr->getType()); // Prepare storage for the result. if (!Initializing && !SubExprT) { -- cgit v1.1