From b50b2f775ed0268af9c83a96b285e296778d0743 Mon Sep 17 00:00:00 2001 From: medithe <40990424+medithe@users.noreply.github.com> Date: Mon, 9 Jul 2018 13:36:46 +0200 Subject: [PATCH 1/4] Cast the tr1::tuple_element template parameter to int MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because in `std::tr1::tuple_element` the first template parameter should be of type int (https://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.4/a00547.html), but the code inserts a size_t, the first template parameter should be casted to int before, to get rid of the following errors: googletest-src/googletest/include/gtest/gtest-printers.h:957:60: error: conversion from ‘long unsigned int’ to ‘int’ may change value [-Werror=conversion] struct tuple_element : ::std::tr1::tuple_element {}; and googletest-src/googletest/include/gtest/gtest-printers.h:961:56: error: conversion from ‘long unsigned int’ to ‘int’ may change value [-Werror=conversion] const typename ::std::tr1::tuple_element::type>::type get( --- googletest/include/gtest/gtest-printers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 373946b9..fa465c38 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -954,11 +954,11 @@ struct TuplePolicy { static const size_t tuple_size = ::std::tr1::tuple_size::value; template - struct tuple_element : ::std::tr1::tuple_element {}; + struct tuple_element : ::std::tr1::tuple_element(I), Tuple> {}; template static typename AddReference< - const typename ::std::tr1::tuple_element::type>::type get( + const typename ::std::tr1::tuple_element(I), Tuple>::type>::type get( const Tuple& tuple) { return ::std::tr1::get(tuple); } From 421e7b4f29fc761c66d2773a1fc318a738a6d3da Mon Sep 17 00:00:00 2001 From: Wojciech Kaluza Date: Sat, 26 May 2018 01:40:06 +0100 Subject: [PATCH 2/4] Remove default /EHsc compiler flag This prevents warning D9025 (one command-line option overrides another) on MSVC builds: some test targets are built with the /EHs-c- which conflicts with /EHsc. --- googletest/cmake/internal_utils.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index 6448918f..3a9b5bc4 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -38,6 +38,11 @@ macro(fix_default_compiler_settings_) # We prefer more strict warning checking for building Google Test. # Replaces /W3 with /W4 in defaults. string(REPLACE "/W3" "/W4" ${flag_var} "${${flag_var}}") + + # Prevent D9025 warning for targets that have exception handling + # turned off (/EHs-c- flag). Where required, exceptions are explicitly + # re-enabled using the cxx_exception_flags variable. + string(REPLACE "/EHsc" "" ${flag_var} "${${flag_var}}") endforeach() endif() endmacro() From cda442da0b6027bdaf3b37e4df1b1b280e5732ab Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 17 Aug 2018 13:44:48 -0400 Subject: [PATCH 3/4] Formatting --- googletest/include/gtest/gtest-printers.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 491bcc9c..51865f84 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -978,12 +978,13 @@ struct TuplePolicy { static const size_t tuple_size = ::std::tr1::tuple_size::value; template - struct tuple_element : ::std::tr1::tuple_element(I), Tuple> {}; + struct tuple_element : ::std::tr1::tuple_element(I), Tuple> { + }; template - static typename AddReference< - const typename ::std::tr1::tuple_element(I), Tuple>::type>::type get( - const Tuple& tuple) { + static typename AddReference(I), Tuple>::type>::type + get(const Tuple& tuple) { return ::std::tr1::get(tuple); } }; From 079641531492b0f5b87e08278aa229d047bea1e5 Mon Sep 17 00:00:00 2001 From: Vadim Berezniker Date: Fri, 17 Aug 2018 10:49:10 -0700 Subject: [PATCH 4/4] std references shouldn't be fully qualified --- googletest/docs/advanced.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/googletest/docs/advanced.md b/googletest/docs/advanced.md index 0a92e524..3a097f1b 100644 --- a/googletest/docs/advanced.md +++ b/googletest/docs/advanced.md @@ -572,7 +572,7 @@ namespace foo { class Bar { // We want googletest to be able to print instances of this. ... // Create a free inline friend function. - friend ::std::ostream& operator<<(::std::ostream& os, const Bar& bar) { + friend std::ostream& operator<<(std::ostream& os, const Bar& bar) { return os << bar.DebugString(); // whatever needed to print bar to os } }; @@ -580,7 +580,7 @@ class Bar { // We want googletest to be able to print instances of this. // If you can't declare the function in the class it's important that the // << operator is defined in the SAME namespace that defines Bar. C++'s look-up // rules rely on that. -::std::ostream& operator<<(::std::ostream& os, const Bar& bar) { +std::ostream& operator<<(std::ostream& os, const Bar& bar) { return os << bar.DebugString(); // whatever needed to print bar to os } @@ -601,7 +601,7 @@ namespace foo { class Bar { ... - friend void PrintTo(const Bar& bar, ::std::ostream* os) { + friend void PrintTo(const Bar& bar, std::ostream* os) { *os << bar.DebugString(); // whatever needed to print bar to os } }; @@ -609,7 +609,7 @@ class Bar { // If you can't declare the function in the class it's important that PrintTo() // is defined in the SAME namespace that defines Bar. C++'s look-up rules rely // on that. -void PrintTo(const Bar& bar, ::std::ostream* os) { +void PrintTo(const Bar& bar, std::ostream* os) { *os << bar.DebugString(); // whatever needed to print bar to os }