Remove workarounds for MSVC with versions _MSC_VER < 1925

GoogleTest only supports Visual Studio 2022 or later.

PiperOrigin-RevId: 975742423
Change-Id: Ibc09f5cd2c8cb1f9097bd27b584ec136ec2ce42a
This commit is contained in:
Abseil Team 2026-09-03 08:28:12 -07:00 committed by Copybara-Service
parent efbef50b59
commit 283c17563f
7 changed files with 15 additions and 36 deletions

View File

@ -69,7 +69,7 @@ IF EXIST "%KOKORO_GFILE_DIR%\distdir\googletest_vendor.tar.gz" (
--keep_going ^ --keep_going ^
--per_file_copt=external/.*@/w ^ --per_file_copt=external/.*@/w ^
--test_output=errors ^ --test_output=errors ^
--test_tag_filters=-no_test_msvc2017 ^ --test_tag_filters=-no_test_msvc2022 ^
%VENDOR_FLAG% %VENDOR_FLAG%
IF %errorlevel% neq 0 EXIT /B 1 IF %errorlevel% neq 0 EXIT /B 1
@ -84,6 +84,6 @@ IF %errorlevel% neq 0 EXIT /B 1
--keep_going ^ --keep_going ^
--per_file_copt=external/.*@/w ^ --per_file_copt=external/.*@/w ^
--test_output=errors ^ --test_output=errors ^
--test_tag_filters=-no_test_msvc2017 ^ --test_tag_filters=-no_test_msvc2022 ^
%VENDOR_FLAG% %VENDOR_FLAG%
IF %errorlevel% neq 0 EXIT /B 1 IF %errorlevel% neq 0 EXIT /B 1

View File

@ -277,13 +277,6 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-internal.h"
// MSVC warning C5046 is new as of VS2017 version 15.8.
#if defined(_MSC_VER) && _MSC_VER >= 1915
#define GMOCK_MAYBE_5046_ 5046
#else
#define GMOCK_MAYBE_5046_
#endif
#if GTEST_HAS_RTTI #if GTEST_HAS_RTTI
namespace proto2 { namespace proto2 {
namespace internal { namespace internal {
@ -324,7 +317,7 @@ T* DynamicCastMessageForGtest(proto2::MessageLite* msg) {
GTEST_DISABLE_MSC_WARNINGS_PUSH_( GTEST_DISABLE_MSC_WARNINGS_PUSH_(
// class A needs to have dll-interface to be used by clients of class B // class A needs to have dll-interface to be used by clients of class B
4251 GMOCK_MAYBE_5046_ 4251 5046
/* Symbol involving type with internal linkage not defined */) /* Symbol involving type with internal linkage not defined */)
namespace testing { namespace testing {

View File

@ -62,10 +62,11 @@
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#endif #endif
// For MS Visual C++, check the compiler version. At least VS 2015 is // For MS Visual C++, check the compiler version. At least VS 2022 is
// required to compile Google Mock. // required to compile Google Mock (_MSC_VER >= 1930). We use a slightly lower
#if defined(_MSC_VER) && _MSC_VER < 1900 // version for internal toolchains lagging behind.
#error "At least Visual C++ 2015 (14.0) is required to compile Google Mock." #if defined(_MSC_VER) && _MSC_VER < 1925
#error "At least Visual C++ 2022 (17.0) is required to compile Google Mock."
#endif #endif
// Macro for referencing flags. This is public as we want the user to // Macro for referencing flags. This is public as we want the user to

View File

@ -74,8 +74,7 @@ py_test(
":gmock_test_utils", ":gmock_test_utils",
], ],
tags = [ tags = [
"no_test_msvc2015", "no_test_msvc2022",
"no_test_msvc2017",
], ],
) )
@ -105,8 +104,7 @@ py_test(
":gmock_output_test_golden.txt", ":gmock_output_test_golden.txt",
], ],
tags = [ tags = [
"no_test_msvc2015", "no_test_msvc2022",
"no_test_msvc2017",
], ],
deps = [":gmock_test_utils"], deps = [":gmock_test_utils"],
) )

View File

@ -143,11 +143,9 @@ class GTEST_API_ [[nodiscard]] AssertionResult {
// Used in EXPECT_TRUE/FALSE(assertion_result). // Used in EXPECT_TRUE/FALSE(assertion_result).
AssertionResult(const AssertionResult& other); AssertionResult(const AssertionResult& other);
// C4800 is off by default starting in Visual Studio 2019 but can be // C4800 is off by default starting in Visual Studio 2019 but can be
// enabled with command-line options. // enabled with command-line options.
#if defined(_MSC_VER) && _MSC_VER >= 1920
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */) GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)
#endif
// Used in the EXPECT_TRUE/FALSE(bool_expression). // Used in the EXPECT_TRUE/FALSE(bool_expression).
// //
@ -169,9 +167,7 @@ class GTEST_API_ [[nodiscard]] AssertionResult {
int> = 0> int> = 0>
explicit AssertionResult(const T& success) : success_(success) {} explicit AssertionResult(const T& success) : success_(success) {}
#if defined(_MSC_VER) && _MSC_VER >= 1920
GTEST_DISABLE_MSC_WARNINGS_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
#endif
// Assignment operator. // Assignment operator.
AssertionResult& operator=(AssertionResult other) { AssertionResult& operator=(AssertionResult other) {

View File

@ -52,16 +52,9 @@
#include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-port.h"
// MSVC warning C5046 is new as of VS2017 version 15.8.
#if defined(_MSC_VER) && _MSC_VER >= 1915
#define GTEST_MAYBE_5046_ 5046
#else
#define GTEST_MAYBE_5046_
#endif
GTEST_DISABLE_MSC_WARNINGS_PUSH_( GTEST_DISABLE_MSC_WARNINGS_PUSH_(
// class A needs to have dll-interface to be used by clients of class B // class A needs to have dll-interface to be used by clients of class B
4251 GTEST_MAYBE_5046_ 4251 5046
/* Symbol involving type with internal linkage not defined */) /* Symbol involving type with internal linkage not defined */)
namespace testing { namespace testing {

View File

@ -611,8 +611,7 @@ py_test(
srcs = ["googletest-param-test-invalid-name1-test.py"], srcs = ["googletest-param-test-invalid-name1-test.py"],
data = [":googletest-param-test-invalid-name1-test_"], data = [":googletest-param-test-invalid-name1-test_"],
tags = [ tags = [
"no_test_msvc2015", "no_test_msvc2022",
"no_test_msvc2017",
], ],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )
@ -623,8 +622,7 @@ py_test(
srcs = ["googletest-param-test-invalid-name2-test.py"], srcs = ["googletest-param-test-invalid-name2-test.py"],
data = [":googletest-param-test-invalid-name2-test_"], data = [":googletest-param-test-invalid-name2-test_"],
tags = [ tags = [
"no_test_msvc2015", "no_test_msvc2022",
"no_test_msvc2017",
], ],
deps = [":gtest_test_utils"], deps = [":gtest_test_utils"],
) )