From b8ef9ec1788708cf37e483e7c26554370ea0ce56 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sat, 24 Sep 2022 02:11:41 +0100 Subject: [PATCH] Disable inconsistent missing override warnings in qa mocks turtlemocks doesn't seem to provide a way to annotate that these methods override a base class method, so it triggers a lot of warnings about missing override when the classes are instantiated. --- cmake/Warnings.cmake | 4 ++++ cmake/config.h.cmake | 3 +++ qa/mocks/include/mock_kiface_base.h | 12 ++++++++++++ qa/mocks/include/mock_pgm_base.h | 12 ++++++++++++ 4 files changed, 31 insertions(+) diff --git a/cmake/Warnings.cmake b/cmake/Warnings.cmake index 44ce2b8141..16932ebd1f 100644 --- a/cmake/Warnings.cmake +++ b/cmake/Warnings.cmake @@ -52,6 +52,10 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) if( COMPILER_SUPPORTS_WINCONSISTENT_MISSING_OVERRIDE ) set( WARN_FLAGS_CXX "${WARN_FLAGS_CXX} -Winconsistent-missing-override" ) + + # Also use this to guard warning removal of the warning inside the code + set( HAVE_WINCONSISTENT_MISSING_OVERRIDE true ) + message( STATUS "Enabling warning -Winconsistent-missing-override" ) endif() diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index d69d70e6ab..3a41b34f24 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -52,6 +52,9 @@ // Does the compiler support the -Wimplicit-int-float-conversion warning #cmakedefine HAVE_WIMPLICIT_FLOAT_CONVERSION +// Does the compiler support the -Winconsistent-missing-override +#cmakedefine HAVE_WINCONSISTENT_MISSING_OVERRIDE + // Use Posix getc_unlocked() instead of getc() when it's available. #cmakedefine HAVE_FGETC_NOLOCK diff --git a/qa/mocks/include/mock_kiface_base.h b/qa/mocks/include/mock_kiface_base.h index f2795c9974..c54d62e4a9 100644 --- a/qa/mocks/include/mock_kiface_base.h +++ b/qa/mocks/include/mock_kiface_base.h @@ -24,6 +24,14 @@ #pragma once #include #include +#include + +// Suppress a warning that the mock methods don't override the base class methods because +// turtlemocks doesn't seem to provide a way to actually annotate the methods with override. +#ifdef HAVE_WINCONSISTENT_MISSING_OVERRIDE + _Pragma( "GCC diagnostic push" ) \ + _Pragma( "GCC diagnostic ignored \"-Winconsistent-missing-override\"" ) +#endif MOCK_BASE_CLASS( MOCK_KIFACE_BASE, KIFACE_BASE ) { @@ -35,3 +43,7 @@ MOCK_BASE_CLASS( MOCK_KIFACE_BASE, KIFACE_BASE ) MOCK_METHOD( CreateWindow, 4, wxWindow*( wxWindow*, int, KIWAY*, int ) ); MOCK_METHOD( IfaceOrAddress, 1, void*( int ) ); }; + +#ifdef HAVE_WINCONSISTENT_MISSING_OVERRIDE + _Pragma( "GCC diagnostic pop" ) +#endif diff --git a/qa/mocks/include/mock_pgm_base.h b/qa/mocks/include/mock_pgm_base.h index e2a12bf25a..1c26743734 100644 --- a/qa/mocks/include/mock_pgm_base.h +++ b/qa/mocks/include/mock_pgm_base.h @@ -24,6 +24,14 @@ #pragma once #include #include +#include + +// Suppress a warning that the mock methods don't override the base class methods because +// turtlemocks doesn't seem to provide a way to actually annotate the methods with override. +#ifdef HAVE_WINCONSISTENT_MISSING_OVERRIDE + _Pragma( "GCC diagnostic push" ) \ + _Pragma( "GCC diagnostic ignored \"-Winconsistent-missing-override\"" ) +#endif MOCK_BASE_CLASS( MOCK_PGM_BASE, PGM_BASE ) { @@ -62,3 +70,7 @@ MOCK_BASE_CLASS( MOCK_PGM_BASE, PGM_BASE ) // MOCK_CONST_METHOD( GetExecutablePath, 0, const wxString&() ); // MOCK_METHOD( GetSettingsManager, 0, SETTINGS_MANAGER&() ); }; + +#ifdef HAVE_WINCONSISTENT_MISSING_OVERRIDE + _Pragma( "GCC diagnostic pop" ) +#endif