[clang] [clang] Define ATOMIC_FLAG_INIT correctly for C++. (PR #97534)
Chris Copeland via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 3 00:37:14 PDT 2024
https://github.com/chrisnc updated https://github.com/llvm/llvm-project/pull/97534
>From b7857c25e56ea59956d8ae0aac068358bcf67a03 Mon Sep 17 00:00:00 2001
From: Chris Copeland <chris at chrisnc.net>
Date: Wed, 3 Jul 2024 00:11:39 -0700
Subject: [PATCH] [clang] Define ATOMIC_FLAG_INIT correctly for C++.
---
clang/docs/ReleaseNotes.rst | 2 ++
clang/lib/Headers/stdatomic.h | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1537eaaba0c66..3d85065a7ff8a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -750,6 +750,8 @@ Bug Fixes in This Version
- Fixed `static_cast` to array of unknown bound. Fixes (#GH62863).
+- Fixed the definition of ATOMIC_FLAG_INIT in stdatomic.h so it can be used in C++.
+
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Headers/stdatomic.h b/clang/lib/Headers/stdatomic.h
index 9c103d98af8c5..51a5d004e82d8 100644
--- a/clang/lib/Headers/stdatomic.h
+++ b/clang/lib/Headers/stdatomic.h
@@ -166,7 +166,11 @@ typedef _Atomic(uintmax_t) atomic_uintmax_t;
typedef struct atomic_flag { atomic_bool _Value; } atomic_flag;
+#ifdef __cplusplus
+#define ATOMIC_FLAG_INIT {false}
+#else
#define ATOMIC_FLAG_INIT { 0 }
+#endif
/* These should be provided by the libc implementation. */
#ifdef __cplusplus
More information about the cfe-commits
mailing list