diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index 59839c17..2bbee6bc 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -114,6 +114,11 @@ _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) # endif +# if ( __clang_major__ >= 22 ) +# define CATCH_INTERNAL_SUPPRESS_COUNTER_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wc2y-extensions\"" ) +# endif + # define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) @@ -429,6 +434,9 @@ #if !defined( CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS ) # define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS #endif +#if !defined( CATCH_INTERNAL_SUPPRESS_COUNTER_WARNINGS ) +# define CATCH_INTERNAL_SUPPRESS_COUNTER_WARNINGS +#endif #if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) # undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS diff --git a/src/catch2/internal/catch_unique_name.hpp b/src/catch2/internal/catch_unique_name.hpp index c6e1c2ca..b8c08fa2 100644 --- a/src/catch2/internal/catch_unique_name.hpp +++ b/src/catch2/internal/catch_unique_name.hpp @@ -8,9 +8,22 @@ #ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED #define CATCH_UNIQUE_NAME_HPP_INCLUDED +#include #include + +// Fixme: Clang 22 has an annoying bug where the localized suppression +// below does not actually suppress the extension warning from +// using __COUNTER__, so we have to leak the suppression for the +// whole TU. Hopefully Clang 23 fixes this before full release. +// As AppleClang does its own thing version-wise, we ignore it +// completely. +#if defined( __clang__ ) && ( __clang_major__ >= 22 ) && !defined( __APPLE__ ) +CATCH_INTERNAL_SUPPRESS_COUNTER_WARNINGS +#endif + #define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line #define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) + #ifdef CATCH_CONFIG_COUNTER # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) #else