diff options
author | Robin Lindén <dev@robinlinden.eu> | 2018-11-10 14:05:55 (GMT) |
---|---|---|
committer | Robin Lindén <dev@robinlinden.eu> | 2018-11-10 14:20:26 (GMT) |
commit | 826656b25f62ed0a2fadc7c5dde303616e621c08 (patch) | |
tree | 01db8e689dc6d256d0a5d65dad6d714cc39b8273 | |
parent | de5be0eb28b74ecd6335e3bd61d9dc8914ce0e57 (diff) | |
download | googletest-826656b25f62ed0a2fadc7c5dde303616e621c08.zip googletest-826656b25f62ed0a2fadc7c5dde303616e621c08.tar.gz googletest-826656b25f62ed0a2fadc7c5dde303616e621c08.tar.bz2 |
Remove workarounds for unsupported MSVC versions
-rw-r--r-- | googlemock/include/gmock/gmock-matchers.h | 7 | ||||
-rw-r--r-- | googlemock/include/gmock/internal/gmock-port.h | 6 | ||||
-rw-r--r-- | googlemock/src/gmock-spec-builders.cc | 6 | ||||
-rw-r--r-- | googlemock/test/gmock-actions_test.cc | 4 | ||||
-rw-r--r-- | googlemock/test/gmock-generated-function-mockers_test.cc | 7 | ||||
-rw-r--r-- | googletest/cmake/internal_utils.cmake | 27 | ||||
-rw-r--r-- | googletest/include/gtest/internal/gtest-internal.h | 10 | ||||
-rw-r--r-- | googletest/include/gtest/internal/gtest-port.h | 17 | ||||
-rw-r--r-- | googletest/src/gtest.cc | 19 |
9 files changed, 19 insertions, 84 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 95bc22c..18a1c94 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -2484,15 +2484,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, diff --git a/googlemock/include/gmock/internal/gmock-port.h b/googlemock/include/gmock/internal/gmock-port.h index c593249..063e292 100644 --- a/googlemock/include/gmock/internal/gmock-port.h +++ b/googlemock/include/gmock/internal/gmock-port.h @@ -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 diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index e8b51f6..5db774e 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -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 diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index 0de8481..5b9f3dd 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -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 diff --git a/googlemock/test/gmock-generated-function-mockers_test.cc b/googlemock/test/gmock-generated-function-mockers_test.cc index 02c4203..41fbd26 100644 --- a/googlemock/test/gmock-generated-function-mockers_test.cc +++ b/googlemock/test/gmock-generated-function-mockers_test.cc @@ -46,12 +46,9 @@ #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) +#if !GTEST_OS_WINDOWS || defined(_MSC_VER) # define GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS -#endif // !GTEST_OS_WINDOWS || (_MSC_VER >= 1500) +#endif // !GTEST_OS_WINDOWS || defined(_MSC_VER) namespace testing { namespace gmock_generated_function_mockers_test { diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index 9867436..9be14c9 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -68,31 +68,6 @@ 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") @@ -219,7 +194,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() diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 217ee79..d9d8533 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -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) \ diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index b618289..9989b6b 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -304,16 +304,12 @@ // 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. -# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) -# define GTEST_DISABLE_MSC_WARNINGS_POP_() #endif // Clang on Windows does not understand MSVC's pragma warning. @@ -653,12 +649,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 +663,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 +2315,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 diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 06f09c3..4345e81 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -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: |