[clang] 9b060d1 - [clang][bytecode] Fix zero-init of atomic floating point objects (#132782)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 25 00:05:08 PDT 2025
Author: Timm Baeder
Date: 2025-03-25T08:05:04+01:00
New Revision: 9b060d1e6aea15fb486a94798fedd88188269c92
URL: https://github.com/llvm/llvm-project/commit/9b060d1e6aea15fb486a94798fedd88188269c92
DIFF: https://github.com/llvm/llvm-project/commit/9b060d1e6aea15fb486a94798fedd88188269c92.diff
LOG: [clang][bytecode] Fix zero-init of atomic floating point objects (#132782)
We can't pass the AtomicType along to ASTContext::getFloatTypeSemantics.
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/floats.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 943e4302a0398..5242a524308a8 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4033,6 +4033,9 @@ template <class Emitter> bool Compiler<Emitter>::visitBool(const Expr *E) {
template <class Emitter>
bool Compiler<Emitter>::visitZeroInitializer(PrimType T, QualType QT,
const Expr *E) {
+ if (const auto *AT = QT->getAs<AtomicType>())
+ QT = AT->getValueType();
+
switch (T) {
case PT_Bool:
return this->emitZeroBool(E);
diff --git a/clang/test/AST/ByteCode/floats.cpp b/clang/test/AST/ByteCode/floats.cpp
index 45c31c759e47f..930921d0eee1f 100644
--- a/clang/test/AST/ByteCode/floats.cpp
+++ b/clang/test/AST/ByteCode/floats.cpp
@@ -175,7 +175,10 @@ namespace ZeroInit {
static_assert(a.f == 0.0f, "");
constexpr A<double> b{12};
- static_assert(a.f == 0.0, "");
+ static_assert(b.f == 0.0, "");
+
+ constexpr A<_Atomic(float)> c{12};
+ static_assert(c.f == 0.0, "");
};
namespace LongDouble {
More information about the cfe-commits
mailing list