Skip to content

Commit

Permalink
libstdc++: Guard tr2::bases and tr2::direct_bases with __has_builtin
Browse files Browse the repository at this point in the history
These non-standard extensions use GCC-specific built-ins. Use
__has_builtin to avoid errors when Clang compiles this header.

See llvm/llvm-project#24289

libstdc++-v3/ChangeLog:

	* include/tr2/type_traits (bases, direct_bases): Use
	__has_builtin to check if required built-ins are supported.
  • Loading branch information
jwakely committed Feb 8, 2024
1 parent d945912 commit 5fb204a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libstdc++-v3/include/tr2/type_traits
Expand Up @@ -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
}
Expand Down

0 comments on commit 5fb204a

Please sign in to comment.