diff --git a/include/fmt/format.h b/include/fmt/format.h index 24159f9f..018f1aaf 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -283,12 +283,12 @@ class fp { typedef uint64_t significand_type; // All sizes are in bits. - static constexpr int char_size = std::numeric_limits::digits; + static FMT_CONSTEXPR_DECL const int char_size = std::numeric_limits::digits; // Subtract 1 to account for an implicit most significant bit in the // normalized form. - static constexpr int double_significand_size = + static FMT_CONSTEXPR_DECL const int double_significand_size = std::numeric_limits::digits - 1; - static constexpr uint64_t implicit_bit = 1ull << double_significand_size; + static FMT_CONSTEXPR_DECL const uint64_t implicit_bit = 1ull << double_significand_size; public: significand_type f; @@ -317,7 +317,7 @@ class fp { f += implicit_bit; else biased_e = 1; // Subnormals use biased exponent 1 (min exponent). - e = biased_e - exponent_bias - double_significand_size; + e = static_cast(biased_e - exponent_bias - double_significand_size); } // Normalizes the value converted from double and multiplied by (1 << SHIFT). @@ -2660,7 +2660,7 @@ class basic_writer { }; struct double_writer { - unsigned n; + size_t n; char sign; basic_memory_buffer &buffer; @@ -2914,7 +2914,7 @@ void basic_writer::write_double(T value, const format_specs &spec) { internal::fp product = fp_value * dec_pow; // Generate output. internal::fp one(1ull << -product.e, product.e); - uint32_t hi = product.f >> -one.e; + uint64_t hi = product.f >> -one.e; uint64_t f = product.f & (one.f - 1); typedef back_insert_range> range; basic_writer w{range(buffer)}; @@ -2934,7 +2934,7 @@ void basic_writer::write_double(T value, const format_specs &spec) { normalized_spec.type_ = handler.type; write_double_sprintf(value, normalized_spec, buffer); } - unsigned n = buffer.size(); + size_t n = buffer.size(); align_spec as = spec; if (spec.align() == ALIGN_NUMERIC) { if (sign) { diff --git a/support/cmake/cxx14.cmake b/support/cmake/cxx14.cmake index 083f7886..1866cdcc 100644 --- a/support/cmake/cxx14.cmake +++ b/support/cmake/cxx14.cmake @@ -36,7 +36,7 @@ elseif (CMAKE_CXX_STANDARD EQUAL 14) set(CXX_STANDARD_FLAG -std=c++1y) endif () elseif (CMAKE_CXX_STANDARD EQUAL 11) - check_cxx_compiler_flag(-std=c++11 has_std_14_flag) + check_cxx_compiler_flag(-std=c++11 has_std_11_flag) check_cxx_compiler_flag(-std=c++0x has_std_0x_flag) if (has_std_11_flag) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8d2ccc67..78e952e2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -150,8 +150,6 @@ if (FMT_PEDANTIC) target_include_directories(no-windows-h-test SYSTEM PUBLIC gtest gmock) endif () - message(STATUS USER_DEFINED_LITERALS: ${SUPPORTS_USER_DEFINED_LITERALS}) - add_test(compile-test ${CMAKE_CTEST_COMMAND} --build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/compile-test" diff --git a/test/posix-mock-test.cc b/test/posix-mock-test.cc index 9218816f..83a9ac3c 100644 --- a/test/posix-mock-test.cc +++ b/test/posix-mock-test.cc @@ -475,7 +475,13 @@ double _strtod_l(const char *nptr, char **endptr, _locale_t locale) { # pragma warning(pop) #endif -LocaleType newlocale(int category_mask, const char *locale, LocaleType base) { +#if defined(__THROW) && FMT_GCC_VERSION > 0 && FMT_GCC_VERSION <= 408 +#define FMT_LOCALE_THROW __THROW +#else +#define FMT_LOCALE_THROW +#endif + +LocaleType newlocale(int category_mask, const char *locale, LocaleType base) FMT_LOCALE_THROW { return LocaleMock::instance->newlocale(category_mask, locale, base); } @@ -485,15 +491,17 @@ typedef int FreeLocaleResult; typedef void FreeLocaleResult; #endif -FreeLocaleResult freelocale(LocaleType locale) { +FreeLocaleResult freelocale(LocaleType locale) FMT_LOCALE_THROW { LocaleMock::instance->freelocale(locale); return FreeLocaleResult(); } -double strtod_l(const char *nptr, char **endptr, LocaleType locale) { +double strtod_l(const char *nptr, char **endptr, LocaleType locale) FMT_LOCALE_THROW { return LocaleMock::instance->strtod_l(nptr, endptr, locale); } +#undef FMT_LOCALE_THROW + TEST(LocaleTest, LocaleMock) { ScopedMock mock; LocaleType locale = reinterpret_cast(11);