diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index 0a0334964..f0218b792 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -1222,23 +1222,26 @@ class Foo { // Tests InvokeWithoutArgs(function). TEST(InvokeWithoutArgsTest, Function) { + GTEST_DISABLE_DEPRECATED_PUSH_() // As an action that takes one argument. - Action a = Nullary; // NOLINT + Action a = InvokeWithoutArgs(Nullary); // NOLINT EXPECT_EQ(1, a.Perform(std::make_tuple(2))); // As an action that takes two arguments. - Action a2 = Nullary; // NOLINT + Action a2 = InvokeWithoutArgs(Nullary); // NOLINT EXPECT_EQ(1, a2.Perform(std::make_tuple(2, 3.5))); // As an action that returns void. - Action a3 = VoidNullary; // NOLINT + Action a3 = InvokeWithoutArgs(VoidNullary); // NOLINT g_done = false; a3.Perform(std::make_tuple(1)); EXPECT_TRUE(g_done); + GTEST_DISABLE_DEPRECATED_POP_() } // Tests InvokeWithoutArgs(functor). TEST(InvokeWithoutArgsTest, Functor) { + GTEST_DISABLE_DEPRECATED_PUSH_() // As an action that takes no argument. Action a = InvokeWithoutArgs(NullaryFunctor()); // NOLINT EXPECT_EQ(2, a.Perform(std::make_tuple())); @@ -1253,6 +1256,7 @@ TEST(InvokeWithoutArgsTest, Functor) { g_done = false; a3.Perform(std::make_tuple()); EXPECT_TRUE(g_done); + GTEST_DISABLE_DEPRECATED_POP_() } // Tests InvokeWithoutArgs(obj_ptr, method). diff --git a/googlemock/test/gmock_link_test.h b/googlemock/test/gmock_link_test.h index 41bfba055..6f749bb56 100644 --- a/googlemock/test/gmock_link_test.h +++ b/googlemock/test/gmock_link_test.h @@ -338,10 +338,12 @@ TEST(LinkTest, TestInvokeWithoutArgs) { Mock mock; InvokeHelper test_invoke_helper; + GTEST_DISABLE_DEPRECATED_PUSH_() EXPECT_CALL(mock, VoidFromString(_)) .WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid)) .WillOnce( InvokeWithoutArgs(&test_invoke_helper, &InvokeHelper::VoidFromVoid)); + GTEST_DISABLE_DEPRECATED_POP_() mock.VoidFromString(nullptr); mock.VoidFromString(nullptr); } diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 8b32daece..df10ca651 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -363,18 +363,24 @@ #define GTEST_DISABLE_MSC_WARNINGS_POP_() #endif -// Clang on Windows does not understand MSVC's pragma warning. -// We need clang-specific way to disable function deprecation warning. -#ifdef __clang__ -#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ +// Pragmas to disable function deprecation warnings. +#if defined(__clang__) +#define GTEST_DISABLE_DEPRECATED_PUSH_() \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \ _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"") -#define GTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop") +#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop") +#elif defined(__GNUC__) +#define GTEST_DISABLE_DEPRECATED_PUSH_() \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop") +#elif defined(_MSC_VER) +#define GTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) +#define GTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_() #else -#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ - GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) -#define GTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_() +#define GTEST_DISABLE_DEPRECATED_PUSH_() +#define GTEST_DISABLE_DEPRECATED_POP_() #endif // Brings in definitions for functions used in the testing::internal::posix @@ -2119,7 +2125,7 @@ inline int IsATTY(int fd) { // Functions deprecated by MSVC 8.0. -GTEST_DISABLE_MSC_DEPRECATED_PUSH_() +GTEST_DISABLE_DEPRECATED_PUSH_() // ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and // StrError() aren't needed on Windows CE at this time and thus not @@ -2181,7 +2187,7 @@ inline const char* GetEnv(const char* name) { #endif } -GTEST_DISABLE_MSC_DEPRECATED_POP_() +GTEST_DISABLE_DEPRECATED_POP_() #ifdef GTEST_OS_WINDOWS_MOBILE // Windows CE has no C library. The abort() function is used in diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index d34a693e4..4f4f2d8b2 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -1069,7 +1069,7 @@ GTestLog::~GTestLog() { // Disable Microsoft deprecation warnings for POSIX functions called from // this class (creat, dup, dup2, and close) -GTEST_DISABLE_MSC_DEPRECATED_PUSH_() +GTEST_DISABLE_DEPRECATED_PUSH_() namespace { @@ -1200,7 +1200,7 @@ class CapturedStream { CapturedStream& operator=(const CapturedStream&) = delete; }; -GTEST_DISABLE_MSC_DEPRECATED_POP_() +GTEST_DISABLE_DEPRECATED_POP_() static CapturedStream* g_captured_stderr = nullptr; static CapturedStream* g_captured_stdout = nullptr; diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 8ce64d386..c753c3602 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -442,11 +442,11 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { void SetUp() override { saved_tz_.reset(); - GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv: deprecated */) + GTEST_DISABLE_DEPRECATED_PUSH_(/* getenv: deprecated */) if (const char* tz = getenv("TZ")) { saved_tz_ = std::make_unique(tz); } - GTEST_DISABLE_MSC_DEPRECATED_POP_() + GTEST_DISABLE_DEPRECATED_POP_() // Set the local time zone for FormatEpochTimeInMillisAsIso8601 to be // a fixed time zone for reproducibility purposes.