Skip to content

Commit 4bac149

Browse files
committed
Supress 'suggest-override' warnings in mocked methods
1 parent cb9e7e2 commit 4bac149

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

include/turtle/config.hpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// http://turtle.sourceforge.net
22
//
33
// Copyright Mathieu Champlon 2009
4-
// Copyright 2020-2025 Alexander Grund
4+
// Copyright 2020-2026 Alexander Grund
55
//
66
// Distributed under the Boost Software License, Version 1.0.
77
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -32,6 +32,27 @@
3232
# endif
3333
#endif
3434

35+
#if defined(__clang__) && defined(__has_warning)
36+
# define MOCK_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
37+
# define MOCK_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
38+
# if __has_warning("-Wsuggest-override")
39+
# define MOCK_DIAGNOSTIC_IGNORE_SUGGEST_OVERRIDE _Pragma("clang diagnostic ignored \"-Wsuggest-override\"")
40+
# endif
41+
#elif defined(__GNUC__)
42+
# define MOCK_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
43+
# define MOCK_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
44+
# if(__GNUC__ >= 9)
45+
# define MOCK_DIAGNOSTIC_IGNORE_SUGGEST_OVERRIDE _Pragma("GCC diagnostic ignored \"-Wsuggest-override\"")
46+
# endif
47+
#endif
48+
#ifndef MOCK_DIAGNOSTIC_PUSH
49+
# define MOCK_DIAGNOSTIC_PUSH
50+
# define MOCK_DIAGNOSTIC_POP
51+
#endif
52+
#ifndef MOCK_DIAGNOSTIC_IGNORE_SUGGEST_OVERRIDE
53+
# define MOCK_DIAGNOSTIC_IGNORE_SUGGEST_OVERRIDE
54+
#endif
55+
3556
#if BOOST_VERSION >= 107700
3657
# define MOCK_CXX_VERSION BOOST_CXX_VERSION
3758
#elif defined(_MSC_VER)

include/turtle/detail/mock_impl.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// http://turtle.sourceforge.net
22
//
33
// Copyright Mathieu Champlon 2008
4-
// Copyright 2022-2025 Alexander Grund
4+
// Copyright 2022-2026 Alexander Grund
55
//
66
// Distributed under the Boost Software License, Version 1.0.
77
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -60,10 +60,13 @@ namespace mock { namespace detail {
6060
#define MOCK_FORWARD_PARAM(z, n, S) std::forward<MOCK_PARAM(S, n)>(p##n)
6161
#define MOCK_FORWARD_PARAMS(n, S) BOOST_PP_ENUM(n, MOCK_FORWARD_PARAM, S)
6262
#define MOCK_METHOD_AUX(name, arity, signature, identifier, qualifier) \
63+
MOCK_DIAGNOSTIC_PUSH \
64+
MOCK_DIAGNOSTIC_IGNORE_SUGGEST_OVERRIDE \
6365
MOCK_DECL(name, arity, signature, qualifier) \
6466
{ \
6567
return MOCK_ANONYMOUS_HELPER(identifier)(MOCK_FORWARD_PARAMS(arity, signature)); \
66-
}
68+
} \
69+
MOCK_DIAGNOSTIC_POP
6770

6871
#define MOCK_METHOD_EXT(name, arity, signature, identifier) \
6972
MOCK_METHOD_AUX(name, arity, signature, identifier, ) \

0 commit comments

Comments
 (0)