From e1cfa03f89a35dcd47ee7d3e74e91a952c992665 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Sat, 13 Dec 2025 13:26:41 +0100 Subject: [PATCH 1/4] Fix compilation with clang-13 and newer. Drone-CI shows a compilation error with clang-13 and newer. This patch fixes that compilation error and extends the Github-CI to detect this. --- .github/workflows/ubuntu24.yml | 49 +++++++++++++++++++++++++++++++++ include/boost/parser/search.hpp | 17 ++---------- 2 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/ubuntu24.yml diff --git a/.github/workflows/ubuntu24.yml b/.github/workflows/ubuntu24.yml new file mode 100644 index 00000000..aa22d984 --- /dev/null +++ b/.github/workflows/ubuntu24.yml @@ -0,0 +1,49 @@ +name: Ubuntu + +on: + push: + branches: [ master, develop ] + pull_request: + branches: [ master, develop ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Debug + +jobs: + build: + strategy: + fail-fast: false + matrix: + compiler_version: [g++-13, g++-14, clang++-20] + cxx_std: [20, 23] + os: [ubuntu-24.04] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + - name: Install Clang 20 + id: install_clang_20 + if: matrix.compiler_version == 'clang++-20' + shell: bash + working-directory: ${{ env.HOME }} + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 20 + sudo apt-get install libc++-20-dev libc++abi-20-dev libunwind-20-dev + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: | + mkdir build + cd build + cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler_version }} -DCXX_STD=${{ matrix.cxx_std }} + + - name: Build + run: cd build ; make -j4 + + - name: Test + run: cd build ; make check diff --git a/include/boost/parser/search.hpp b/include/boost/parser/search.hpp index ef54c945..8d3c63f4 100644 --- a/include/boost/parser/search.hpp +++ b/include/boost/parser/search.hpp @@ -28,10 +28,7 @@ namespace boost::parser { template< typename R_, bool ToCommonRange = false, - text::format OtherRangeFormat = no_format, - bool = std::is_same_v>, - null_sentinel_t> || - text::detail::is_bounded_array_v>> + text::format OtherRangeFormat = no_format> struct to_range { template @@ -75,22 +72,14 @@ namespace boost::parser { return BOOST_PARSER_SUBRANGE(first, last) | as_utf; } + } else if constexpr (OtherRangeFormat == no_format) { + return (R &&) r; } else { return (R &&) r | as_utf; } } }; - template - struct to_range - { - template - static constexpr R && call(R && r) - { - return (R &&) r; - } - }; - template using to_range_t = decltype(to_range::call(std::declval())); From 98f947da533b272fdcfbfa4d544e7b6cf5a9dfda Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Sat, 13 Dec 2025 14:02:17 +0100 Subject: [PATCH 2/4] check for ranges when deciding whether to uses ranges --- include/boost/parser/detail/text/detail/all_t.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/parser/detail/text/detail/all_t.hpp b/include/boost/parser/detail/text/detail/all_t.hpp index 7e65b607..df53f1ea 100644 --- a/include/boost/parser/detail/text/detail/all_t.hpp +++ b/include/boost/parser/detail/text/detail/all_t.hpp @@ -42,7 +42,7 @@ namespace boost::parser::detail::text::detail { template constexpr bool view = #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || \ - (defined(__cpp_lib_concepts) && \ + (defined(__cpp_lib_ranges) && \ (!defined(BOOST_PARSER_GCC) || 12 <= __GNUC__)) std::ranges::view #else From 0766cc0f886b776c43b2b0d8c86cf6b91da8e4c5 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Sat, 13 Dec 2025 14:06:44 +0100 Subject: [PATCH 3/4] check for ranges when deciding whether to uses ranges --- include/boost/parser/detail/text/detail/all_t.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/parser/detail/text/detail/all_t.hpp b/include/boost/parser/detail/text/detail/all_t.hpp index df53f1ea..1e7d2fb4 100644 --- a/include/boost/parser/detail/text/detail/all_t.hpp +++ b/include/boost/parser/detail/text/detail/all_t.hpp @@ -43,7 +43,8 @@ namespace boost::parser::detail::text::detail { constexpr bool view = #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || \ (defined(__cpp_lib_ranges) && \ - (!defined(BOOST_PARSER_GCC) || 12 <= __GNUC__)) + (!defined(BOOST_PARSER_GCC) || 12 <= __GNUC__) && \ + (!defined(__clang_major__) || 16 <= __clang_major__)) std::ranges::view #else range_ && !container_ && From fb4979d73da7aaacc9f513b99240e8092b984be9 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Sat, 13 Dec 2025 14:34:00 +0100 Subject: [PATCH 4/4] more fixes --- include/boost/parser/search.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/boost/parser/search.hpp b/include/boost/parser/search.hpp index 8d3c63f4..b7e4fe64 100644 --- a/include/boost/parser/search.hpp +++ b/include/boost/parser/search.hpp @@ -25,10 +25,16 @@ namespace boost::parser { constexpr auto as_utf = text::detail::as_utf_impl{}; + template + constexpr bool has_special_sentinel_v = + std::is_same_v>, null_sentinel_t> || + text::detail::is_bounded_array_v>; + template< typename R_, bool ToCommonRange = false, - text::format OtherRangeFormat = no_format> + text::format OtherRangeFormat = no_format, + bool HasSpecialSentinel = has_special_sentinel_v> struct to_range { template @@ -36,7 +42,8 @@ namespace boost::parser { { static_assert(std::is_same_v); using T = remove_cv_ref_t; - if constexpr (std::is_same_v, null_sentinel_t>) { + if constexpr (HasSpecialSentinel && + std::is_same_v, null_sentinel_t>) { auto plus_strlen = [](auto * ptr) { while (*ptr) { ++ptr; @@ -60,7 +67,8 @@ namespace boost::parser { return (R &&) r | as_utf; } } - } else if constexpr (text::detail::is_bounded_array_v) { + } else if constexpr (HasSpecialSentinel && + text::detail::is_bounded_array_v) { auto const first = std::begin(r); auto last = std::end(r); constexpr auto n = std::extent_v;