[llvm-branch-commits] [clang] release/18.x: [Headers] Don't declare unreachable() from stddef.h in C++ (#86748) (PR #87696)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Apr 4 13:12:58 PDT 2024
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/87696
Backport df69a305253f1d1b4a4066055a07101a4cc03e55
Requested by: @ian-twilightcoder
>From b397b076cf69a6095fec1cc85c465fd65f0493da Mon Sep 17 00:00:00 2001
From: Ian Anderson <iana at apple.com>
Date: Thu, 4 Apr 2024 13:01:49 -0700
Subject: [PATCH] [Headers] Don't declare unreachable() from stddef.h in C++
(#86748)
Even if __need_unreachable is set, stddef.h should not declare
unreachable() in C++ because it conflicts with the declaration in
\<utility>.
(cherry picked from commit df69a305253f1d1b4a4066055a07101a4cc03e55)
---
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 llvm-branch-commits
mailing list