Merge pull request #1959 from robinlinden:remove-msvc-workarounds
PiperOrigin-RevId: 221356626
This commit is contained in:
commit
7a0680dc22
|
@ -2485,15 +2485,8 @@ class PropertyMatcher {
|
|||
*listener << whose_property_ << "is ";
|
||||
// Cannot pass the return value (for example, int) to MatchPrintAndExplain,
|
||||
// which takes a non-const reference as argument.
|
||||
#if defined(_PREFAST_ ) && _MSC_VER == 1800
|
||||
// Workaround bug in VC++ 2013's /analyze parser.
|
||||
// https://connect.microsoft.com/VisualStudio/feedback/details/1106363/internal-compiler-error-with-analyze-due-to-failure-to-infer-move
|
||||
posix::Abort(); // To make sure it is never run.
|
||||
return false;
|
||||
#else
|
||||
RefToConstProperty result = (obj.*property_)();
|
||||
return MatchPrintAndExplain(result, matcher_, listener);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,
|
||||
|
|
|
@ -55,10 +55,10 @@
|
|||
#include "gtest/internal/gtest-port.h"
|
||||
#include "gmock/internal/custom/gmock-port.h"
|
||||
|
||||
// For MS Visual C++, check the compiler version. At least VS 2003 is
|
||||
// For MS Visual C++, check the compiler version. At least VS 2015 is
|
||||
// required to compile Google Mock.
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1310
|
||||
# error "At least Visual C++ 2003 (7.1) is required to compile Google Mock."
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
# error "At least Visual C++ 2015 (14.0) is required to compile Google Mock."
|
||||
#endif
|
||||
|
||||
// Macro for referencing flags. This is public as we want the user to
|
||||
|
|
|
@ -50,9 +50,9 @@
|
|||
#endif
|
||||
|
||||
// Silence C4800 (C4800: 'int *const ': forcing value
|
||||
// to bool 'true' or 'false') for MSVC 14,15
|
||||
// to bool 'true' or 'false') for MSVC 15
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER <= 1900
|
||||
#if _MSC_VER == 1900
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4800)
|
||||
#endif
|
||||
|
@ -887,7 +887,7 @@ InSequence::~InSequence() {
|
|||
} // namespace testing
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER <= 1900
|
||||
#if _MSC_VER == 1900
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
// This file tests the built-in actions.
|
||||
|
||||
// Silence C4800 (C4800: 'int *const ': forcing value
|
||||
// to bool 'true' or 'false') for MSVC 14,15
|
||||
// to bool 'true' or 'false') for MSVC 15
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER <= 1900
|
||||
#if _MSC_VER == 1900
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4800)
|
||||
#endif
|
||||
|
|
|
@ -46,13 +46,6 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
// There is a bug in MSVC (fixed in VS 2008) that prevents creating a
|
||||
// mock for a function with const arguments, so we don't test such
|
||||
// cases for MSVC versions older than 2008.
|
||||
#if !GTEST_OS_WINDOWS || (_MSC_VER >= 1500)
|
||||
# define GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
#endif // !GTEST_OS_WINDOWS || (_MSC_VER >= 1500)
|
||||
|
||||
namespace testing {
|
||||
namespace gmock_generated_function_mockers_test {
|
||||
|
||||
|
@ -85,9 +78,7 @@ class FooInterface {
|
|||
|
||||
virtual bool TakesNonConstReference(int& n) = 0; // NOLINT
|
||||
virtual std::string TakesConstReference(const int& n) = 0;
|
||||
#ifdef GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
virtual bool TakesConst(const int x) = 0;
|
||||
#endif // GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
|
||||
virtual int OverloadedOnArgumentNumber() = 0;
|
||||
virtual int OverloadedOnArgumentNumber(int n) = 0;
|
||||
|
@ -136,10 +127,7 @@ class MockFoo : public FooInterface {
|
|||
|
||||
MOCK_METHOD1(TakesNonConstReference, bool(int&)); // NOLINT
|
||||
MOCK_METHOD1(TakesConstReference, std::string(const int&));
|
||||
|
||||
#ifdef GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
MOCK_METHOD1(TakesConst, bool(const int)); // NOLINT
|
||||
#endif
|
||||
|
||||
// Tests that the function return type can contain unprotected comma.
|
||||
MOCK_METHOD0(ReturnTypeWithComma, std::map<int, std::string>());
|
||||
|
@ -249,7 +237,6 @@ TEST_F(FunctionMockerTest, MocksFunctionWithConstReferenceArgument) {
|
|||
EXPECT_EQ("Hello", foo_->TakesConstReference(a));
|
||||
}
|
||||
|
||||
#ifdef GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
// Tests mocking a function that takes a const variable.
|
||||
TEST_F(FunctionMockerTest, MocksFunctionWithConstArgument) {
|
||||
EXPECT_CALL(mock_foo_, TakesConst(Lt(10)))
|
||||
|
@ -257,7 +244,6 @@ TEST_F(FunctionMockerTest, MocksFunctionWithConstArgument) {
|
|||
|
||||
EXPECT_FALSE(foo_->TakesConst(5));
|
||||
}
|
||||
#endif // GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
|
||||
// Tests mocking functions overloaded on the number of arguments.
|
||||
TEST_F(FunctionMockerTest, MocksFunctionsOverloadedOnArgumentNumber) {
|
||||
|
|
|
@ -68,36 +68,14 @@ macro(config_compiler_and_linker)
|
|||
# Newlines inside flags variables break CMake's NMake generator.
|
||||
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
|
||||
set(cxx_base_flags "-GS -W4 -WX -wd4251 -wd4275 -nologo -J -Zi")
|
||||
if (MSVC_VERSION LESS 1400) # 1400 is Visual Studio 2005
|
||||
# Suppress spurious warnings MSVC 7.1 sometimes issues.
|
||||
# Forcing value to bool.
|
||||
set(cxx_base_flags "${cxx_base_flags} -wd4800")
|
||||
# Copy constructor and assignment operator could not be generated.
|
||||
set(cxx_base_flags "${cxx_base_flags} -wd4511 -wd4512")
|
||||
# Compatibility warnings not applicable to Google Test.
|
||||
# Resolved overload was found by argument-dependent lookup.
|
||||
set(cxx_base_flags "${cxx_base_flags} -wd4675")
|
||||
endif()
|
||||
if (MSVC_VERSION LESS 1500) # 1500 is Visual Studio 2008
|
||||
# Conditional expression is constant.
|
||||
# When compiling with /W4, we get several instances of C4127
|
||||
# (Conditional expression is constant). In our code, we disable that
|
||||
# warning on a case-by-case basis. However, on Visual Studio 2005,
|
||||
# the warning fires on std::list. Therefore on that compiler and earlier,
|
||||
# we disable the warning project-wide.
|
||||
set(cxx_base_flags "${cxx_base_flags} -wd4127")
|
||||
endif()
|
||||
if (NOT (MSVC_VERSION LESS 1700)) # 1700 is Visual Studio 2012.
|
||||
# Suppress "unreachable code" warning on VS 2012 and later.
|
||||
# http://stackoverflow.com/questions/3232669 explains the issue.
|
||||
set(cxx_base_flags "${cxx_base_flags} -wd4702")
|
||||
endif()
|
||||
|
||||
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
|
||||
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
|
||||
set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
|
||||
set(cxx_no_exception_flags "-EHs-c- -D_HAS_EXCEPTIONS=0")
|
||||
set(cxx_no_rtti_flags "-GR-")
|
||||
# Suppress "unreachable code" warning
|
||||
# http://stackoverflow.com/questions/3232669 explains the issue.
|
||||
set(cxx_base_flags "${cxx_base_flags} -wd4702")
|
||||
elseif (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(cxx_base_flags "-Wall -Wshadow -Werror")
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)
|
||||
|
@ -219,7 +197,7 @@ endfunction()
|
|||
# is built from the given source files with the given compiler flags.
|
||||
function(cxx_executable_with_flags name cxx_flags libs)
|
||||
add_executable(${name} ${ARGN})
|
||||
if (MSVC AND (NOT (MSVC_VERSION LESS 1700))) # 1700 is Visual Studio 2012.
|
||||
if (MSVC)
|
||||
# BigObj required for tests.
|
||||
set(cxx_flags "${cxx_flags} -bigobj")
|
||||
endif()
|
||||
|
|
|
@ -840,16 +840,6 @@ struct RemoveConst<const T[N]> {
|
|||
typedef typename RemoveConst<T>::type type[N];
|
||||
};
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1400
|
||||
// This is the only specialization that allows VC++ 7.1 to remove const in
|
||||
// 'const int[3] and 'const int[3][4]'. However, it causes trouble with GCC
|
||||
// and thus needs to be conditionally compiled.
|
||||
template <typename T, size_t N>
|
||||
struct RemoveConst<T[N]> {
|
||||
typedef typename RemoveConst<T>::type type[N];
|
||||
};
|
||||
#endif
|
||||
|
||||
// A handy wrapper around RemoveConst that works when the argument
|
||||
// T depends on template parameters.
|
||||
#define GTEST_REMOVE_CONST_(T) \
|
||||
|
|
|
@ -304,14 +304,14 @@
|
|||
// GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
|
||||
// /* code that triggers warnings C4800 and C4385 */
|
||||
// GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#if _MSC_VER >= 1400
|
||||
#if defined(_MSC_VER)
|
||||
# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable: warnings))
|
||||
# define GTEST_DISABLE_MSC_WARNINGS_POP_() \
|
||||
__pragma(warning(pop))
|
||||
#else
|
||||
// Older versions of MSVC don't have __pragma.
|
||||
// Not all compilers are MSVC
|
||||
# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
|
||||
# define GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#endif
|
||||
|
@ -602,15 +602,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
|||
# include <time.h> // NOLINT
|
||||
#endif
|
||||
|
||||
// Determines if hash_map/hash_set are available.
|
||||
// Only used for testing against those containers.
|
||||
#if !defined(GTEST_HAS_HASH_MAP_)
|
||||
# if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||
# define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available.
|
||||
# define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available.
|
||||
# endif // _MSC_VER
|
||||
#endif // !defined(GTEST_HAS_HASH_MAP_)
|
||||
|
||||
// Determines whether clone(2) is supported.
|
||||
// Usually it will only be available on Linux, excluding
|
||||
// Linux on the Itanium architecture.
|
||||
|
@ -653,12 +644,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
|||
#endif // GTEST_HAS_STREAM_REDIRECTION
|
||||
|
||||
// Determines whether to support death tests.
|
||||
// Google Test does not support death tests for VC 7.1 and earlier as
|
||||
// abort() in a VC 7.1 application compiled as GUI in debug config
|
||||
// pops up a dialog window that cannot be suppressed programmatically.
|
||||
#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
|
||||
(GTEST_OS_MAC && !GTEST_OS_IOS) || \
|
||||
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
|
||||
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || \
|
||||
GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
|
||||
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || \
|
||||
GTEST_OS_NETBSD || GTEST_OS_FUCHSIA)
|
||||
|
@ -669,7 +658,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
|||
|
||||
// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
|
||||
// Sun Pro CC, IBM Visual Age, and HP aCC support.
|
||||
#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \
|
||||
#if defined(__GNUC__) || defined(_MSC_VER) || defined(__SUNPRO_CC) || \
|
||||
defined(__IBMCPP__) || defined(__HP_aCC)
|
||||
# define GTEST_HAS_TYPED_TEST 1
|
||||
# define GTEST_HAS_TYPED_TEST_P 1
|
||||
|
@ -2321,13 +2310,12 @@ GTEST_DISABLE_MSC_DEPRECATED_POP_()
|
|||
// MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate
|
||||
// function in order to achieve that. We use macro definition here because
|
||||
// snprintf is a variadic function.
|
||||
#if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
|
||||
#if _MSC_VER && !GTEST_OS_WINDOWS_MOBILE
|
||||
// MSVC 2005 and above support variadic macros.
|
||||
# define GTEST_SNPRINTF_(buffer, size, format, ...) \
|
||||
_snprintf_s(buffer, size, size, format, __VA_ARGS__)
|
||||
#elif defined(_MSC_VER)
|
||||
// Windows CE does not define _snprintf_s and MSVC prior to 2005 doesn't
|
||||
// complain about _snprintf.
|
||||
// Windows CE does not define _snprintf_s
|
||||
# define GTEST_SNPRINTF_ _snprintf
|
||||
#else
|
||||
# define GTEST_SNPRINTF_ snprintf
|
||||
|
|
|
@ -4537,24 +4537,17 @@ void TestEventListeners::SuppressEventForwarding() {
|
|||
// call this before main() starts, from which point on the return
|
||||
// value will never change.
|
||||
UnitTest* UnitTest::GetInstance() {
|
||||
// When compiled with MSVC 7.1 in optimized mode, destroying the
|
||||
// UnitTest object upon exiting the program messes up the exit code,
|
||||
// causing successful tests to appear failed. We have to use a
|
||||
// different implementation in this case to bypass the compiler bug.
|
||||
// This implementation makes the compiler happy, at the cost of
|
||||
// leaking the UnitTest object.
|
||||
|
||||
// CodeGear C++Builder insists on a public destructor for the
|
||||
// default implementation. Use this implementation to keep good OO
|
||||
// design with private destructor.
|
||||
|
||||
#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
|
||||
#if defined(__BORLANDC__)
|
||||
static UnitTest* const instance = new UnitTest;
|
||||
return instance;
|
||||
#else
|
||||
static UnitTest instance;
|
||||
return &instance;
|
||||
#endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
|
||||
#endif // defined(__BORLANDC__)
|
||||
}
|
||||
|
||||
// Gets the number of successful test cases.
|
||||
|
@ -4812,18 +4805,12 @@ int UnitTest::Run() {
|
|||
_set_error_mode(_OUT_TO_STDERR);
|
||||
# endif
|
||||
|
||||
# if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
|
||||
# if defined(_MSC_VER) && !GTEST_OS_WINDOWS_MOBILE
|
||||
// In the debug version, Visual Studio pops up a separate dialog
|
||||
// offering a choice to debug the aborted program. We need to suppress
|
||||
// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
|
||||
// executed. Google Test will notify the user of any unexpected
|
||||
// failure via stderr.
|
||||
//
|
||||
// VC++ doesn't define _set_abort_behavior() prior to the version 8.0.
|
||||
// Users of prior VC versions shall suffer the agony and pain of
|
||||
// clicking through the countless debug dialogs.
|
||||
// FIXME: find a way to suppress the abort dialog() in the
|
||||
// debug mode when compiled with VC 7.1 or lower.
|
||||
if (!GTEST_FLAG(break_on_failure))
|
||||
_set_abort_behavior(
|
||||
0x0, // Clear the following flags:
|
||||
|
|
|
@ -7277,9 +7277,6 @@ TEST(IsHashTable, Basic) {
|
|||
EXPECT_FALSE(testing::internal::IsHashTable<NotReallyAHashTable>::value);
|
||||
EXPECT_FALSE(testing::internal::IsHashTable<std::vector<int>>::value);
|
||||
EXPECT_TRUE(testing::internal::IsHashTable<std::unordered_set<int>>::value);
|
||||
#if GTEST_HAS_HASH_SET_
|
||||
EXPECT_TRUE(testing::internal::IsHashTable<__gnu_cxx::hash_set<int>>::value);
|
||||
#endif // GTEST_HAS_HASH_SET_
|
||||
}
|
||||
|
||||
// Tests ArrayEq().
|
||||
|
|
Loading…
Reference in New Issue
Block a user