MSVC has an optional warning which flags when 32-bit pointers get cast
into a 64-bit value. This is a little overaggressive I think, but to
ease compiling in projects with aggressive warnings, fix this by just
casting to const void * directly. Modern GCCs seem to compile it just
fine.
The rest of the (covered) codebase is already integer overflow clean.
This is a cherry-pick of an internal change.
TESTED=gtest_shuffle_test goes from fail to pass with -fsanitize=integer
The documentation of former versions is available in the history (e.g.
by checking out the appropriate git tags), so there is no need to keep
them in parallel to the current documentation.
Use `EXCLUDE_FROM_ALL` in `add_subdirectory` to prevent `make install` from including lots of headers from gtest/gmock.
```
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
```
Re-use existing background color for Widows' console window.
This fixes a problem where the background color for ColoredPrintf would be BLACK even if the user's console is using a different BG color.
This merges a Google-internal change (117235625).
Original CL description:
This CL was created manually in about an hour with sed, a Python script
to find all the places unqualified 'string' was mentioned, and some help
from Emacs to add the "std::" qualifications, plus a few manual tweaks.
This upstreams a Google-internal change.
Original CL description:
The C++ standard says that function pointers are not implicitly
convertible to object pointers. Visual Studio disregards that and allows
implicit conversion between function pointers and object points, and
enough code relies on this that clang follows suit in
Microsoft-compatibility mode.
However, clang emits a -Wmicrosoft-cast warning when such a conversion
is done:
E:\b\c\b\win_clang\src\sandbox\win\src\sync_dispatcher.cc(42,7):
warning: implicit conversion between pointer-to-function and
pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]
This change fixes this warning in gtest, while hopefully not changing
any behavior. The change does two things:
1. It replaces the if in DefaultPrintTo with SFINAE
2. In C++11 mode, it uses enable_if<is_function<>> instead of
ImplicitlyConvertible<T*, const void*> to check if the
explicit cast is needed.
With this change, functions will use the branch with the reintpret_casts
with Visual Studio and clang/win, and clang no longer needs to warn
that it implicitly converts a function pointer to a void pointer.
Fixes the following errors:
hash_map(17): error C2338: <hash_map> is deprecated and will be REMOVED. Please use <unordered_map>. You can define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS to acknowledge that you have received this warning. [googlemock\gtest\gtest-printers_test.vcxproj]
hash_set(17): error C2338: <hash_set> is deprecated and will be REMOVED. Please use <unordered_set>. You can define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS to acknowledge that you have received this warning. [googlemock\gtest\gtest-printers_test.vcxproj]
googletest\test\gtest_catch_exceptions_test_.cc(152): error C2220: warning treated as error - no 'object' file generated
googletest\test\gtest_catch_exceptions_test_.cc(152): warning C4297: 'CxxExceptionInDestructorTest::~CxxExceptionInDestructorTest': function assumed not to throw an exception but does
googletest\test\gtest_catch_exceptions_test_.cc(152): note: destructor or deallocator has a (possibly implicit) non-throwing exception specification
There were already some checks for _MSC_VER in the code, so this commit
continues in that vein.
`gtest-config --version` reports wrong version.
Made against master branch but please note that this affects tag release-1.8.0 and the distribution tarballs.
If REGISTER_TYPED_TEST_CASE_P is included in a header file, but
the .cc file does not declare INSTANTIATE_TYPED_TEST_CASE_P, an
unused-variable warning may be raised by the compiler.
googletest doesn't currently build with clang's very aggressive
-Wformat-nonliteral warning. It requires that all non-literal format
strings come from the argument of a function annotated with a compatible
format attribute.
Fixing that reports that ColoredPrintf's callers weren't passing the
normal -Wformat warning. Some messages were passed directly into the
format string rather than via "%s".
Adds instructions for how to add gtest and gmock to
another CMake project directly. Downloading of the
googletest sources happens as configure time, allowing
it to be added to the main build directly via the
add_subdirectory() command. This ensures googletest is
built with the same compiler settings, etc. and will
typically result in a more robust and more convenient
build arrangement.
If $XML_OUTPUT_FILE is set, and $GTEST_OUTPUT and --gtest_output are not
specified, produce output as if GTEST_OUTPUT=xml:$XML_OUTPUT_FILE had
been set.
Put occurrences of "#include" in a code span so they are not interpreted
as headers.
Other documents were not broken because the #include was not at the
start of the line, but put them in code spans anyway just in case the
text gets refilled in the future.
This fixes these warnings:
…\gtest\googletest\test\gtest-port_test.cc(78) : error C2220: warning treated as error - no 'object' file generated
…\gtest\googletest\test\gtest-port_test.cc(78) : warning C4309: 'static_cast' : truncation of constant value
…\gtest\googletest\test\gtest-port_test.cc(79) : warning C4309: 'static_cast' : truncation of constant value
…\gtest\googlemock\test\gmock-matchers_test.cc(2712) : error C2220: warning treated as error - no 'object' file generated
…\gtest\googlemock\test\gmock-matchers_test.cc(2706) : while compiling class template member function 'testing::gmock_matchers_test::FloatingPointTest<float>::FloatingPointTest(void)'
…\gtest\googlemock\test\gmock-matchers_test.cc(2896) : see reference to function template instantiation 'testing::gmock_matchers_test::FloatingPointTest<float>::FloatingPointTest(void)' being compiled
…\gtest\googlemock\test\gmock-matchers_test.cc(2896) : see reference to class template instantiation 'testing::gmock_matchers_test::FloatingPointTest<float>' being compiled
…\gtest\googlemock\test\gmock-matchers_test.cc(2712) : warning C4267: 'argument' : conversion from 'size_t' to 'const unsigned int', possible loss of data
…\gtest\googlemock\test\gmock-matchers_test.cc(2714) : warning C4267: 'argument' : conversion from 'size_t' to 'const unsigned int', possible loss of data
…\gtest\googlemock\test\gmock-matchers_test.cc(2716) : warning C4267: 'argument' : conversion from 'size_t' to 'const unsigned int', possible loss of data
…\gtest\googlemock\test\gmock-matchers_test.cc(2717) : warning C4267: 'argument' : conversion from 'size_t' to 'const unsigned int', possible loss of data
…\gtest\googlemock\test\gmock-matchers_test.cc(2718) : warning C4267: 'argument' : conversion from 'size_t' to 'const unsigned int', possible loss of data
…\gtest\googlemock\test\gmock-matchers_test.cc(2721) : warning C4267: 'argument' : conversion from 'size_t' to 'const unsigned int', possible loss of data
…\gtest\googlemock\test\gmock-matchers_test.cc(2723) : warning C4267: 'argument' : conversion from 'size_t' to 'const unsigned int', possible loss of data
When this option is set gtest itself is built with -fvisibility=hidden
with gcc and clang. This replicates MSVC's default behaviour with gcc
and clang.
Project file contained the 'README' instead of 'README.md'
that's why the build failed with the fact that it can't
copy this file for its proper location.
Signed-off-by: Gergő Nagy <gergo@getcodie.com>