From d15b8b4524063e065263316e67e74a47f7dc4af2 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 21:25:34 +0200 Subject: [PATCH 1/5] switch one build to Release mode This turns on optimization which allows the compiler to discover more problems and omit some more warnings. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 417d2c51..81692dd9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ script: ./travis.sh env: matrix: - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Debug VERBOSE=1 - - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS=-std=c++11 + - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 notifications: email: false sudo: false From 520ad96b78179fde7110ea29f7c22a6a9b32ed09 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 21:42:33 +0200 Subject: [PATCH 2/5] treat all warnings as errors for GCC (-Werror) --- googletest/cmake/internal_utils.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index ec5d08c0..0b41e3ab 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -94,7 +94,7 @@ macro(config_compiler_and_linker) set(cxx_no_exception_flags "-D_HAS_EXCEPTIONS=0") set(cxx_no_rtti_flags "-GR-") elseif (CMAKE_COMPILER_IS_GNUCXX) - set(cxx_base_flags "-Wall -Wshadow") + set(cxx_base_flags "-Wall -Wshadow -Werror") set(cxx_exception_flags "-fexceptions") set(cxx_no_exception_flags "-fno-exceptions") # Until version 4.3.2, GCC doesn't define a macro to indicate From 8abacca52eeb9e9502b5cc2c3b4733d8adf3c42b Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Mon, 4 Sep 2017 13:23:08 +0200 Subject: [PATCH 3/5] avoid -Wshadow warning on GCC When using INSTANTIATE_TEST_CASE_P with a lambda function which uses 'info' as parameter name, GCC complains that this would shadow parameter 'info' used in the macro's VA_ARGS call. --- googletest/test/gtest-param-test_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 857f6c5e..d1b0644f 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -857,8 +857,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {} INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest, Values(std::string("LambdaName")), - [](const ::testing::TestParamInfo& info) { - return info.param; + [](const ::testing::TestParamInfo& tpinfo) { + return tpinfo.param; }); #endif // GTEST_LANG_CXX11 From 55fd999adf5a8ecfcd502f07b0ea4b691ca7215f Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 21:43:37 +0200 Subject: [PATCH 4/5] avoid warning about unused variable --- googletest/test/gtest_unittest.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index f84def90..78f3ee2b 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -2096,7 +2096,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment { }; // This will test property recording outside of any test or test case. -static Environment* record_property_env = +Environment* record_property_env = AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment); // This group of tests is for predicate assertions (ASSERT_PRED*, etc) @@ -4188,6 +4188,12 @@ TEST(AssertionSyntaxTest, WorksWithConst) { } // namespace +// we don't use the variable further, just avoid compiler warning +// by defining a function which uses it +void dummy_use_of_record_property_env() { + (void) record_property_env; +} + namespace testing { // Tests that Google Test tracks SUCCEED*. From 6c0146fd0075aae0beb394c19285a8869745cc2c Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Thu, 7 Sep 2017 17:33:19 +0200 Subject: [PATCH 5/5] use GTEST_ATTRIBUTE_UNUSED_ instead of dummy function --- googletest/test/gtest_unittest.cc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 78f3ee2b..745c9506 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -2096,7 +2096,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment { }; // This will test property recording outside of any test or test case. -Environment* record_property_env = +Environment* record_property_env GTEST_ATTRIBUTE_UNUSED_ = AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment); // This group of tests is for predicate assertions (ASSERT_PRED*, etc) @@ -4188,12 +4188,6 @@ TEST(AssertionSyntaxTest, WorksWithConst) { } // namespace -// we don't use the variable further, just avoid compiler warning -// by defining a function which uses it -void dummy_use_of_record_property_env() { - (void) record_property_env; -} - namespace testing { // Tests that Google Test tracks SUCCEED*.