From 4970b5813302934cfc3df8ccd0b8647a912884a1 Mon Sep 17 00:00:00 2001 From: thakis Date: Wed, 12 Nov 2014 12:53:32 -0800 Subject: [PATCH] Enable -Wunused-local-typedef BUG=321833 TBR=brettw Review URL: https://codereview.chromium.org/722513003 Cr-Commit-Position: refs/heads/master@{#303892} --- base/memory/scoped_ptr_unittest.cc | 2 ++ build/common.gypi | 3 --- build/config/compiler/BUILD.gn | 3 --- .../extensions/file_manager/event_router.cc | 2 -- chrome/browser/ui/libgtk2ui/BUILD.gn | 23 ++++++++++++++++------ chrome/browser/ui/libgtk2ui/libgtk2ui.gyp | 7 +++++-- components/pairing/fake_host_pairing_controller.cc | 2 -- sdch/BUILD.gn | 22 +++++++++++++++++---- sdch/sdch.gyp | 5 +++++ third_party/libphonenumber/BUILD.gn | 10 ++++++++++ third_party/libphonenumber/libphonenumber.gyp | 2 ++ 11 files changed, 59 insertions(+), 22 deletions(-) diff --git a/base/memory/scoped_ptr_unittest.cc b/base/memory/scoped_ptr_unittest.cc index 3f169a7fa2ae..ca7cfbf0cf02 100644 --- a/base/memory/scoped_ptr_unittest.cc +++ b/base/memory/scoped_ptr_unittest.cc @@ -669,7 +669,9 @@ TEST(ScopedPtrTest, SelfResetAbortsWithCustomDeleter) { TEST(ScopedPtrTest, SelfResetWithCustomDeleterOptOut) { // A custom deleter should be able to opt out of self-reset abort behavior. struct NoOpDeleter { +#if !defined(NDEBUG) typedef void AllowSelfReset; +#endif inline void operator()(int*) {} }; scoped_ptr owner(new int); diff --git a/build/common.gypi b/build/common.gypi index 8e2d6dec187c..2653bb804f0b 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -2516,9 +2516,6 @@ # code generated by flex (used in angle) contains that keyword. # http://crbug.com/255186 '-Wno-deprecated-register', - - # TODO(hans): Clean this up. Or disable with finer granularity. - '-Wno-unused-local-typedef', ], }, 'includes': [ 'set_clang_warning_flags.gypi', ], diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 088120dd4e24..1c51cd0e1a02 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -745,9 +745,6 @@ config("default_warnings") { # TODO(thakis): Remove, http://crbug.com/263960 "-Wno-reserved-user-defined-literal", - - # TODO(hans): Clean this up. Or disable with finer granularity. - "-Wno-unused-local-typedef", ] } if (gcc_version >= 48) { diff --git a/chrome/browser/chromeos/extensions/file_manager/event_router.cc b/chrome/browser/chromeos/extensions/file_manager/event_router.cc index 9a80d55991f3..994d2b897eb4 100644 --- a/chrome/browser/chromeos/extensions/file_manager/event_router.cc +++ b/chrome/browser/chromeos/extensions/file_manager/event_router.cc @@ -888,8 +888,6 @@ void EventRouter::DispatchDirectoryChangeEventWithEntryDefinition( const std::string* extension_id, bool watcher_error, const EntryDefinition& entry_definition) { - typedef std::map ChangeListMap; - // TODO(mtomasz): Add support for watching files in File System Provider API. if (entry_definition.error != base::File::FILE_OK || !entry_definition.is_directory) { diff --git a/chrome/browser/ui/libgtk2ui/BUILD.gn b/chrome/browser/ui/libgtk2ui/BUILD.gn index 0d34b7a1a5be..c5e1668b56b3 100644 --- a/chrome/browser/ui/libgtk2ui/BUILD.gn +++ b/chrome/browser/ui/libgtk2ui/BUILD.gn @@ -72,12 +72,6 @@ component("libgtk2ui") { "gconf_listener.h", ] } - if (is_clang) { - # G_DEFINE_TYPE automatically generates a *get_instance_private inline - # function after glib 2.37. That's unused. Prevent to complain about it. - cflags = [ "-Wno-unused-function" ] - } - defines = [ "LIBGTK2UI_IMPLEMENTATION" ] configs += [ @@ -87,6 +81,23 @@ component("libgtk2ui") { "//printing:cups", ] + # gn orders flags on a target before flags from configs. The default config + # adds -Wall, and these flags have to be after -Wall -- so they need to come + # from a config and can't be on the target directly. + config("libgtk2ui_warnings") { + if (is_clang) { + cflags = [ + # G_DEFINE_TYPE automatically generates a *get_instance_private inline + # function after glib 2.37. That's unused. Prevent to complain about it. + "-Wno-unused-function", + + # G_STATIC_ASSERT uses a typedef as a static_assert. + "-Wno-unused-local-typedef", + ] + } + } + configs += [ ":libgtk2ui_warnings", ] + deps = [ "//base", "//base:i18n", diff --git a/chrome/browser/ui/libgtk2ui/libgtk2ui.gyp b/chrome/browser/ui/libgtk2ui/libgtk2ui.gyp index ffe341e32940..d66b00c48ef1 100644 --- a/chrome/browser/ui/libgtk2ui/libgtk2ui.gyp +++ b/chrome/browser/ui/libgtk2ui/libgtk2ui.gyp @@ -96,10 +96,13 @@ ], }], [ 'clang==1', { - # G_DEFINE_TYPE automatically generates a *get_instance_private inline function after glib 2.37. - # That's unused. Prevent to complain about it. 'cflags': [ + # G_DEFINE_TYPE automatically generates a *get_instance_private inline function after glib 2.37. + # That's unused. Prevent to complain about it. '-Wno-unused-function', + + # G_STATIC_ASSERT uses a typedef as a static_assert. + '-Wno-unused-local-typedef', ], }], ], diff --git a/components/pairing/fake_host_pairing_controller.cc b/components/pairing/fake_host_pairing_controller.cc index 12798e4b8586..e6d1e7620f14 100644 --- a/components/pairing/fake_host_pairing_controller.cc +++ b/components/pairing/fake_host_pairing_controller.cc @@ -36,8 +36,6 @@ FakeHostPairingController::~FakeHostPairingController() { } void FakeHostPairingController::ApplyConfig(const std::string& config) { - typedef std::vector Tokens; - base::StringPairs kv_pairs; CHECK(base::SplitStringIntoKeyValuePairs(config, ':', ',', &kv_pairs)) << "Wrong config format."; diff --git a/sdch/BUILD.gn b/sdch/BUILD.gn index 7a95f1fa1547..727fb497712a 100644 --- a/sdch/BUILD.gn +++ b/sdch/BUILD.gn @@ -45,6 +45,24 @@ static_library("sdch") { "//third_party/zlib", ] + # gn orders flags on a target before flags from configs. The default config + # adds -Wall, and these flags have to be after -Wall -- so they need to come + # from a config and can't be on the target directly. + config("sdch_warnings") { + cflags = [] + if (is_linux) { + # TODO(mostynb): remove this if open-vcdiff is ever updated for c++11: + cflags += [ "-Wno-deprecated-declarations" ] + } + + if (is_clang) { + # sdch uses the pre-c++11 typedef-as-static_assert hack. + # https://code.google.com/p/open-vcdiff/issues/detail?id=44 + cflags += [ "-Wno-unused-local-typedef" ] + } + } + configs += [ ":sdch_warnings" ] + if (is_linux || is_android) { include_dirs = [ "linux" ] } else if (is_ios) { @@ -69,9 +87,5 @@ static_library("sdch") { } else { logging_file = rebase_path("logging_forward.h", root_build_dir) cflags = [ "-include", logging_file ] - if (is_linux) { - # TODO(mostynb): remove this if open-vcdiff is ever updated for c++11: - cflags += [ "-Wno-deprecated-declarations" ] - } } } diff --git a/sdch/sdch.gyp b/sdch/sdch.gyp index 52a92f31e2a7..e886288da501 100644 --- a/sdch/sdch.gyp +++ b/sdch/sdch.gyp @@ -71,6 +71,11 @@ # introduce static initializers, and which prevents open-vcdiff's # logging.h from being used). 'variables': { + 'clang_warning_flags': [ + # sdch uses the pre-c++11 typedef-as-static_assert hack. + # https://code.google.com/p/open-vcdiff/issues/detail?id=44 + '-Wno-unused-local-typedef', + ], 'logging_path': 'logging_forward.h', 'conditions': [ # gyp leaves unspecified what the cwd is when running the compiler, diff --git a/third_party/libphonenumber/BUILD.gn b/third_party/libphonenumber/BUILD.gn index 22d13475be5f..2f04ff53735d 100644 --- a/third_party/libphonenumber/BUILD.gn +++ b/third_party/libphonenumber/BUILD.gn @@ -92,6 +92,16 @@ test("libphonenumber_unittests") { include_dirs = [ "src/test" ] + # gn orders flags on a target before flags from configs. The default config + # adds -Wall, and these flags have to be after -Wall -- so they need to come + # from a config and can't be on the target directly. + config("libphonenumber_unittests_warnings") { + if (is_clang) { + cflags = [ "-Wno-unused-local-typedef" ] + } + } + configs += [ ":libphonenumber_unittests_warnings" ] + deps = [ ":libphonenumber_without_metadata", "//base", diff --git a/third_party/libphonenumber/libphonenumber.gyp b/third_party/libphonenumber/libphonenumber.gyp index 229440bfaa86..7d61067d8175 100644 --- a/third_party/libphonenumber/libphonenumber.gyp +++ b/third_party/libphonenumber/libphonenumber.gyp @@ -134,6 +134,8 @@ '../../testing/gtest.gyp:gtest', 'libphonenumber_without_metadata', ], + # TODO: https://code.google.com/p/libphonenumber/issues/detail?id=553 + 'variables': { 'clang_warning_flags': [ '-Wno-unused-local-typedef' ] }, 'conditions': [ ['OS=="win"', { 'action': [ -- 2.11.4.GIT