diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index d8956822..9e77b4e0 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -683,7 +683,7 @@ template struct grisu_shortest_handler { }; template -FMT_FUNC bool grisu_format(Double value, buffer& buf, int precision, +FMT_API bool grisu_format(Double value, buffer& buf, int precision, unsigned options, int& exp) { FMT_ASSERT(value >= 0, "value is negative"); bool fixed = (options & grisu_options::fixed) != 0; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e3667d06..7bbe63a5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,9 +21,16 @@ if (NOT SUPPORTS_VARIADIC_TEMPLATES) target_compile_definitions(gmock PUBLIC GTEST_LANG_CXX11=0) endif () -# Workaround a bug in implementation of variadic templates in MSVC11. if (MSVC) + # Workaround a bug in implementation of variadic templates in MSVC11. target_compile_definitions(gmock PUBLIC _VARIADIC_MAX=10) + + # Disable MSVC warnings of _CRT_INSECURE_DEPRECATE functions. + target_compile_definitions(gmock PUBLIC _CRT_SECURE_NO_WARNINGS) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Disable MSVC warnings of POSIX functions. + target_compile_options(gmock PUBLIC -Wno-deprecated-declarations) + endif () endif () # GTest doesn't detect with clang. diff --git a/test/format-test.cc b/test/format-test.cc index dd65bdd3..c6043586 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2482,10 +2482,17 @@ TEST(FormatTest, FmtStringInTemplate) { #endif // FMT_USE_CONSTEXPR +// C++20 feature test, since r346892 Clang considers char8_t a fundamental +// type in this mode. If this is the case __cpp_char8_t will be defined. +#ifndef __cpp_char8_t +// Locally provide type char8_t defined in format.h +using fmt::char8_t; +#endif + TEST(FormatTest, ConstructU8StringViewFromCString) { fmt::u8string_view s("ab"); EXPECT_EQ(s.size(), 2u); - const fmt::char8_t* data = s.data(); + const char8_t* data = s.data(); EXPECT_EQ(data[0], 'a'); EXPECT_EQ(data[1], 'b'); } @@ -2493,7 +2500,7 @@ TEST(FormatTest, ConstructU8StringViewFromCString) { TEST(FormatTest, ConstructU8StringViewFromDataAndSize) { fmt::u8string_view s("foobar", 3); EXPECT_EQ(s.size(), 3u); - const fmt::char8_t* data = s.data(); + const char8_t* data = s.data(); EXPECT_EQ(data[0], 'f'); EXPECT_EQ(data[1], 'o'); EXPECT_EQ(data[2], 'o'); @@ -2504,7 +2511,7 @@ TEST(FormatTest, U8StringViewLiteral) { using namespace fmt::literals; fmt::u8string_view s = "ab"_u; EXPECT_EQ(s.size(), 2u); - const fmt::char8_t* data = s.data(); + const char8_t* data = s.data(); EXPECT_EQ(data[0], 'a'); EXPECT_EQ(data[1], 'b'); EXPECT_EQ(format("{:*^5}"_u, "🤡"_u), "**🤡**"_u); @@ -2525,8 +2532,10 @@ TEST(FormatTest, CharTraitsIsNotAmbiguous) { // Test that we don't inject internal names into the std namespace. using namespace std; char_traits::char_type c; + (void)c; #if __cplusplus >= 201103L std::string s; - begin(s); + auto lval = begin(s); + (void)lval; #endif } diff --git a/test/posix-mock-test.cc b/test/posix-mock-test.cc index 75660ea5..fc62627f 100644 --- a/test/posix-mock-test.cc +++ b/test/posix-mock-test.cc @@ -461,6 +461,10 @@ struct LocaleMock { # ifdef _MSC_VER # pragma warning(push) # pragma warning(disable : 4273) +# ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Winconsistent-dllimport" +# endif _locale_t _create_locale(int category, const char* locale) { return LocaleMock::instance->newlocale(category, locale, 0); @@ -473,6 +477,9 @@ void _free_locale(_locale_t locale) { double _strtod_l(const char* nptr, char** endptr, _locale_t locale) { return LocaleMock::instance->strtod_l(nptr, endptr, locale); } +# ifdef __clang__ +# pragma clang diagnostic pop +# endif # pragma warning(pop) # endif