Skip to content

Commit 9b060d1

Browse files
authored
[clang][bytecode] Fix zero-init of atomic floating point objects (#132782)
We can't pass the AtomicType along to ASTContext::getFloatTypeSemantics.
1 parent cb4ae35 commit 9b060d1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -4033,6 +4033,9 @@ template <class Emitter> bool Compiler<Emitter>::visitBool(const Expr *E) {
40334033
template <class Emitter>
40344034
bool Compiler<Emitter>::visitZeroInitializer(PrimType T, QualType QT,
40354035
const Expr *E) {
4036+
if (const auto *AT = QT->getAs<AtomicType>())
4037+
QT = AT->getValueType();
4038+
40364039
switch (T) {
40374040
case PT_Bool:
40384041
return this->emitZeroBool(E);

clang/test/AST/ByteCode/floats.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ namespace ZeroInit {
175175
static_assert(a.f == 0.0f, "");
176176

177177
constexpr A<double> b{12};
178-
static_assert(a.f == 0.0, "");
178+
static_assert(b.f == 0.0, "");
179+
180+
constexpr A<_Atomic(float)> c{12};
181+
static_assert(c.f == 0.0, "");
179182
};
180183

181184
namespace LongDouble {

0 commit comments

Comments
 (0)