From b51adda8d29c82253e104fc9588fe38a4ed45f94 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Mon, 18 Dec 2017 15:26:15 -0500 Subject: [PATCH] Build certain gtest/gmock tests with -Wno-unused-private-field Fuchsia is using a newer Clang than I was using on macOS when I wrote these GN targets, and -Wunused-private-field can now detect these violations. Change-Id: If71eb74f6453957aa92852cbe53356e325c7b635 Reviewed-on: https://chromium-review.googlesource.com/833195 Reviewed-by: Scott Graham Commit-Queue: Mark Mentovai --- third_party/gtest/BUILD.gn | 24 ++++++++++++++++++++---- third_party/gtest/gmock.gyp | 20 ++++++++++++++++++++ third_party/gtest/gtest.gyp | 20 ++++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/third_party/gtest/BUILD.gn b/third_party/gtest/BUILD.gn index 80a65e4d..86b0d0fb 100644 --- a/third_party/gtest/BUILD.gn +++ b/third_party/gtest/BUILD.gn @@ -147,6 +147,13 @@ test("gtest_param_test") { deps = [ ":gtest", ] + + if (is_clang) { + cflags_cc = [ + # For gtest/googlemock/test/gmock-matchers_test.cc’s Unstreamable::value_. + "-Wno-unused-private-field", + ] + } } test("gtest_premature_exit_test") { @@ -221,12 +228,13 @@ config("gmock_private_config") { config("gmock_public_config") { include_dirs = [ "gtest/googlemock/include" ] - # The MOCK_METHODn() macros do not specify “override”, which triggers this - # warning in users: “error: 'Method' overrides a member function but is not - # marked 'override' [-Werror,-Winconsistent-missing-override]”. Suppress these - # warnings until https://github.com/google/googletest/issues/533 is fixed. if (is_clang) { cflags_cc = [ + # The MOCK_METHODn() macros do not specify “override”, which triggers this + # warning in users: “error: 'Method' overrides a member function but is + # not marked 'override' [-Werror,-Winconsistent-missing-override]”. + # Suppress these warnings until + # https://github.com/google/googletest/issues/533 is fixed. "-Wno-inconsistent-missing-override", ] } @@ -306,6 +314,14 @@ test("gmock_all_test") { ":gmock_main", ":gtest", ] + + if (is_clang) { + cflags_cc = [ + # For gtest/googlemock/test/gmock-matchers_test.cc’s + # testing::gmock_matchers_test::Unprintable::c_. + "-Wno-unused-private-field", + ] + } } test("gmock_link_test") { diff --git a/third_party/gtest/gmock.gyp b/third_party/gtest/gmock.gyp index db8e8b87..d53c925f 100644 --- a/third_party/gtest/gmock.gyp +++ b/third_party/gtest/gmock.gyp @@ -168,6 +168,26 @@ '<(gmock_dir)/test/gmock-spec-builders_test.cc', '<(gmock_dir)/test/gmock_test.cc', ], + 'conditions': [ + ['clang!=0', { + # For gtest/googlemock/test/gmock-matchers_test.cc’s + # Unstreamable::value_. + 'conditions': [ + ['OS=="mac"', { + 'xcode_settings': { + 'WARNING_CFLAGS': [ + '-Wno-unused-private-field', + ], + }, + }], + ['OS=="linux" or OS=="android"', { + 'cflags': [ + '-Wno-unused-private-field', + ], + }], + ], + }], + ], }, { 'target_name': 'gmock_link_test', diff --git a/third_party/gtest/gtest.gyp b/third_party/gtest/gtest.gyp index 5079e269..5d93feb5 100644 --- a/third_party/gtest/gtest.gyp +++ b/third_party/gtest/gtest.gyp @@ -216,6 +216,26 @@ '<(gtest_dir)/test/gtest-param-test_test.cc', '<(gtest_dir)/test/gtest-param-test_test.h', ], + 'conditions': [ + ['clang!=0', { + # For gtest/googlemock/test/gmock-matchers_test.cc’s + # Unstreamable::value_. + 'conditions': [ + ['OS=="mac"', { + 'xcode_settings': { + 'WARNING_CFLAGS': [ + '-Wno-unused-private-field', + ], + }, + }], + ['OS=="linux" or OS=="android"', { + 'cflags': [ + '-Wno-unused-private-field', + ], + }], + ], + }], + ], }, { 'target_name': 'gtest_premature_exit_test',