@@ -470,6 +470,10 @@ _LIBCPP_HARDENING_MODE_DEBUG
470
470
# define __has_include (...) 0
471
471
# endif
472
472
473
+ # ifndef __has_warning
474
+ # define __has_warning (...) 0
475
+ # endif
476
+
473
477
# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
474
478
# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
475
479
# endif
@@ -787,6 +791,23 @@ typedef __char32_t char32_t;
787
791
# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
788
792
# endif
789
793
794
+ # ifdef _LIBCPP_COMPILER_CLANG_BASED
795
+ # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma (" clang diagnostic push" )
796
+ # define _LIBCPP_DIAGNOSTIC_POP _Pragma (" clang diagnostic pop" )
797
+ # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str ) _Pragma (_LIBCPP_TOSTRING(clang diagnostic ignored str))
798
+ # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str )
799
+ # elif defined(_LIBCPP_COMPILER_GCC)
800
+ # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma (" GCC diagnostic push" )
801
+ # define _LIBCPP_DIAGNOSTIC_POP _Pragma (" GCC diagnostic pop" )
802
+ # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str )
803
+ # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str ) _Pragma (_LIBCPP_TOSTRING(GCC diagnostic ignored str))
804
+ # else
805
+ # define _LIBCPP_DIAGNOSTIC_PUSH
806
+ # define _LIBCPP_DIAGNOSTIC_POP
807
+ # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str )
808
+ # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str )
809
+ # endif
810
+
790
811
# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
791
812
# define _LIBCPP_HARDENING_SIG f
792
813
# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
@@ -874,16 +895,33 @@ typedef __char32_t char32_t;
874
895
# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
875
896
# endif
876
897
898
+ // TODO: Remove this workaround once we drop support for Clang 16
899
+ #if __has_warning("-Wc++23-extensions")
900
+ # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (" -Wc++23-extensions" )
901
+ #else
902
+ # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (" -Wc++2b-extensions" )
903
+ #endif
904
+
877
905
// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
878
906
// clang-format off
879
- # define _LIBCPP_BEGIN_NAMESPACE_STD namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
907
+ # define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_DIAGNOSTIC_PUSH \
908
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (" -Wc++11-extensions" ) \
909
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(" -Wc++14-extensions" ) \
910
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(" -Wc++17-extensions" ) \
911
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(" -Wc++20-extensions" ) \
912
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \
913
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED(" -Wc++14-extensions" ) \
914
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED(" -Wc++17-extensions" ) \
915
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED(" -Wc++20-extensions" ) \
916
+ _LIBCPP_GCC_DIAGNOSTIC_IGNORED(" -Wc++23-extensions" ) \
917
+ namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
880
918
inline namespace _LIBCPP_ABI_NAMESPACE {
881
- # define _LIBCPP_END_NAMESPACE_STD }}
919
+ # define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_DIAGNOSTIC_POP
882
920
883
921
# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \
884
922
inline namespace __fs { namespace filesystem {
885
923
886
- # define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
924
+ # define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD
887
925
// clang-format on
888
926
889
927
# if __has_attribute(__enable_if__)
@@ -1323,23 +1361,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
1323
1361
// the ABI inconsistent.
1324
1362
# endif
1325
1363
1326
- # ifdef _LIBCPP_COMPILER_CLANG_BASED
1327
- # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma (" clang diagnostic push" )
1328
- # define _LIBCPP_DIAGNOSTIC_POP _Pragma (" clang diagnostic pop" )
1329
- # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str ) _Pragma (_LIBCPP_TOSTRING(clang diagnostic ignored str))
1330
- # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str )
1331
- # elif defined(_LIBCPP_COMPILER_GCC)
1332
- # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma (" GCC diagnostic push" )
1333
- # define _LIBCPP_DIAGNOSTIC_POP _Pragma (" GCC diagnostic pop" )
1334
- # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str )
1335
- # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str ) _Pragma (_LIBCPP_TOSTRING(GCC diagnostic ignored str))
1336
- # else
1337
- # define _LIBCPP_DIAGNOSTIC_PUSH
1338
- # define _LIBCPP_DIAGNOSTIC_POP
1339
- # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (str )
1340
- # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str )
1341
- # endif
1342
-
1343
1364
// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
1344
1365
// functions is gradually being added to existing C libraries. The conditions
1345
1366
// below check for known C library versions and conditions under which these
0 commit comments