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:
denchat
2019-05-12 01:48:27 +07:00
committed by Victor Zverovich
parent a6e8ed15c4
commit f4dfd6e30f
4 changed files with 29 additions and 6 deletions

View File

@@ -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
}