From 850aa1b19d642f1da2f7d1aef0d4a755db10709e Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Sun, 3 Jul 2022 14:27:27 +0500 Subject: [PATCH 1/3] New CI: Microsoft Visual Studio 2022. Signed-off-by: Vladislav Shchapov --- .github/workflows/windows.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 34bd57be718b..28c95d5b75c0 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -10,9 +10,10 @@ jobs: runs-on: ${{matrix.os}} strategy: matrix: - # windows-2019 has MSVC 2019 installed: + # windows-2019 has MSVC 2019 installed; + # windows-2022 has MSVC 2022 installed: # https://github.com/actions/virtual-environments. - os: [windows-2019] + os: [windows-2019, windows-2022] platform: [Win32, x64] build_type: [Debug, Release] standard: [11, 17, 20] @@ -28,6 +29,8 @@ jobs: - os: windows-2019 standard: 20 platform: Win32 + - os: windows-2022 + standard: 11 steps: - uses: actions/checkout@v2 From d6df555f7b3ec53a498a555b7782bd0ab115945c Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Sun, 3 Jul 2022 14:50:21 +0500 Subject: [PATCH 2/3] Replace __cplusplus with FMT_CPLUSPLUS. Signed-off-by: Vladislav Shchapov --- include/fmt/core.h | 22 +++++++++++----------- include/fmt/format.h | 2 +- test/compile-fp-test.cc | 2 +- test/compile-test.cc | 4 ++-- test/format-test.cc | 6 +++--- test/xchar-test.cc | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 4f9115b1bbcb..0efb34e468e0 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -93,7 +93,7 @@ // GCC doesn't allow throw in constexpr until version 6 (bug 67371). #ifndef FMT_USE_CONSTEXPR # if (FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VERSION >= 1912 || \ - (FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) && \ + (FMT_GCC_VERSION >= 600 && FMT_CPLUSPLUS >= 201402L)) && \ !FMT_ICC_VERSION && !defined(__NVCC__) # define FMT_USE_CONSTEXPR 1 # else @@ -106,9 +106,9 @@ # define FMT_CONSTEXPR #endif -#if ((__cplusplus >= 202002L) && \ +#if ((FMT_CPLUSPLUS >= 202002L) && \ (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE > 9)) || \ - (__cplusplus >= 201709L && FMT_GCC_VERSION >= 1002) + (FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002) # define FMT_CONSTEXPR20 constexpr #else # define FMT_CONSTEXPR20 @@ -116,11 +116,11 @@ // Check if constexpr std::char_traits<>::{compare,length} are supported. #if defined(__GLIBCXX__) -# if __cplusplus >= 201703L && defined(_GLIBCXX_RELEASE) && \ +# if FMT_CPLUSPLUS >= 201703L && defined(_GLIBCXX_RELEASE) && \ _GLIBCXX_RELEASE >= 7 // GCC 7+ libstdc++ has _GLIBCXX_RELEASE. # define FMT_CONSTEXPR_CHAR_TRAITS constexpr # endif -#elif defined(_LIBCPP_VERSION) && __cplusplus >= 201703L && \ +#elif defined(_LIBCPP_VERSION) && FMT_CPLUSPLUS >= 201703L && \ _LIBCPP_VERSION >= 4000 # define FMT_CONSTEXPR_CHAR_TRAITS constexpr #elif FMT_MSC_VERSION >= 1914 && FMT_CPLUSPLUS >= 201703L @@ -248,7 +248,7 @@ (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION)) # include # define FMT_USE_STRING_VIEW -#elif FMT_HAS_INCLUDE("experimental/string_view") && __cplusplus >= 201402L +#elif FMT_HAS_INCLUDE("experimental/string_view") && FMT_CPLUSPLUS >= 201402L # include # define FMT_USE_EXPERIMENTAL_STRING_VIEW #endif @@ -258,9 +258,9 @@ #endif #ifndef FMT_CONSTEVAL -# if ((FMT_GCC_VERSION >= 1000 || FMT_CLANG_VERSION >= 1101) && \ - __cplusplus >= 202002L && !defined(__apple_build_version__)) || \ - (defined(__cpp_consteval) && \ +# if ((FMT_GCC_VERSION >= 1000 || FMT_CLANG_VERSION >= 1101) && \ + FMT_CPLUSPLUS >= 202002L && !defined(__apple_build_version__)) || \ + (defined(__cpp_consteval) && \ (!FMT_MSC_VERSION || _MSC_FULL_VER >= 193030704)) // consteval is broken in MSVC before VS2022 and Apple clang 13. # define FMT_CONSTEVAL consteval @@ -271,8 +271,8 @@ #endif #ifndef FMT_USE_NONTYPE_TEMPLATE_ARGS -# if defined(__cpp_nontype_template_args) && \ - ((FMT_GCC_VERSION >= 903 && __cplusplus >= 201709L) || \ +# if defined(__cpp_nontype_template_args) && \ + ((FMT_GCC_VERSION >= 903 && FMT_CPLUSPLUS >= 201709L) || \ __cpp_nontype_template_args >= 201911L) # define FMT_USE_NONTYPE_TEMPLATE_ARGS 1 # else diff --git a/include/fmt/format.h b/include/fmt/format.h index 4e1466038d20..0bd2fdb1823d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1516,7 +1516,7 @@ template struct basic_data { 10000000000000000000ULL}; }; -#if __cplusplus < 201703L +#if FMT_CPLUSPLUS < 201703L template constexpr uint64_t basic_data::pow10_significands[]; template constexpr int16_t basic_data::pow10_exponents[]; template constexpr uint64_t basic_data::power_of_10_64[]; diff --git a/test/compile-fp-test.cc b/test/compile-fp-test.cc index afedc26d0611..db0cd906c5b1 100644 --- a/test/compile-fp-test.cc +++ b/test/compile-fp-test.cc @@ -11,7 +11,7 @@ #if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806 && \ defined(__cpp_constexpr) && __cpp_constexpr >= 201907 && \ defined(__cpp_constexpr_dynamic_alloc) && \ - __cpp_constexpr_dynamic_alloc >= 201907 && __cplusplus >= 202002L + __cpp_constexpr_dynamic_alloc >= 201907 && FMT_CPLUSPLUS >= 202002L template struct test_string { template constexpr bool operator==(const T& rhs) const noexcept { return fmt::basic_string_view(rhs).compare(buffer) == 0; diff --git a/test/compile-test.cc b/test/compile-test.cc index 1337cf4f3dbe..06c7303babfc 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -294,8 +294,8 @@ TEST(compile_test, compile_format_string_literal) { } #endif -#if __cplusplus >= 202002L || \ - (__cplusplus >= 201709L && FMT_GCC_VERSION >= 1002) +#if FMT_CPLUSPLUS >= 202002L || \ + (FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002) template struct test_string { template constexpr bool operator==(const T& rhs) const noexcept { return fmt::basic_string_view(rhs).compare(buffer) == 0; diff --git a/test/format-test.cc b/test/format-test.cc index f6e586f65840..45a92624fbef 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1860,11 +1860,11 @@ TEST(format_test, compile_time_string) { (void)with_null; (void)no_null; -#if __cplusplus >= 201703L +#if FMT_CPLUSPLUS >= 201703L EXPECT_EQ("42", fmt::format(FMT_STRING(with_null), 42)); EXPECT_EQ("42", fmt::format(FMT_STRING(no_null), 42)); #endif -#if defined(FMT_USE_STRING_VIEW) && __cplusplus >= 201703L +#if defined(FMT_USE_STRING_VIEW) && FMT_CPLUSPLUS >= 201703L EXPECT_EQ("42", fmt::format(FMT_STRING(std::string_view("{}")), 42)); #endif } @@ -2233,7 +2233,7 @@ TEST(format_test, char_traits_is_not_ambiguous) { using namespace std; auto c = char_traits::char_type(); (void)c; -#if __cplusplus >= 201103L +#if FMT_CPLUSPLUS >= 201103L auto s = std::string(); auto lval = begin(s); (void)lval; diff --git a/test/xchar-test.cc b/test/xchar-test.cc index 52dc4ff41b0c..ea8bc85ab337 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -98,12 +98,12 @@ TEST(xchar_test, is_formattable) { } TEST(xchar_test, compile_time_string) { -#if defined(FMT_USE_STRING_VIEW) && __cplusplus >= 201703L +#if defined(FMT_USE_STRING_VIEW) && FMT_CPLUSPLUS >= 201703L EXPECT_EQ(L"42", fmt::format(FMT_STRING(std::wstring_view(L"{}")), 42)); #endif } -#if __cplusplus > 201103L +#if FMT_CPLUSPLUS > 201103L struct custom_char { int value; custom_char() = default; From 2f3f86e0b60236adea6643281a1b246b171f3742 Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Sun, 3 Jul 2022 15:56:56 +0500 Subject: [PATCH 3/3] Workaround for Microsoft Visual Studio 2022 Internal compiler error. D:\a\fmt\fmt\test\compile-test.cc(362,3): fatal error C1001: Internal compiler error. [D:\a\fmt\build\test\compile-test.vcxproj] (compiler file 'D:\a\_work\1\s\src\vctools\Compiler\CxxFE\sl\p1\c\constexpr\constexpr.cpp', line 8635) Signed-off-by: Vladislav Shchapov --- test/compile-test.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/compile-test.cc b/test/compile-test.cc index 06c7303babfc..2a9e16196d01 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -294,7 +294,14 @@ TEST(compile_test, compile_format_string_literal) { } #endif -#if FMT_CPLUSPLUS >= 202002L || \ +// MSVS 2019 19.29.30145.0 - Support C++20 and OK. +// MSVS 2022 19.32.31332.0 - compile-test.cc(362,3): fatal error C1001: Internal +// compiler error. +// (compiler file +// 'D:\a\_work\1\s\src\vctools\Compiler\CxxFE\sl\p1\c\constexpr\constexpr.cpp', +// line 8635) +#if ((FMT_CPLUSPLUS >= 202002L) && \ + (!FMT_MSC_VERSION || FMT_MSC_VERSION < 1930)) || \ (FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002) template struct test_string { template constexpr bool operator==(const T& rhs) const noexcept {