Author: Timm Baeder Date: 2026-01-05T16:41:50+01:00 New Revision: 787a476c922e13cf6a575c55e053c55041ad3a31
URL: https://github.com/llvm/llvm-project/commit/787a476c922e13cf6a575c55e053c55041ad3a31 DIFF: https://github.com/llvm/llvm-project/commit/787a476c922e13cf6a575c55e053c55041ad3a31.diff LOG: [clang][bytecode] Mark volatile composite locals as such (#174407) We were forgetting to pass the volatile-ness along. Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/test/AST/ByteCode/cxx23.cpp Removed: ################################################################################ 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
