1 Star 0 Fork 14

ocs-bot/gcc

forked from OpenCloudOS Stream/gcc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
987e70f4290451abd98eda8b82e97b4ad25ee3c2.patch 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
ocs-bot 提交于 2024-08-06 16:59 . - Apply patches from rpm-tracker
From 987e70f4290451abd98eda8b82e97b4ad25ee3c2 Mon Sep 17 00:00:00 2001
From: Jonathan Wakely <[email protected]>
Date: Sun, 7 Jul 2024 12:22:42 +0100
Subject: [PATCH] libstdc++: Fix _Atomic(T) macro in <stdatomic.h> [PR115807]
The definition of the _Atomic(T) macro needs to refer to ::std::atomic,
not some other std::atomic relative to the current namespace.
libstdc++-v3/ChangeLog:
PR libstdc++/115807
* include/c_compatibility/stdatomic.h (_Atomic): Ensure it
refers to std::atomic in the global namespace.
* testsuite/29_atomics/headers/stdatomic.h/115807.cc: New test.
(cherry picked from commit 40d234dd6439e8c8cfbf3f375a61906aed35c80d)
---
libstdc++-v3/include/c_compatibility/stdatomic.h | 2 +-
.../29_atomics/headers/stdatomic.h/115807.cc | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
create mode 100644 libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/115807.cc
diff --git a/libstdc++-v3/include/c_compatibility/stdatomic.h b/libstdc++-v3/include/c_compatibility/stdatomic.h
index b565a1c1ab187..2bb23decf8d1e 100644
--- a/libstdc++-v3/include/c_compatibility/stdatomic.h
+++ b/libstdc++-v3/include/c_compatibility/stdatomic.h
@@ -34,7 +34,7 @@
#define __cpp_lib_stdatomic_h 202011L
-#define _Atomic(_Tp) std::atomic<_Tp>
+#define _Atomic(_Tp) ::std::atomic<_Tp>
using std::memory_order;
using std::memory_order_relaxed;
diff --git a/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/115807.cc b/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/115807.cc
new file mode 100644
index 0000000000000..14f320fe83575
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/115807.cc
@@ -0,0 +1,14 @@
+// { dg-do compile { target c++23 } }
+#include <stdatomic.h>
+namespace other {
+ namespace std {
+ int atomic = 0;
+ }
+ _Atomic(long) a{};
+}
+
+#include <type_traits>
+
+namespace non::std {
+ static_assert( ::std::is_same_v<_Atomic(int), ::std::atomic<int>> );
+}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ocs-bot/gcc.git
[email protected]:ocs-bot/gcc.git
ocs-bot
gcc
gcc
master

搜索帮助