diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 22:40:46 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 22:40:46 +0000 |
commit | 690bda8807a97827d72abf6ac2b350cf44de135e (patch) | |
tree | 3f33051a5cf5f9db7047b7addc70329f8fa1b635 /base | |
parent | 388e4d376be45063c5ba65b4d089f245665b7917 (diff) | |
download | chromium_src-690bda8807a97827d72abf6ac2b350cf44de135e.zip chromium_src-690bda8807a97827d72abf6ac2b350cf44de135e.tar.gz chromium_src-690bda8807a97827d72abf6ac2b350cf44de135e.tar.bz2 |
MSVC warns when you try to use Base if T has a private destructor,
The common pattern for refcounted types. It does this even though
no attempt to instantiate Base is made. We disable the warning for
this portion of code.
BUG=none
TEST=try bots.
Review URL: http://codereview.chromium.org/6833006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81499 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/bind_helpers.h | 9 | ||||
-rw-r--r-- | base/bind_unittest.cc | 14 |
2 files changed, 23 insertions, 0 deletions
diff --git a/base/bind_helpers.h b/base/bind_helpers.h index 92194e7..3293dbb 100644 --- a/base/bind_helpers.h +++ b/base/bind_helpers.h @@ -133,8 +133,17 @@ class SupportsAddRefAndRelease { void Release(); }; +// MSVC warns when you try to use Base if T has a private destructor, the +// common pattern for refcounted types. It does this even though no attempt to +// instantiate Base is made. We disable the warning for this definition. +#if defined(OS_WIN) +#pragma warning(disable:4624) +#endif struct Base : public T, public BaseMixin { }; +#if defined(OS_WIN) +#pragma warning(default:4624) +#endif template <void(BaseMixin::*)(void)> struct Helper {}; diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc index b3e0160..c131a86 100644 --- a/base/bind_unittest.cc +++ b/base/bind_unittest.cc @@ -48,6 +48,11 @@ class HasRef : public NoRef { DISALLOW_COPY_AND_ASSIGN(HasRef); }; +class HasRefPrivateDtor : public HasRef { + private: + ~HasRefPrivateDtor() {} +}; + static const int kParentValue = 1; static const int kChildValue = 2; @@ -425,6 +430,11 @@ TEST_F(BindTest, ArrayArgumentBinding) { // Verify SupportsAddRefAndRelease correctly introspects the class type for // AddRef() and Release(). +// - Class with AddRef() and Release() +// - Class without AddRef() and Release() +// - Derived Class with AddRef() and Release() +// - Derived Class without AddRef() and Release() +// - Derived Class with AddRef() and Release() and a private destructor. TEST_F(BindTest, SupportsAddRefAndRelease) { EXPECT_TRUE(internal::SupportsAddRefAndRelease<HasRef>::value); EXPECT_FALSE(internal::SupportsAddRefAndRelease<NoRef>::value); @@ -434,6 +444,10 @@ TEST_F(BindTest, SupportsAddRefAndRelease) { // inheritance. EXPECT_TRUE(internal::SupportsAddRefAndRelease<StrictMock<HasRef> >::value); EXPECT_FALSE(internal::SupportsAddRefAndRelease<StrictMock<NoRef> >::value); + + // This matters because the implementation creates a dummy class that + // inherits from the template type. + EXPECT_TRUE(internal::SupportsAddRefAndRelease<HasRefPrivateDtor>::value); } // Unretained() wrapper support. |