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

We can't pass the AtomicType along to ASTContext::getFloatTypeSemantics.

>From 88ce8a55d9e8fea57ff71989f6a5cd2fe9b505ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com>
Date: Mon, 24 Mar 2025 18:13:03 +0100
Subject: [PATCH] [clang][bytecode] Fix zero-init of atomic floating point
 objects

We can't pass the AtomicType along to ASTContext::getFloatTypeSemantics.
---
 clang/lib/AST/ByteCode/Compiler.cpp | 3 +++
 clang/test/AST/ByteCode/floats.cpp  | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

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 {

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to