diff options
| author | Matt Van Horn | 2026-08-20 16:39:01 +0100 |
|---|---|---|
| committer | GitHub | 2026-08-20 17:39:01 +0200 |
| commit | fdfc07e571eb7f046013052a9fa57db51c6a2cb9 (patch) | |
| tree | eadfb8a5ca4c95f97dd56fd4854e74b3575268b3 | |
| parent | 8582805f548e3e091d8d35188f4c3a690f989b0f (diff) | |
| download | catch3-fdfc07e571eb7f046013052a9fa57db51c6a2cb9.tar.gz | |
fix: work around clang 20/21 + libc++ compile failure in TEMPLATE_PRODUCT_TEST_CASE with differing arities (#3173)
* fix: work around clang 20/21 + libc++ compile failure in TEMPLATE_PRODUCT_TEST_CASE with differing arities
Fixes #3115
* docs: reference llvm/llvm-project#130778 in the clang 20/21 workaround comment
---------
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
| -rw-r--r-- | src/catch2/internal/catch_preprocessor.hpp | 11 | ||||
| -rw-r--r-- | src/catch2/internal/catch_template_test_registry.hpp | 4 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/catch2/internal/catch_preprocessor.hpp b/src/catch2/internal/catch_preprocessor.hpp index 1fc8fb8c..fae95e9d 100644 --- a/src/catch2/internal/catch_preprocessor.hpp +++ b/src/catch2/internal/catch_preprocessor.hpp @@ -113,8 +113,11 @@ namespace Catch { template<typename... Ts>\ constexpr auto get_wrapper(Catch::Detail::priority_tag<1>) noexcept -> TypeList<Ts...> { return {}; }\ template<template<typename...> class...> struct TemplateTypeList{};\ - template<template<typename...> class...Cs>\ - constexpr auto get_wrapper(Catch::Detail::priority_tag<1>) noexcept -> TemplateTypeList<Cs...> { return {}; }\ + /* Clang 20 and 21 cannot handle an explicitly specified all-pack template-template parameter here\ + ("conflicting deduction" regression, llvm/llvm-project#130778; fixed for Clang 22).\ + Remove get_template_wrapper once Clang 21 is no longer supported. */\ + template<template<typename...> class C, template<typename...> class...Cs>\ + constexpr auto get_template_wrapper(Catch::Detail::priority_tag<1>) noexcept -> TemplateTypeList<C, Cs...> { return {}; }\ template<typename...>\ struct append;\ template<typename...>\ @@ -146,8 +149,8 @@ namespace Catch { template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\ constexpr auto get_wrapper(Catch::Detail::priority_tag<0>) noexcept -> Nttp<__VA_ARGS__> { return {}; } \ template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...> struct NttpTemplateTypeList{};\ - template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Cs>\ - constexpr auto get_wrapper(Catch::Detail::priority_tag<0>) noexcept -> NttpTemplateTypeList<Cs...> { return {}; } \ + template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class C, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Cs>\ + constexpr auto get_template_wrapper(Catch::Detail::priority_tag<0>) noexcept -> NttpTemplateTypeList<C, Cs...> { return {}; } \ \ template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature)>\ struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>> { using type = TypeList<Container<__VA_ARGS__>>; };\ diff --git a/src/catch2/internal/catch_template_test_registry.hpp b/src/catch2/internal/catch_template_test_registry.hpp index 400c308c..96b76aaf 100644 --- a/src/catch2/internal/catch_template_test_registry.hpp +++ b/src/catch2/internal/catch_template_test_registry.hpp @@ -139,7 +139,7 @@ } \ }; \ static const int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \ - using TestInit = typename create<TestName, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>(Catch::Detail::priority_tag<1>{})), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type; \ + using TestInit = typename create<TestName, decltype(get_template_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>(Catch::Detail::priority_tag<1>{})), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type; \ TestInit t; \ t.reg_tests(); \ return 0; \ @@ -271,7 +271,7 @@ }\ };\ static const int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ - using TestInit = typename create<TestNameClass, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>(Catch::Detail::priority_tag<1>{})), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type;\ + using TestInit = typename create<TestNameClass, decltype(get_template_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>(Catch::Detail::priority_tag<1>{})), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type;\ TestInit t;\ t.reg_tests();\ return 0;\ |