Supress 'suggest-override' warnings in mocked methods

This commit is contained in:
Alexander Grund 2026-06-23 16:26:30 +02:00
parent 1c168d57fb
commit 90f2b84259
No known key found for this signature in database
GPG key ID: AA48A0760367A42B
2 changed files with 27 additions and 3 deletions

View file

@ -1,7 +1,7 @@
// http://turtle.sourceforge.net
//
// Copyright Mathieu Champlon 2009
// Copyright 2020-2025 Alexander Grund
// Copyright 2020-2026 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@ -32,6 +32,27 @@
# endif
#endif
#if defined(__clang__) && defined(__has_warning)
# define MOCK_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
# define MOCK_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
# if __has_warning("-Wsuggest-override")
# define MOCK_DIAGNOSTIC_IGNORE_SUGGEST_OVERRIDE _Pragma("clang diagnostic ignored \"-Wsuggest-override\"")
# endif
#elif defined(__GNUC__)
# define MOCK_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
# define MOCK_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
# if(__GNUC__ >= 9)
# define MOCK_DIAGNOSTIC_IGNORE_SUGGEST_OVERRIDE _Pragma("GCC diagnostic ignored \"-Wsuggest-override\"")
# endif
#endif
#ifndef MOCK_DIAGNOSTIC_PUSH
# define MOCK_DIAGNOSTIC_PUSH
# define MOCK_DIAGNOSTIC_POP
#endif
#ifndef MOCK_DIAGNOSTIC_IGNORE_SUGGEST_OVERRIDE
# define MOCK_DIAGNOSTIC_IGNORE_SUGGEST_OVERRIDE
#endif
#if BOOST_VERSION >= 107700
# define MOCK_CXX_VERSION BOOST_CXX_VERSION
#elif defined(_MSC_VER)

View file

@ -1,7 +1,7 @@
// http://turtle.sourceforge.net
//
// Copyright Mathieu Champlon 2008
// Copyright 2022-2025 Alexander Grund
// Copyright 2022-2026 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@ -60,10 +60,13 @@ namespace mock { namespace detail {
#define MOCK_FORWARD_PARAM(z, n, S) std::forward<MOCK_PARAM(S, n)>(p##n)
#define MOCK_FORWARD_PARAMS(n, S) BOOST_PP_ENUM(n, MOCK_FORWARD_PARAM, S)
#define MOCK_METHOD_AUX(name, arity, signature, identifier, qualifier) \
MOCK_DIAGNOSTIC_PUSH \
MOCK_DIAGNOSTIC_IGNORE_SUGGEST_OVERRIDE \
MOCK_DECL(name, arity, signature, qualifier) \
{ \
return MOCK_ANONYMOUS_HELPER(identifier)(MOCK_FORWARD_PARAMS(arity, signature)); \
}
} \
MOCK_DIAGNOSTIC_POP
#define MOCK_METHOD_EXT(name, arity, signature, identifier) \
MOCK_METHOD_AUX(name, arity, signature, identifier, ) \