From 224b0643ceb74cfc67f9034f79d845367c0363ea Mon Sep 17 00:00:00 2001 From: Sofia Nelcha Date: Mon, 20 Apr 2026 11:32:52 -0400 Subject: [PATCH] Suppress GCC -Weffc++ and -Wctor-dtor-privacy warnings in public headers --- src/catch2/catch_all.hpp | 5 +++++ src/catch2/catch_session.hpp | 8 ++++++++ src/catch2/catch_template_test_macros.hpp | 7 +++++++ src/catch2/catch_test_macros.hpp | 8 ++++++++ src/catch2/generators/catch_generators.hpp | 8 ++++++++ src/catch2/internal/catch_compiler_capabilities.hpp | 12 ++++++++++++ src/catch2/matchers/catch_matchers.hpp | 8 ++++++++ 7 files changed, 56 insertions(+) diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index 97226dd115..cddf913627 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -53,6 +53,9 @@ #include #include #include +CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +CATCH_INTERNAL_SUPPRESS_EFFCPP_WARNINGS +CATCH_INTERNAL_SUPPRESS_CTOR_DTOR_PRIVACY_WARNINGS #include #include #include @@ -138,4 +141,6 @@ #include #include +CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + #endif // CATCH_ALL_HPP_INCLUDED diff --git a/src/catch2/catch_session.hpp b/src/catch2/catch_session.hpp index 23fc6f80ce..aa115d3c58 100644 --- a/src/catch2/catch_session.hpp +++ b/src/catch2/catch_session.hpp @@ -8,6 +8,12 @@ #ifndef CATCH_SESSION_HPP_INCLUDED #define CATCH_SESSION_HPP_INCLUDED +#include + +CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +CATCH_INTERNAL_SUPPRESS_EFFCPP_WARNINGS +CATCH_INTERNAL_SUPPRESS_CTOR_DTOR_PRIVACY_WARNINGS + #include #include #include @@ -67,4 +73,6 @@ namespace Catch { } // end namespace Catch +CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + #endif // CATCH_SESSION_HPP_INCLUDED diff --git a/src/catch2/catch_template_test_macros.hpp b/src/catch2/catch_template_test_macros.hpp index 3baee51753..d7fca35683 100644 --- a/src/catch2/catch_template_test_macros.hpp +++ b/src/catch2/catch_template_test_macros.hpp @@ -8,6 +8,8 @@ #ifndef CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED #define CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED +#include + // We need this suppression to leak, because it took until GCC 10 // for the front end to handle local suppression via _Pragma properly // inside templates (so `TEMPLATE_TEST_CASE` and co). @@ -16,6 +18,10 @@ #pragma GCC diagnostic ignored "-Wparentheses" #endif +CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +CATCH_INTERNAL_SUPPRESS_EFFCPP_WARNINGS +CATCH_INTERNAL_SUPPRESS_CTOR_DTOR_PRIVACY_WARNINGS + #include #include @@ -120,5 +126,6 @@ #endif // end of user facing macro declarations +CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION #endif // CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED diff --git a/src/catch2/catch_test_macros.hpp b/src/catch2/catch_test_macros.hpp index 97708557f9..3f25f0560c 100644 --- a/src/catch2/catch_test_macros.hpp +++ b/src/catch2/catch_test_macros.hpp @@ -8,6 +8,12 @@ #ifndef CATCH_TEST_MACROS_HPP_INCLUDED #define CATCH_TEST_MACROS_HPP_INCLUDED +#include + +CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +CATCH_INTERNAL_SUPPRESS_EFFCPP_WARNINGS +CATCH_INTERNAL_SUPPRESS_CTOR_DTOR_PRIVACY_WARNINGS + #include #include #include @@ -240,4 +246,6 @@ // end of user facing macros +CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + #endif // CATCH_TEST_MACROS_HPP_INCLUDED diff --git a/src/catch2/generators/catch_generators.hpp b/src/catch2/generators/catch_generators.hpp index afb39f865b..00e7d9c047 100644 --- a/src/catch2/generators/catch_generators.hpp +++ b/src/catch2/generators/catch_generators.hpp @@ -8,6 +8,12 @@ #ifndef CATCH_GENERATORS_HPP_INCLUDED #define CATCH_GENERATORS_HPP_INCLUDED +#include + +CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +CATCH_INTERNAL_SUPPRESS_EFFCPP_WARNINGS +CATCH_INTERNAL_SUPPRESS_CTOR_DTOR_PRIVACY_WARNINGS + #include #include #include @@ -258,4 +264,6 @@ namespace Generators { CATCH_INTERNAL_LINEINFO, \ [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) +CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + #endif // CATCH_GENERATORS_HPP_INCLUDED diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index aa3af502e0..b3c7f79716 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -62,6 +62,12 @@ # define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ _Pragma( "GCC diagnostic ignored \"-Wshadow\"" ) +# define CATCH_INTERNAL_SUPPRESS_EFFCPP_WARNINGS \ + _Pragma( "GCC diagnostic ignored \"-Weffc++\"" ) + +# define CATCH_INTERNAL_SUPPRESS_CTOR_DTOR_PRIVACY_WARNINGS \ + _Pragma( "GCC diagnostic ignored \"-Wctor-dtor-privacy\"" ) + # define CATCH_INTERNAL_CONFIG_USE_BUILTIN_CONSTANT_P #endif @@ -429,6 +435,12 @@ #if !defined( CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS ) # define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS #endif +#if !defined( CATCH_INTERNAL_SUPPRESS_EFFCPP_WARNINGS ) +# define CATCH_INTERNAL_SUPPRESS_EFFCPP_WARNINGS +#endif +#if !defined( CATCH_INTERNAL_SUPPRESS_CTOR_DTOR_PRIVACY_WARNINGS ) +# define CATCH_INTERNAL_SUPPRESS_CTOR_DTOR_PRIVACY_WARNINGS +#endif #if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) # undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS diff --git a/src/catch2/matchers/catch_matchers.hpp b/src/catch2/matchers/catch_matchers.hpp index 90ed333854..8c7e5384c0 100644 --- a/src/catch2/matchers/catch_matchers.hpp +++ b/src/catch2/matchers/catch_matchers.hpp @@ -8,6 +8,12 @@ #ifndef CATCH_MATCHERS_HPP_INCLUDED #define CATCH_MATCHERS_HPP_INCLUDED +#include + +CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +CATCH_INTERNAL_SUPPRESS_EFFCPP_WARNINGS +CATCH_INTERNAL_SUPPRESS_CTOR_DTOR_PRIVACY_WARNINGS + #include #include #include @@ -250,4 +256,6 @@ namespace Matchers { #endif // end of user facing macro declarations +CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + #endif // CATCH_MATCHERS_HPP_INCLUDED