diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -614,7 +614,8 @@ endif() target_add_compile_flags_if_supported(${target} PRIVATE -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long - -Werror=return-type -Wextra-semi -Wundef) + -Werror=return-type -Wextra-semi -Wundef + -Wformat-nonliteral) if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") target_add_compile_flags_if_supported(${target} PRIVATE -Wno-user-defined-literals diff --git a/libcxx/include/locale b/libcxx/include/locale --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -1486,7 +1486,10 @@ + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up + 2; // base prefix + terminating null character char __nar[__nbuf]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); +#pragma clang diagnostic pop char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); // Stage 2 - Widen __nar while adding thousands separators @@ -1546,6 +1549,8 @@ char __nar[__nbuf]; char* __nb = __nar; int __nc; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" if (__specify_precision) __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); @@ -1562,6 +1567,7 @@ __throw_bad_alloc(); __nbh.reset(__nb); } +#pragma clang diagnostic pop char* __ne = __nb + __nc; char* __np = this->__identify_padding(__nb, __ne, __iob); // Stage 2 - Widen __nar while adding thousands separators @@ -1606,10 +1612,9 @@ char_type __fl, const void* __v) const { // Stage 1 - Get pointer in narrow char - char __fmt[6] = "%p"; const unsigned __nbuf = 20; char __nar[__nbuf]; - int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); + int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, "%p", __v); char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); // Stage 2 - Widen __nar