From 97e1271e5eab87b4f5b71b5d7cd771d95fbc3916 Mon Sep 17 00:00:00 2001 From: Elias Kosunen Date: Fri, 11 May 2018 16:24:38 +0300 Subject: [PATCH] Add more compilers to CI Fix (some) of the compiler errors with them --- .travis.yml | 99 ++++++++++++++++++++++++++++++++-------- CMakeLists.txt | 3 +- include/fmt/core.h | 6 +-- include/fmt/format-inl.h | 10 +--- include/fmt/format.h | 2 +- 5 files changed, 88 insertions(+), 32 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4388dd57..8443e5a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,19 @@ language: cpp dist: trusty -sudo: required # the doc target uses sudo to install dependencies +sudo: false -os: - - linux - - osx +os: linux + +git: + depth: 1 + +addons: + apt: + update: true + sources: &apt_sources + - ubuntu-toolchain-r-test + packages: + - g++-6 env: global: @@ -12,16 +21,65 @@ env: a1eovNn4uol9won7ghr67eD3/59oeESN+G9bWE+ecI1V6yRseG9whniGhIpC/YfMW/Qz5I 5sxSmFjaw9bxCISNwUIrL1O5x2AmRYTnFcXk4dFsUvlZg+WeF/aKyBYCNRM8C2ndbBmtAO o1F2EwFbiso0EmtzhAPs19ujiVxkLn4= - matrix: - - BUILD=Doc - - BUILD=Debug STANDARD=14 - - BUILD=Release STANDARD=14 matrix: exclude: - - os: osx - env: BUILD=Doc + - env: TRAVIS_EMPTY_JOB_WORKAROUND=true include: + # Documentation + - env: CXX_COMPILER=g++-6 BUILD=Doc + sudo: required + compiler: gcc + # g++ 6 on Linux with C++14 + - env: CXX_COMPILER=g++-6 BUILD=Debug STANDARD=14 + compiler: gcc + - env: CXX_COMPILER=g++-6 BUILD=Release STANDARD=14 + compiler: gcc + # Apple clang on OS X with C++14 + - env: BUILD=Debug STANDARD=14 + compiler: clang + os: osx + - env: BUILD=Release STANDARD=14 + compiler: clang + os: osx + # clang 6.0 on Linux with C++14 + - env: CXX_COMPILER=clang++-6.0 BUILD=Debug STANDARD=14 + compiler: clang + addons: + apt: + update: true + packages: + - clang-6.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty + - llvm-toolchain-trusty-6.0 + # clang 4.0 on Linux with C++14 + - env: CXX_COMPILER=clang++-4.0 BUILD=Debug STANDARD=11 + compiler: clang + addons: + apt: + update: true + packages: + - clang-4.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty + - llvm-toolchain-trusty-4.0 + # g++ 4.8 on Linux with C++11 + - env: CXX_COMPILER=g++-4.8 BUILD=Debug STANDARD=11 + compiler: gcc + # g++ 4.4 on Linux with C++11 + - env: CXX_COMPILER=g++-4.4 BUILD=Debug STANDARD=0x + compiler: gcc + addons: + apt: + update: true + packages: + - g++-4.4 + sources: + - ubuntu-toolchain-r-test + # Android - language: android android: components: @@ -51,17 +109,20 @@ matrix: after_success: - cd ${TRAVIS_BUILD_DIR} - tree ./libs + allow_failures: + # Errors + - env: CXX_COMPILER=g++-4.4 BUILD=Debug STANDARD=0x + compiler: gcc -# Install gcc-6 for extended constexpr support. -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-6 +install: + - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" + - mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR} -before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CXX=g++-6; fi + - cd ${TRAVIS_BUILD_DIR} + +before_script: + - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then export CXX=${CXX_COMPILER}; fi + - ${CXX} --version script: - support/travis-build.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f65a6a4..4156356d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") -Wcast-qual -Wformat=2 -Wmissing-include-dirs -Wcast-align -Wnon-virtual-dtor -Wctor-dtor-privacy -Wdisabled-optimization - -Winvalid-pch -Wmissing-declarations -Woverloaded-virtual) + -Winvalid-pch -Wmissing-declarations -Woverloaded-virtual + -Wno-sign-conversion -Wno-shadow) if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wnoexcept) endif () diff --git a/include/fmt/core.h b/include/fmt/core.h index d0f63feb..820304ff 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -219,7 +219,7 @@ class basic_string_view { #else struct type { const char *data() const { return FMT_NULL; } - size_t size() const { return 0; }; + size_t size() const { return 0; } }; #endif @@ -557,7 +557,7 @@ struct typed_value : value { template FMT_CONSTEXPR basic_format_arg make_arg(const T &value); -#if FMT_GCC_VERSION +#if FMT_GCC_VERSION >= 406 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuseless-cast" #endif @@ -629,7 +629,7 @@ FMT_MAKE_VALUE(pointer_type, const void*, const void*) FMT_MAKE_VALUE(pointer_type, std::nullptr_t, const void*) #endif -#if FMT_GCC_VERSION +#if FMT_GCC_VERSION >= 406 // -Wuseless-cast #pragma GCC diagnostic pop #endif diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index fad31909..f66a5ff6 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -45,12 +45,6 @@ # define FMT_CATCH(x) if (false) #endif -#ifdef __GNUC__ -// Disable the warning about declaration shadowing because it affects too -// many valid cases. -# pragma GCC diagnostic ignored "-Wshadow" -#endif - #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable: 4127) // conditional expression is constant @@ -228,7 +222,7 @@ FMT_FUNC void system_error::init( } namespace internal { -#ifdef __GNUC__ +#if FMT_GCC_VERSION >= 406 || FMT_CLANG_VERSION #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" #endif @@ -261,7 +255,7 @@ int char_traits::format_float( FMT_SWPRINTF(buffer, size, format, width, precision, value); } -#ifdef __GNUC__ +#if FMT_GCC_VERSION >= 406 || FMT_CLANG_VERSION #pragma GCC diagnostic pop #endif diff --git a/include/fmt/format.h b/include/fmt/format.h index 215510ac..ce1347b4 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -318,7 +318,7 @@ fp operator*(fp x, fp y); // Compute k such that its cached power c_k = c_k.f * pow(2, c_k.e) satisfies // min_exponent <= c_k.e + e <= min_exponent + 3. inline int compute_cached_power_index(int e, int min_exponent) { - constexpr double one_over_log2_10 = 0.30102999566398114; // 1 / log2(10) + FMT_CONSTEXPR_DECL double one_over_log2_10 = 0.30102999566398114; // 1 / log2(10) return static_cast(std::ceil((min_exponent - e + 63) * one_over_log2_10)); }