https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/174407

We were forgetting to pass the volatile-ness along.

>From fb64e797c62d18b028e7b9902690f470bfa9e5d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Mon, 5 Jan 2026 15:10:45 +0100
Subject: [PATCH] [clang][bytecode] Mark volatile composite locals as such

We were forgetting to pass the volatile-ness along.
---
 clang/lib/AST/ByteCode/Compiler.cpp |  3 ++-
 clang/test/AST/ByteCode/cxx23.cpp   | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index f2021ef9456b7..b4449def1c6f0 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4673,7 +4673,8 @@ UnsignedOrNone Compiler<Emitter>::allocateLocal(DeclTy 
&&Src, QualType Ty,
 
   Descriptor *D = P.createDescriptor(
       Src, Ty.getTypePtr(), Descriptor::InlineDescMD, Ty.isConstQualified(),
-      IsTemporary, /*IsMutable=*/false, /*IsVolatile=*/false, Init);
+      IsTemporary, /*IsMutable=*/false, 
/*IsVolatile=*/Ty.isVolatileQualified(),
+      Init);
   if (!D)
     return std::nullopt;
   D->IsConstexprUnknown = IsConstexprUnknown;
diff --git a/clang/test/AST/ByteCode/cxx23.cpp 
b/clang/test/AST/ByteCode/cxx23.cpp
index 819460628c1b7..2a8b061d7671a 100644
--- a/clang/test/AST/ByteCode/cxx23.cpp
+++ b/clang/test/AST/ByteCode/cxx23.cpp
@@ -450,6 +450,20 @@ namespace VolatileWrites {
                             // all-note {{in call to}}
 }
 
+namespace VolatileReads {
+  constexpr int test1(bool b) {
+    if (!b)
+      return -1;
+    struct C {
+      int a;
+    };
+    volatile C c{12}; // all-note {{volatile object declared here}}
+    return ((C&)(c)).a; // all-note {{read of volatile object}}
+  }
+  static_assert(test1(true) == 0); // all-error {{not an integral constant 
expression}} \
+                                   // all-note {{in call to}}
+}
+
 namespace AIEWithIndex0Narrows {
   template <class _Tp> struct greater {
     constexpr void operator()(_Tp, _Tp) {}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to