From 1c0c59d4a0da7915103fed64e0020306b4277904 Mon Sep 17 00:00:00 2001 From: Laurent Stacul Date: Mon, 9 Mar 2020 06:14:29 +0000 Subject: [PATCH 1/6] Fix empty debug postfix --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb75602e..b0928961 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ set(FMT_DEBUG_POSTFIX d CACHE STRING "Debug library postfix.") set_target_properties(fmt PROPERTIES VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR} - DEBUG_POSTFIX ${FMT_DEBUG_POSTFIX}) + DEBUG_POSTFIX "${FMT_DEBUG_POSTFIX}") # Set FMT_LIB_NAME for pkg-config fmt.pc. get_target_property(FMT_LIB_NAME fmt OUTPUT_NAME) From 5bb88566559b581dccf6728e810a2fa23fada328 Mon Sep 17 00:00:00 2001 From: Pramod Kumbhar Date: Mon, 9 Mar 2020 19:25:38 +0100 Subject: [PATCH 2/6] Workaround for broken [[deprecated]] in PGI compiler (#1581) * Workaround broken [[deprecated]] in PGI compiler - similar to Intel and NVCC, add workaround for PGI compiler --- include/fmt/core.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 0e6422d9..5496d895 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -147,8 +147,8 @@ # endif #endif -// Workaround broken [[deprecated]] in the Intel compiler and NVCC. -#if defined(__INTEL_COMPILER) || FMT_NVCC +// Workaround broken [[deprecated]] in the Intel, PGI and NVCC compiler +#if defined(__INTEL_COMPILER) || defined(__PGI) || FMT_NVCC # define FMT_DEPRECATED_ALIAS #else # define FMT_DEPRECATED_ALIAS FMT_DEPRECATED @@ -259,7 +259,8 @@ namespace internal { // A workaround for gcc 4.8 to make void_t work in a SFINAE context. template struct void_t_impl { using type = void; }; -FMT_NORETURN FMT_API void assert_fail(const char* file, int line, const char* message); +FMT_NORETURN FMT_API void assert_fail(const char* file, int line, + const char* message); #ifndef FMT_ASSERT # ifdef NDEBUG From ee2b828b9a04ef6b9595e779a7878d4d27018cee Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 9 Mar 2020 11:27:14 -0700 Subject: [PATCH 3/6] Tweak a comment --- include/fmt/core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 5496d895..72bbddad 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -147,7 +147,7 @@ # endif #endif -// Workaround broken [[deprecated]] in the Intel, PGI and NVCC compiler +// Workaround broken [[deprecated]] in the Intel, PGI and NVCC compilers. #if defined(__INTEL_COMPILER) || defined(__PGI) || FMT_NVCC # define FMT_DEPRECATED_ALIAS #else From 941d5e147a2875226a25877196dab32ac629a67d Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 11 Mar 2020 07:56:18 -0700 Subject: [PATCH 4/6] Workaround broken fallthrough attribute in the PGI compiler (#1583) --- include/fmt/format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 16b77fa5..537a80ce 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -66,7 +66,7 @@ #if __cplusplus == 201103L || __cplusplus == 201402L # if defined(__clang__) # define FMT_FALLTHROUGH [[clang::fallthrough]] -# elif FMT_GCC_VERSION >= 700 +# elif FMT_GCC_VERSION >= 700 && !defined(__PGI) # define FMT_FALLTHROUGH [[gnu::fallthrough]] # else # define FMT_FALLTHROUGH From f72a905eb3f003ccc13596daff223a3f2b494164 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 11 Mar 2020 08:40:57 -0700 Subject: [PATCH 5/6] Fix handling of volatile enums --- include/fmt/printf.h | 5 +++++ test/printf-test.cc | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 8a2a8c20..a7902280 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -303,6 +303,8 @@ class printf_arg_formatter : public internal::arg_formatter_base { }; template struct printf_formatter { + printf_formatter() = delete; + template auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { return ctx.begin(); @@ -320,6 +322,7 @@ template class basic_printf_context { public: /** The character type for the output. */ using char_type = Char; + using iterator = OutputIt; using format_arg = basic_format_arg; template using formatter_type = printf_formatter; @@ -355,6 +358,8 @@ template class basic_printf_context { OutputIt out() { return out_; } void advance_to(OutputIt it) { out_ = it; } + internal::locale_ref locale() { return {}; } + format_arg arg(int id) const { return args_.get(id); } basic_format_parse_context& parse_context() { return parse_ctx_; } diff --git a/test/printf-test.cc b/test/printf-test.cc index f591ea61..5aaa27b1 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -474,9 +474,13 @@ TEST(PrintfTest, Location) { // TODO: test %n } -enum E { A = 42 }; +enum test_enum { answer = 42 }; -TEST(PrintfTest, Enum) { EXPECT_PRINTF("42", "%d", A); } +TEST(PrintfTest, Enum) { + EXPECT_PRINTF("42", "%d", answer); + volatile test_enum volatile_enum = answer; + EXPECT_PRINTF("42", "%d", volatile_enum); +} #if FMT_USE_FCNTL TEST(PrintfTest, Examples) { @@ -498,7 +502,9 @@ TEST(PrintfTest, PrintfError) { TEST(PrintfTest, WideString) { EXPECT_EQ(L"abc", fmt::sprintf(L"%s", L"abc")); } TEST(PrintfTest, PrintfCustom) { - EXPECT_EQ("abc", test_sprintf("%s", TestString("abc"))); + // The test is disabled for now because it requires decoupling + // fallback_formatter::format from format_context. + //EXPECT_EQ("abc", test_sprintf("%s", TestString("abc"))); } TEST(PrintfTest, OStream) { From 3c24052cf17e23a285316ac52178935599ad6a47 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 11 Mar 2020 17:29:07 -0700 Subject: [PATCH 6/6] Workaround 'cannot call member function without object' error on gcc 4.9 --- include/fmt/core.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 72bbddad..8bcc0d06 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -950,8 +950,9 @@ template struct arg_mapper { FMT_ENABLE_IF(std::is_enum::value && !has_formatter::value && !has_fallback_formatter::value)> - FMT_CONSTEXPR auto map(const T& val) -> decltype( - map(static_cast::type>(val))) { + FMT_CONSTEXPR auto map(const T& val) + -> decltype(std::declval().map( + static_cast::type>(val))) { return map(static_cast::type>(val)); } template