mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 12:14:26 +00:00
Suppress all clang-target-msvc test warning in CMake and other misc fixes (#1151)
* Fix conditional `char8_t` from `format.h` and fix `-Wunused-result` of [[no_discard]] begin() when in c++17 * Suppress `-Winconsistent-dllimport` when in clang-target-msvc * Suppress warning _CRT_SECURE_NO_WARNINGS in MSVC and -Wdeprecated-declarations Suppress warning _CRT_SECURE_NO_WARNINGS in MSVC and -Wdeprecated-declarations of POSIX functions in Clang target MSVC. Those functions are used by gtest. * Remove FMT_FUNC, mark FMT_API to export
This commit is contained in:
parent
a6e8ed15c4
commit
f4dfd6e30f
@ -683,7 +683,7 @@ template <int GRISU_VERSION> struct grisu_shortest_handler {
|
||||
};
|
||||
|
||||
template <typename Double, FMT_ENABLE_IF_T(sizeof(Double) == sizeof(uint64_t))>
|
||||
FMT_FUNC bool grisu_format(Double value, buffer<char>& buf, int precision,
|
||||
FMT_API bool grisu_format(Double value, buffer<char>& buf, int precision,
|
||||
unsigned options, int& exp) {
|
||||
FMT_ASSERT(value >= 0, "value is negative");
|
||||
bool fixed = (options & grisu_options::fixed) != 0;
|
||||
|
@ -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 <tuple> with clang.
|
||||
|
@ -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>::char_type c;
|
||||
(void)c;
|
||||
#if __cplusplus >= 201103L
|
||||
std::string s;
|
||||
begin(s);
|
||||
auto lval = begin(s);
|
||||
(void)lval;
|
||||
#endif
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user