diff mbox series

[committed] libstdc++: Guard tr2::bases and tr2::direct_bases with __has_builtin

Message ID 20240208160109.2697643-1-jwakely@redhat.com
State New
Headers show
Series [committed] libstdc++: Guard tr2::bases and tr2::direct_bases with __has_builtin | expand

Commit Message

Jonathan Wakely Feb. 8, 2024, 4 p.m. UTC
Tested x86_64-linux. Pusued to trunk. I'll backport it too.

-- >8 --

These non-standard extensions use GCC-specific built-ins. Use
__has_builtin to avoid errors when Clang compiles this header.

See https://github.com/llvm/llvm-project/issues/24289

libstdc++-v3/ChangeLog:

	* include/tr2/type_traits (bases, direct_bases): Use
	__has_builtin to check if required built-ins are supported.
---
 libstdc++-v3/include/tr2/type_traits | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jonathan Wakely Feb. 8, 2024, 5:05 p.m. UTC | #1
On Thu, 8 Feb 2024 at 16:02, Jonathan Wakely wrote:

> Tested x86_64-linux. Pusued to trunk. I'll backport it too.
>

Only to gcc-13 though, because __has_builtin(__bases) is false for gcc-12.
diff mbox series

Patch

diff --git a/libstdc++-v3/include/tr2/type_traits b/libstdc++-v3/include/tr2/type_traits
index a7ebaf66947..603039de894 100644
--- a/libstdc++-v3/include/tr2/type_traits
+++ b/libstdc++-v3/include/tr2/type_traits
@@ -82,20 +82,23 @@  namespace tr2
   /// Sequence abstraction metafunctions for manipulating a typelist.
 
 
-
+#if __has_builtin(__bases)
   /// Enumerate all the base classes of a class. Form of a typelist.
   template<typename _Tp>
     struct bases
     {
       typedef __reflection_typelist<__bases(_Tp)...>		type;
     };
+#endif
 
+#if __has_builtin(__direct_bases)
   /// Enumerate all the direct base classes of a class. Form of a typelist.
   template<typename _Tp>
     struct direct_bases
     {
       typedef __reflection_typelist<__direct_bases(_Tp)...>	type;
     };
+#endif
 
   /// @} group metaprogramming
 }