[clang] [Headers] Don't declare unreachable() from stddef.h in C++ (PR #86748)

Ian Anderson via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 26 17:25:57 PDT 2024


https://github.com/ian-twilightcoder updated https://github.com/llvm/llvm-project/pull/86748

>From e67c757c7cdd1837008e573295e87e3ebec5382d Mon Sep 17 00:00:00 2001
From: Ian Anderson <iana at apple.com>
Date: Tue, 26 Mar 2024 16:19:38 -0700
Subject: [PATCH] [Headers] Don't declare unreachable() from stddef.h in C++

Even if __need_unreachable is set, stddef.h should not declare unreachable() in C++ because it conflicts with the declaration in <utility>.
---
 clang/lib/Headers/__stddef_unreachable.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/Headers/__stddef_unreachable.h b/clang/lib/Headers/__stddef_unreachable.h
index 518580c92d3f5d..61df43e9732f8a 100644
--- a/clang/lib/Headers/__stddef_unreachable.h
+++ b/clang/lib/Headers/__stddef_unreachable.h
@@ -7,6 +7,8 @@
  *===-----------------------------------------------------------------------===
  */
 
+#ifndef __cplusplus
+
 /*
  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  * and needs to behave as if it was textual.
@@ -15,3 +17,5 @@
     (__has_feature(modules) && !__building_module(_Builtin_stddef))
 #define unreachable() __builtin_unreachable()
 #endif
+
+#endif



More information about the cfe-commits mailing list