@@ -406,6 +406,10 @@ _LIBCPP_HARDENING_MODE_DEBUG
406
406
# define __has_include (...) 0
407
407
# endif
408
408
409
+ # ifndef __has_warning
410
+ # define __has_warning (...) 0
411
+ # endif
412
+
409
413
# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
410
414
# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
411
415
# endif
@@ -723,6 +727,23 @@ typedef __char32_t char32_t;
723
727
# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
724
728
# endif
725
729
730
+ # ifdef _LIBCPP_COMPILER_CLANG_BASED
731
+ # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma (" clang diagnostic push" )
732
+ # define _LIBCPP_DIAGNOSTIC_POP _Pragma (" clang diagnostic pop" )
733
+ # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str ) _Pragma (_LIBCPP_TOSTRING(clang diagnostic ignored str))
734
+ # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str )
735
+ # elif defined(_LIBCPP_COMPILER_GCC)
736
+ # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma (" GCC diagnostic push" )
737
+ # define _LIBCPP_DIAGNOSTIC_POP _Pragma (" GCC diagnostic pop" )
738
+ # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str )
739
+ # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str ) _Pragma (_LIBCPP_TOSTRING(GCC diagnostic ignored str))
740
+ # else
741
+ # define _LIBCPP_DIAGNOSTIC_PUSH
742
+ # define _LIBCPP_DIAGNOSTIC_POP
743
+ # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str )
744
+ # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str )
745
+ # endif
746
+
726
747
# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
727
748
# define _LIBCPP_HARDENING_SIG f
728
749
# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
@@ -810,16 +831,33 @@ typedef __char32_t char32_t;
810
831
# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
811
832
# endif
812
833
834
+ // TODO: Remove this workaround once we drop support for Clang 16
835
+ #if __has_warning("-Wc++23-extensions")
836
+ # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (" -Wc++23-extensions" )
837
+ #else
838
+ # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (" -Wc++2b-extensions" )
839
+ #endif
840
+
813
841
// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
814
842
// clang-format off
815
- # define _LIBCPP_BEGIN_NAMESPACE_STD namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
843
+ # define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_DIAGNOSTIC_PUSH \
844
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (" -Wc++11-extensions" ) \
845
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(" -Wc++14-extensions" ) \
846
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(" -Wc++17-extensions" ) \
847
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(" -Wc++20-extensions" ) \
848
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \
849
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED(" -Wc++14-extensions" ) \
850
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED(" -Wc++17-extensions" ) \
851
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED(" -Wc++20-extensions" ) \
852
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED(" -Wc++23-extensions" ) \
853
+ namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
816
854
inline namespace _LIBCPP_ABI_NAMESPACE {
817
- # define _LIBCPP_END_NAMESPACE_STD }}
855
+ # define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_DIAGNOSTIC_POP
818
856
819
857
# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \
820
858
inline namespace __fs { namespace filesystem {
821
859
822
- # define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
860
+ # define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD
823
861
// clang-format on
824
862
825
863
# if __has_attribute(__enable_if__)
@@ -1256,23 +1294,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
1256
1294
// the ABI inconsistent.
1257
1295
# endif
1258
1296
1259
- # ifdef _LIBCPP_COMPILER_CLANG_BASED
1260
- # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma (" clang diagnostic push" )
1261
- # define _LIBCPP_DIAGNOSTIC_POP _Pragma (" clang diagnostic pop" )
1262
- # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str ) _Pragma (_LIBCPP_TOSTRING(clang diagnostic ignored str))
1263
- # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str )
1264
- # elif defined(_LIBCPP_COMPILER_GCC)
1265
- # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma (" GCC diagnostic push" )
1266
- # define _LIBCPP_DIAGNOSTIC_POP _Pragma (" GCC diagnostic pop" )
1267
- # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str )
1268
- # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str ) _Pragma (_LIBCPP_TOSTRING(GCC diagnostic ignored str))
1269
- # else
1270
- # define _LIBCPP_DIAGNOSTIC_PUSH
1271
- # define _LIBCPP_DIAGNOSTIC_POP
1272
- # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str )
1273
- # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str )
1274
- # endif
1275
-
1276
1297
// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
1277
1298
// functions is gradually being added to existing C libraries. The conditions
1278
1299
// below check for known C library versions and conditions under which these
0 commit comments