mirror of
https://github.com/google/googletest.git
synced 2025-01-14 00:20:57 +08:00
Mark ACTION_Pn()-generated functions as must-use-result, adding non-compilation tests.
This catches when a client creates an action and discards it, thinking that the action has actually been applied to something. This will help people who make the mistake of defining, for example, both `void Use(Foo*, Bar)` and `ACTION_P(Use, bar) { Use(arg, bar); }` for later application to a Foo. With such an overload, a client may then write `Use(bar);`, selecting the Action<> overload and being confused why nothing happens. This also catches when a client defines their own action in terms of an ACTION_P()-generated one, invokes the Action<>'s builder, and then fails to invoke the resulting action, thinking it's operating on the outer action's parameters. PiperOrigin-RevId: 433197479 Change-Id: I98e4389150d01a5e753230113016d9fc38b1d260
This commit is contained in:
parent
c9461a9b55
commit
ae1b7ad430
@ -1610,6 +1610,9 @@ template <typename F, typename Impl>
|
||||
std::shared_ptr<const gmock_Impl> impl_; \
|
||||
}; \
|
||||
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
|
||||
inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
|
||||
GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) GTEST_MUST_USE_RESULT_; \
|
||||
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
|
||||
inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
|
||||
GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) { \
|
||||
return full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>( \
|
||||
|
Loading…
x
Reference in New Issue
Block a user