Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
826656b2
Unverified
Commit
826656b2
authored
Nov 10, 2018
by
Robin Lindén
Browse files
Remove workarounds for unsupported MSVC versions
parent
de5be0eb
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
19 additions
and
84 deletions
+19
-84
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+0
-7
googlemock/include/gmock/internal/gmock-port.h
googlemock/include/gmock/internal/gmock-port.h
+3
-3
googlemock/src/gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+3
-3
googlemock/test/gmock-actions_test.cc
googlemock/test/gmock-actions_test.cc
+2
-2
googlemock/test/gmock-generated-function-mockers_test.cc
googlemock/test/gmock-generated-function-mockers_test.cc
+2
-5
googletest/cmake/internal_utils.cmake
googletest/cmake/internal_utils.cmake
+1
-26
googletest/include/gtest/internal/gtest-internal.h
googletest/include/gtest/internal/gtest-internal.h
+0
-10
googletest/include/gtest/internal/gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+5
-12
googletest/src/gtest.cc
googletest/src/gtest.cc
+3
-16
No files found.
googlemock/include/gmock/gmock-matchers.h
View file @
826656b2
...
@@ -2484,15 +2484,8 @@ class PropertyMatcher {
...
@@ -2484,15 +2484,8 @@ class PropertyMatcher {
*
listener
<<
whose_property_
<<
"is "
;
*
listener
<<
whose_property_
<<
"is "
;
// Cannot pass the return value (for example, int) to MatchPrintAndExplain,
// Cannot pass the return value (for example, int) to MatchPrintAndExplain,
// which takes a non-const reference as argument.
// 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_
)();
RefToConstProperty
result
=
(
obj
.
*
property_
)();
return
MatchPrintAndExplain
(
result
,
matcher_
,
listener
);
return
MatchPrintAndExplain
(
result
,
matcher_
,
listener
);
#endif
}
}
bool
MatchAndExplainImpl
(
true_type
/* is_pointer */
,
const
Class
*
p
,
bool
MatchAndExplainImpl
(
true_type
/* is_pointer */
,
const
Class
*
p
,
...
...
googlemock/include/gmock/internal/gmock-port.h
View file @
826656b2
...
@@ -55,10 +55,10 @@
...
@@ -55,10 +55,10 @@
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-port.h"
#include "gmock/internal/custom/gmock-port.h"
#include "gmock/internal/custom/gmock-port.h"
// For MS Visual C++, check the compiler version. At least VS 20
03
is
// For MS Visual C++, check the compiler version. At least VS 20
15
is
// required to compile Google Mock.
// required to compile Google Mock.
#if defined(_MSC_VER) && _MSC_VER < 1
31
0
#if defined(_MSC_VER) && _MSC_VER < 1
90
0
# error "At least Visual C++ 20
03 (7.1
) is required to compile Google Mock."
# error "At least Visual C++ 20
15 (14.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
...
...
googlemock/src/gmock-spec-builders.cc
View file @
826656b2
...
@@ -50,9 +50,9 @@
...
@@ -50,9 +50,9 @@
#endif
#endif
// Silence C4800 (C4800: 'int *const ': forcing value
// 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
#ifdef _MSC_VER
#if _MSC_VER
<
= 1900
#if _MSC_VER
=
= 1900
# pragma warning(push)
# pragma warning(push)
# pragma warning(disable:4800)
# pragma warning(disable:4800)
#endif
#endif
...
@@ -887,7 +887,7 @@ InSequence::~InSequence() {
...
@@ -887,7 +887,7 @@ InSequence::~InSequence() {
}
// namespace testing
}
// namespace testing
#ifdef _MSC_VER
#ifdef _MSC_VER
#if _MSC_VER
<
= 1900
#if _MSC_VER
=
= 1900
# pragma warning(pop)
# pragma warning(pop)
#endif
#endif
#endif
#endif
googlemock/test/gmock-actions_test.cc
View file @
826656b2
...
@@ -33,9 +33,9 @@
...
@@ -33,9 +33,9 @@
// This file tests the built-in actions.
// This file tests the built-in actions.
// Silence C4800 (C4800: 'int *const ': forcing value
// 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
#ifdef _MSC_VER
#if _MSC_VER
<
= 1900
#if _MSC_VER
=
= 1900
# pragma warning(push)
# pragma warning(push)
# pragma warning(disable:4800)
# pragma warning(disable:4800)
#endif
#endif
...
...
googlemock/test/gmock-generated-function-mockers_test.cc
View file @
826656b2
...
@@ -46,12 +46,9 @@
...
@@ -46,12 +46,9 @@
#include "gmock/gmock.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
// There is a bug in MSVC (fixed in VS 2008) that prevents creating a
#if !GTEST_OS_WINDOWS || defined(_MSC_VER)
// 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
# define GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
#endif // !GTEST_OS_WINDOWS || (_MSC_VER
>= 1500
)
#endif // !GTEST_OS_WINDOWS ||
defined
(_MSC_VER)
namespace
testing
{
namespace
testing
{
namespace
gmock_generated_function_mockers_test
{
namespace
gmock_generated_function_mockers_test
{
...
...
googletest/cmake/internal_utils.cmake
View file @
826656b2
...
@@ -68,31 +68,6 @@ macro(config_compiler_and_linker)
...
@@ -68,31 +68,6 @@ macro(config_compiler_and_linker)
# Newlines inside flags variables break CMake's NMake generator.
# Newlines inside flags variables break CMake's NMake generator.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
set
(
cxx_base_flags
"-GS -W4 -WX -wd4251 -wd4275 -nologo -J -Zi"
)
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
}
-D_UNICODE -DUNICODE -DWIN32 -D_WIN32"
)
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-DSTRICT -DWIN32_LEAN_AND_MEAN"
)
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-DSTRICT -DWIN32_LEAN_AND_MEAN"
)
set
(
cxx_exception_flags
"-EHsc -D_HAS_EXCEPTIONS=1"
)
set
(
cxx_exception_flags
"-EHsc -D_HAS_EXCEPTIONS=1"
)
...
@@ -219,7 +194,7 @@ endfunction()
...
@@ -219,7 +194,7 @@ endfunction()
# is built from the given source files with the given compiler flags.
# is built from the given source files with the given compiler flags.
function
(
cxx_executable_with_flags name cxx_flags libs
)
function
(
cxx_executable_with_flags name cxx_flags libs
)
add_executable
(
${
name
}
${
ARGN
}
)
add_executable
(
${
name
}
${
ARGN
}
)
if
(
MSVC
AND
(
NOT
(
MSVC_VERSION LESS 1700
)))
# 1700 is Visual Studio 2012.
if
(
MSVC
)
# BigObj required for tests.
# BigObj required for tests.
set
(
cxx_flags
"
${
cxx_flags
}
-bigobj"
)
set
(
cxx_flags
"
${
cxx_flags
}
-bigobj"
)
endif
()
endif
()
...
...
googletest/include/gtest/internal/gtest-internal.h
View file @
826656b2
...
@@ -840,16 +840,6 @@ struct RemoveConst<const T[N]> {
...
@@ -840,16 +840,6 @@ struct RemoveConst<const T[N]> {
typedef
typename
RemoveConst
<
T
>::
type
type
[
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
// A handy wrapper around RemoveConst that works when the argument
// T depends on template parameters.
// T depends on template parameters.
#define GTEST_REMOVE_CONST_(T) \
#define GTEST_REMOVE_CONST_(T) \
...
...
googletest/include/gtest/internal/gtest-port.h
View file @
826656b2
...
@@ -304,16 +304,12 @@
...
@@ -304,16 +304,12 @@
// GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
// GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
// /* code that triggers warnings C4800 and C4385 */
// /* code that triggers warnings C4800 and C4385 */
// GTEST_DISABLE_MSC_WARNINGS_POP_()
// GTEST_DISABLE_MSC_WARNINGS_POP_()
#if
_MSC_VER >= 1400
#if
defined(_MSC_VER)
# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
__pragma(warning(push)) \
__pragma(warning(push)) \
__pragma(warning(disable: warnings))
__pragma(warning(disable: warnings))
# define GTEST_DISABLE_MSC_WARNINGS_POP_() \
# define GTEST_DISABLE_MSC_WARNINGS_POP_() \
__pragma(warning(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
#endif
// Clang on Windows does not understand MSVC's pragma warning.
// Clang on Windows does not understand MSVC's pragma warning.
...
@@ -653,12 +649,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
...
@@ -653,12 +649,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif // GTEST_HAS_STREAM_REDIRECTION
#endif // GTEST_HAS_STREAM_REDIRECTION
// Determines whether to support death tests.
// 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.
// pops up a dialog window that cannot be suppressed programmatically.
#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
(GTEST_OS_MAC && !GTEST_OS_IOS) || \
(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_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || \
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || \
GTEST_OS_NETBSD || GTEST_OS_FUCHSIA)
GTEST_OS_NETBSD || GTEST_OS_FUCHSIA)
...
@@ -669,7 +663,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
...
@@ -669,7 +663,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
// Sun Pro CC, IBM Visual Age, and HP aCC support.
// 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)
defined(__IBMCPP__) || defined(__HP_aCC)
# define GTEST_HAS_TYPED_TEST 1
# define GTEST_HAS_TYPED_TEST 1
# define GTEST_HAS_TYPED_TEST_P 1
# define GTEST_HAS_TYPED_TEST_P 1
...
@@ -2321,13 +2315,12 @@ GTEST_DISABLE_MSC_DEPRECATED_POP_()
...
@@ -2321,13 +2315,12 @@ GTEST_DISABLE_MSC_DEPRECATED_POP_()
// MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate
// MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate
// function in order to achieve that. We use macro definition here because
// function in order to achieve that. We use macro definition here because
// snprintf is a variadic function.
// 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.
// MSVC 2005 and above support variadic macros.
# define GTEST_SNPRINTF_(buffer, size, format, ...) \
# define GTEST_SNPRINTF_(buffer, size, format, ...) \
_snprintf_s(buffer, size, size, format, __VA_ARGS__)
_snprintf_s(buffer, size, size, format, __VA_ARGS__)
#elif defined(_MSC_VER)
#elif defined(_MSC_VER)
// Windows CE does not define _snprintf_s and MSVC prior to 2005 doesn't
// Windows CE does not define _snprintf_s
// complain about _snprintf.
# define GTEST_SNPRINTF_ _snprintf
# define GTEST_SNPRINTF_ _snprintf
#else
#else
# define GTEST_SNPRINTF_ snprintf
# define GTEST_SNPRINTF_ snprintf
...
...
googletest/src/gtest.cc
View file @
826656b2
...
@@ -4537,24 +4537,17 @@ void TestEventListeners::SuppressEventForwarding() {
...
@@ -4537,24 +4537,17 @@ void TestEventListeners::SuppressEventForwarding() {
// call this before main() starts, from which point on the return
// call this before main() starts, from which point on the return
// value will never change.
// value will never change.
UnitTest
*
UnitTest
::
GetInstance
()
{
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
// CodeGear C++Builder insists on a public destructor for the
// default implementation. Use this implementation to keep good OO
// default implementation. Use this implementation to keep good OO
// design with private destructor.
// design with private destructor.
#if
(_MSC_VER == 1310 && !defined(_DEBUG)) ||
defined(__BORLANDC__)
#if defined(__BORLANDC__)
static
UnitTest
*
const
instance
=
new
UnitTest
;
static
UnitTest
*
const
instance
=
new
UnitTest
;
return
instance
;
return
instance
;
#else
#else
static
UnitTest
instance
;
static
UnitTest
instance
;
return
&
instance
;
return
&
instance
;
#endif //
(_MSC_VER == 1310 && !defined(_DEBUG)) ||
defined(__BORLANDC__)
#endif // defined(__BORLANDC__)
}
}
// Gets the number of successful test cases.
// Gets the number of successful test cases.
...
@@ -4812,18 +4805,12 @@ int UnitTest::Run() {
...
@@ -4812,18 +4805,12 @@ int UnitTest::Run() {
_set_error_mode
(
_OUT_TO_STDERR
);
_set_error_mode
(
_OUT_TO_STDERR
);
# endif
# 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
// In the debug version, Visual Studio pops up a separate dialog
// offering a choice to debug the aborted program. We need to suppress
// 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
// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
// executed. Google Test will notify the user of any unexpected
// executed. Google Test will notify the user of any unexpected
// failure via stderr.
// 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
))
if
(
!
GTEST_FLAG
(
break_on_failure
))
_set_abort_behavior
(
_set_abort_behavior
(
0x0
,
// Clear the following flags:
0x0
,
// Clear the following flags:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment