Skip to content

Commit 470e009

Browse files
committed
[libc++] Allow the use of extensions in the implementation
1 parent 2acf302 commit 470e009

File tree

2 files changed

+37
-26
lines changed

2 files changed

+37
-26
lines changed

libcxx/include/__config

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,23 @@ typedef __char32_t char32_t;
787787
# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
788788
# endif
789789

790+
# ifdef _LIBCPP_COMPILER_CLANG_BASED
791+
# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
792+
# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
793+
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
794+
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
795+
# elif defined(_LIBCPP_COMPILER_GCC)
796+
# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
797+
# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
798+
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
799+
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
800+
# else
801+
# define _LIBCPP_DIAGNOSTIC_PUSH
802+
# define _LIBCPP_DIAGNOSTIC_POP
803+
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
804+
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
805+
# endif
806+
790807
# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
791808
# define _LIBCPP_HARDENING_SIG f
792809
# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
@@ -879,16 +896,33 @@ typedef __char32_t char32_t;
879896
# define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
880897
# define _VSTD std
881898

899+
// TODO: Remove this workaround once we drop support for Clang 16
900+
#if __has_warning("-Wc++23-extensions")
901+
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
902+
#else
903+
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++2b-extensions")
904+
#endif
905+
882906
// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
883907
// clang-format off
884-
# define _LIBCPP_BEGIN_NAMESPACE_STD namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
908+
# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_DIAGNOSTIC_PUSH \
909+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \
910+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
911+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
912+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
913+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \
914+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
915+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
916+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
917+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++23-extensions") \
918+
namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
885919
inline namespace _LIBCPP_ABI_NAMESPACE {
886-
# define _LIBCPP_END_NAMESPACE_STD }}
920+
# define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_DIAGNOSTIC_POP
887921

888922
# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \
889923
inline namespace __fs { namespace filesystem {
890924

891-
# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
925+
# define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD
892926
// clang-format on
893927

894928
# if __has_attribute(__enable_if__)
@@ -1328,23 +1362,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
13281362
// the ABI inconsistent.
13291363
# endif
13301364

1331-
# ifdef _LIBCPP_COMPILER_CLANG_BASED
1332-
# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1333-
# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1334-
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
1335-
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1336-
# elif defined(_LIBCPP_COMPILER_GCC)
1337-
# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1338-
# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1339-
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1340-
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
1341-
# else
1342-
# define _LIBCPP_DIAGNOSTIC_PUSH
1343-
# define _LIBCPP_DIAGNOSTIC_POP
1344-
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1345-
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1346-
# endif
1347-
13481365
// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
13491366
// functions is gradually being added to existing C libraries. The conditions
13501367
// below check for known C library versions and conditions under which these

libcxx/include/tuple

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,6 @@ class _LIBCPP_TEMPLATE_VIS tuple {
550550
public:
551551
// [tuple.cnstr]
552552

553-
_LIBCPP_DIAGNOSTIC_PUSH
554-
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions")
555-
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions")
556-
557553
// tuple() constructors (including allocator_arg_t variants)
558554
template <template <class...> class _IsImpDefault = __is_implicitly_default_constructible,
559555
template <class...> class _IsDefault = is_default_constructible,
@@ -835,8 +831,6 @@ public:
835831
: __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
836832
# endif // _LIBCPP_STD_VER >= 23
837833

838-
_LIBCPP_DIAGNOSTIC_POP
839-
840834
// [tuple.assign]
841835
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
842836
operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)

0 commit comments

Comments
 (0)