From a25f43576effe4ebe887412a603cddfa8fc3ba64 Mon Sep 17 00:00:00 2001 From: Bogdan Graur Date: Wed, 15 Jul 2026 18:50:43 -0700 Subject: [PATCH] Fixes `-Wtautological-pointer-compare` in gmock-matchers PiperOrigin-RevId: 948667420 Change-Id: Ibb35d7e6469a193607a72f10377ef3a494f9525f --- googlemock/include/gmock/gmock-matchers.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 7407e119e..603a5029f 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -821,7 +821,11 @@ class [[nodiscard]] IsNullMatcher { template bool MatchAndExplain(const Pointer& p, MatchResultListener* /* listener */) const { - return p == nullptr; + if constexpr (std::is_function_v) { + return false; + } else { + return p == nullptr; + } } void DescribeTo(::std::ostream* os) const { *os << "is NULL"; } @@ -835,7 +839,11 @@ class [[nodiscard]] NotNullMatcher { template bool MatchAndExplain(const Pointer& p, MatchResultListener* /* listener */) const { - return p != nullptr; + if constexpr (std::is_function_v) { + return true; + } else { + return p != nullptr; + } } void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; }