From 0b5719d44636a34864d5a1967790fcab00941ac9 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 9 Nov 2023 14:23:10 -1000 Subject: [PATCH 1/4] Add a Github Actions config --- .github/workflows/tests.yml | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..c4132e873 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,55 @@ +name: Hana CI + +permissions: + contents: read + +on: pull_request + +jobs: + tests: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: macos-latest + xcode-version: latest-stable + - os: macos-latest + compiler: llvm + # - os: macos-latest + # compiler: gcc + # - os: windows-latest + # compiler: llvm + - os: ubuntu-latest + compiler: llvm + # - os: ubuntu-latest + # compiler: gcc + + steps: + - name: Setup build environment + uses: aminya/setup-cpp@v1 + with: + vcvarsall: ${{ contains(matrix.os, 'windows') }} + cmake: true + ninja: true + + - name: Setup compiler + uses: aminya/setup-cpp@v1 + if: ${{ matrix.compiler }} + with: + compiler: ${{ matrix.compiler }} + + - name: Install Xcode + uses: maxim-lobanov/setup-xcode@v1 + if: ${{ matrix.xcode-version }} + with: + xcode-version: ${{ matrix.xcode-version }} + + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Configure CMake + run: mkdir build && cmake -S . -B build -G Ninja + + - name: Run the tests + run: cmake --build build --target check From 76b4f38520124777d9c2bc966dc837d3b5ee1ad2 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 9 Nov 2023 15:12:29 -1000 Subject: [PATCH 2/4] Fix a few tests that didn't get ignored properly on Windows --- include/boost/hana/config.hpp | 2 ++ test/CMakeLists.txt | 11 ----------- test/detail/ebo.cpp | 3 ++- test/issues/github_202.cpp | 6 ++++++ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/boost/hana/config.hpp b/include/boost/hana/config.hpp index 7b7805696..84710eb93 100644 --- a/include/boost/hana/config.hpp +++ b/include/boost/hana/config.hpp @@ -46,11 +46,13 @@ Distributed under the Boost Software License, Version 1.0. #elif defined(__clang__) && defined(_MSC_VER) // Clang-cl (Clang for Windows) +# define BOOST_HANA_CONFIG_CLANG_CL # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \ __clang_major__, __clang_minor__, __clang_patchlevel__) #elif defined(__clang__) && defined(__apple_build_version__) // Apple's Clang +# define BOOST_HANA_CONFIG_APPLE_CLANG # if __apple_build_version__ >= 6020049 # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION(3, 6, 0) # endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8e47c538f..85f0c2b15 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -28,17 +28,6 @@ if (NOT Boost_FOUND) list(APPEND EXCLUDED_PUBLIC_HEADERS ${PUBLIC_HEADERS_REQUIRING_BOOST}) endif() -# On Windows, Clang-cl emulates a MSVC bug that causes EBO not to be applied -# properly. We disable the tests that check for EBO. -if (MSVC AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") - list(APPEND EXCLUDED_UNIT_TESTS - "detail/ebo.cpp" - "issues/github_202.cpp" - "pair/empty_storage.cpp" - "tuple/empty_member.cpp" - ) -endif() - ############################################################################## # Generate tests that include each public header. diff --git a/test/detail/ebo.cpp b/test/detail/ebo.cpp index 2c6f5ef86..d65691445 100644 --- a/test/detail/ebo.cpp +++ b/test/detail/ebo.cpp @@ -21,10 +21,11 @@ template struct __declspec(empty_bases) inherit : Bases... { template struct inherit : Bases... { }; #endif +#ifndef BOOST_HANA_CONFIG_CLANG_CL // MSVC doesn't implement EBO in all cases static_assert(sizeof(inherit<>) == sizeof(inherit, empty<0>>>), ""); static_assert(sizeof(inherit<>) == sizeof(inherit, empty<0>>, ebo, empty<1>>>), ""); static_assert(sizeof(inherit<>) == sizeof(inherit, empty<0>>, ebo, empty<1>>, ebo, empty<2>>>), ""); - +#endif int main() { // Test default-construction diff --git a/test/issues/github_202.cpp b/test/issues/github_202.cpp index f3940e9bd..04cacfca9 100644 --- a/test/issues/github_202.cpp +++ b/test/issues/github_202.cpp @@ -2,6 +2,10 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +#include + +#ifndef BOOST_HANA_CONFIG_CLANG_CL // EBO is not well supported on Windows + #include #include #include @@ -23,4 +27,6 @@ static_assert( sizeof(hana::tuple) , ""); +#endif // BOOST_HANA_CONFIG_CLANG_CL + int main() { } From 4cff7d3bbe824bf2e54f360c8c8249bef15a460a Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 9 Nov 2023 15:14:32 -1000 Subject: [PATCH 3/4] Remove -Wpedantic --- CMakeLists.txt | 1 - test/Jamfile.v2 | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 016e78e25..2f5e79fc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,6 @@ function(boost_hana_set_test_properties target) if (NOT MSVC) setflag(BOOST_HANA_HAS_FDIAGNOSTICS_COLOR -fdiagnostics-color) setflag(BOOST_HANA_HAS_FTEMPLATE_BACKTRACE_LIMIT -ftemplate-backtrace-limit=0) - setflag(BOOST_HANA_HAS_PEDANTIC -pedantic) setflag(BOOST_HANA_HAS_WALL -Wall) setflag(BOOST_HANA_HAS_WERROR -Werror) setflag(BOOST_HANA_HAS_WEXTRA -Wextra) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1248b06b1..225b9db33 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -14,8 +14,8 @@ project boost/hana : rule hana-all-tests { local toolset = - clang:"-std=c++1y -pedantic -Wall -Wextra" - darwin:"-std=c++1y -pedantic -Wall -Wextra" + clang:"-std=c++1y -Wall -Wextra" + darwin:"-std=c++1y -Wall -Wextra" [ requires cxx14_constexpr cxx14_decltype_auto From af2603d16e38e0e0bfde9a768f6f4e57f191c109 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 9 Nov 2023 15:17:53 -1000 Subject: [PATCH 4/4] Implement type_name on GCC and fix on older Clangs --- include/boost/hana/experimental/type_name.hpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/boost/hana/experimental/type_name.hpp b/include/boost/hana/experimental/type_name.hpp index e8b251db9..9d3df4dc3 100644 --- a/include/boost/hana/experimental/type_name.hpp +++ b/include/boost/hana/experimental/type_name.hpp @@ -26,18 +26,23 @@ namespace boost { namespace hana { namespace experimental { // Note: We substract the null terminator from the string sizes below. template - constexpr cstring type_name_impl2() { - - #if defined(__clang__) + constexpr auto type_name_impl2() { + #if defined(BOOST_HANA_CONFIG_CLANG) + constexpr char const* pretty_function = __PRETTY_FUNCTION__; + constexpr std::size_t total_size = sizeof(__PRETTY_FUNCTION__) - 1; + constexpr std::size_t prefix_size = sizeof("auto boost::hana::experimental::detail::type_name_impl2() [T = ") - 1; + constexpr std::size_t suffix_size = sizeof("]") - 1; + #elif defined(BOOST_HANA_CONFIG_GCC) constexpr char const* pretty_function = __PRETTY_FUNCTION__; constexpr std::size_t total_size = sizeof(__PRETTY_FUNCTION__) - 1; - constexpr std::size_t prefix_size = sizeof("cstring boost::hana::experimental::detail::type_name_impl2() [T = ") - 1; + constexpr std::size_t prefix_size = sizeof("constexpr auto boost::hana::experimental::detail::type_name_impl2() [with T = ") - 1; constexpr std::size_t suffix_size = sizeof("]") - 1; #else #error "No support for this compiler." #endif - return {pretty_function + prefix_size, total_size - prefix_size - suffix_size}; + cstring s{pretty_function + prefix_size, total_size - prefix_size - suffix_size}; + return s; } template