diff --git a/src/catch2/catch_test_macros.hpp b/src/catch2/catch_test_macros.hpp index a5b2d0c3..a3159a3c 100644 --- a/src/catch2/catch_test_macros.hpp +++ b/src/catch2/catch_test_macros.hpp @@ -279,7 +279,7 @@ #define WARN( msg ) (void)(0) #define CAPTURE( msg ) (void)(0) -#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__) #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) #define METHOD_AS_TEST_CASE( method, ... ) #define REGISTER_TEST_CASE( Function, ... ) (void)(0) diff --git a/src/catch2/catch_test_registry.h b/src/catch2/catch_test_registry.h index 3c2c5386..68815752 100644 --- a/src/catch2/catch_test_registry.h +++ b/src/catch2/catch_test_registry.h @@ -54,7 +54,7 @@ struct AutoReg : NonCopyable { #if defined(CATCH_CONFIG_DISABLE) #define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \ - static void TestName() + static inline void TestName() #define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \ namespace{ \ struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ diff --git a/tests/ExtraTests/X02-DisabledMacros.cpp b/tests/ExtraTests/X02-DisabledMacros.cpp index 0577da09..1c7385c7 100644 --- a/tests/ExtraTests/X02-DisabledMacros.cpp +++ b/tests/ExtraTests/X02-DisabledMacros.cpp @@ -16,11 +16,25 @@ struct foo { } }; +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wglobal-constructors" +#endif // Construct foo, but `foo::print` should not be run foo f; + +#if defined(__clang__) +// The test is unused since the registration is disabled +#pragma clang diagnostic ignored "-Wunused-function" +#endif + // This test should not be run, because it won't be registered TEST_CASE( "Disabled Macros" ) { std::cout << "This should not happen\n"; FAIL(); } + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif