summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authormmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 22:26:06 +0000
committermmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 22:26:06 +0000
commitf1ea2fa47af56a08b964a5ad0512156bfcbfda11 (patch)
tree1626a8a9dfb5de1b6ec86cb2552096d2ee2f1b75 /base
parenta2221350d2f9240099d88930d24c19b7745d3154 (diff)
downloadchromium_src-f1ea2fa47af56a08b964a5ad0512156bfcbfda11.zip
chromium_src-f1ea2fa47af56a08b964a5ad0512156bfcbfda11.tar.gz
chromium_src-f1ea2fa47af56a08b964a5ad0512156bfcbfda11.tar.bz2
Fix the final gcc warnings in base and net. Provide some macros to selectively disable MSVC warnings.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1194 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/base.xcodeproj/project.pbxproj14
-rw-r--r--base/build/base.vcproj14
-rw-r--r--base/compiler_specific.h80
-rw-r--r--base/message_loop.cc3
4 files changed, 98 insertions, 13 deletions
diff --git a/base/base.xcodeproj/project.pbxproj b/base/base.xcodeproj/project.pbxproj
index d635f7c..684fb14 100644
--- a/base/base.xcodeproj/project.pbxproj
+++ b/base/base.xcodeproj/project.pbxproj
@@ -327,7 +327,6 @@
7B8505A40E5B3FBE00730B43 /* size.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = size.cc; sourceTree = "<group>"; };
7B8505A50E5B3FBE00730B43 /* skia_utils.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = skia_utils.cc; sourceTree = "<group>"; };
7B8505A60E5B3FBE00730B43 /* skia_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = skia_utils.h; sourceTree = "<group>"; };
- 7B8505A70E5B3FBE00730B43 /* uniscribe_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = uniscribe_unittest.cc; sourceTree = "<group>"; };
7B8505A80E5B3FBE00730B43 /* vector_canvas_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = vector_canvas_unittest.cc; sourceTree = "<group>"; };
7BAF4F0A0E50A2FD00CA8A07 /* notimplemented.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = notimplemented.h; sourceTree = "<group>"; };
7BAF4F7B0E50A3BD00CA8A07 /* logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = logging.h; sourceTree = "<group>"; };
@@ -336,6 +335,7 @@
7BAF50750E50B8F100CA8A07 /* file_version_info_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_version_info_unittest.cc; sourceTree = "<group>"; };
7BAF50A90E50BACB00CA8A07 /* string_util_posix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string_util_posix.h; sourceTree = "<group>"; };
7BAF50B10E50BAE700CA8A07 /* string_util_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string_util_unittest.cc; sourceTree = "<group>"; };
+ 7BAFFC8A0E5E0CC000797CC4 /* compiler_specific.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = compiler_specific.h; sourceTree = "<group>"; };
7BD9E84E0DA447F800FC7A01 /* singleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = singleton.h; sourceTree = "<group>"; };
7BEB81100D9AD288009BA8DD /* prcpucfg_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = prcpucfg_mac.h; path = third_party/nspr/prcpucfg_mac.h; sourceTree = "<group>"; };
7BEB81490D9B0F33009BA8DD /* time_posix.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = time_posix.cc; sourceTree = "<group>"; };
@@ -696,6 +696,7 @@
E4A133490E37A41D00110AA2 /* command_line.cc */,
E4A1334A0E37A41D00110AA2 /* command_line.h */,
E45A2B5A0E479A1900DB1196 /* command_line_unittest.cc */,
+ 7BAFFC8A0E5E0CC000797CC4 /* compiler_specific.h */,
825402EB0D92D1940006B936 /* condition_variable.h */,
824653670DC12CEC007C2BAA /* condition_variable_posix.cc */,
825402F40D92D1AC0006B936 /* debug_on_start.cc */,
@@ -906,7 +907,6 @@
825403D70D92D31D0006B936 /* size.h */,
7B8505A50E5B3FBE00730B43 /* skia_utils.cc */,
7B8505A60E5B3FBE00730B43 /* skia_utils.h */,
- 7B8505A70E5B3FBE00730B43 /* uniscribe_unittest.cc */,
825403DC0D92D31D0006B936 /* vector_canvas.cc */,
825403DD0D92D31D0006B936 /* vector_canvas.h */,
7B8505A80E5B3FBE00730B43 /* vector_canvas_unittest.cc */,
@@ -1168,6 +1168,7 @@
829E36460DC0F6AC00819EBF /* string_util.cc in Sources */,
820EB4FA0E3A6178009668FC /* string_util_icu.cc in Sources */,
7B4C5F4A0E4B6BF900679E8F /* sys_string_conversions_mac.cc in Sources */,
+ 93E703240E5D64F00046259B /* thread.cc in Sources */,
829E36730DC0FBAD00819EBF /* thread_local_storage_posix.cc in Sources */,
824654910DC25A8C007C2BAA /* time.cc in Sources */,
82D094550E5B892600FEC05C /* time_format.cc in Sources */,
@@ -1178,7 +1179,6 @@
ABF4B9C30DC2BD6C00A6E319 /* values.cc in Sources */,
9301C03B0E54C839001EF103 /* waitable_event_generic.cc in Sources */,
824655DD0DC659B8007C2BAA /* word_iterator.cc in Sources */,
- 93E703240E5D64F00046259B /* thread.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1405,12 +1405,12 @@
);
HEADER_SEARCH_PATHS = (
..,
+ ../skia/include,
+ ../skia/include/corecg,
../testing/gtest/include,
../testing/gtest/include/gtest,
../third_party/icu38/public/common,
../third_party/icu38/public/i18n,
- ../skia/include,
- ../skia/include/corecg,
);
PRODUCT_NAME = base_unittests;
};
@@ -1426,12 +1426,12 @@
);
HEADER_SEARCH_PATHS = (
..,
+ ../skia/include,
+ ../skia/include/corecg,
../testing/gtest/include,
../testing/gtest/include/gtest,
../third_party/icu38/public/common,
../third_party/icu38/public/i18n,
- ../skia/include,
- ../skia/include/corecg,
);
PRODUCT_NAME = base_unittests;
};
diff --git a/base/build/base.vcproj b/base/build/base.vcproj
index b78f41c..7864bd0 100644
--- a/base/build/base.vcproj
+++ b/base/build/base.vcproj
@@ -234,6 +234,10 @@
>
</File>
<File
+ RelativePath="..\compiler_specific.h"
+ >
+ </File>
+ <File
RelativePath="..\condition_variable.h"
>
</File>
@@ -482,11 +486,11 @@
>
</File>
<File
- RelativePath="..\platform_thread_win.cc"
+ RelativePath="..\platform_thread.h"
>
</File>
<File
- RelativePath="..\platform_thread.h"
+ RelativePath="..\platform_thread_win.cc"
>
</File>
<File
@@ -710,15 +714,15 @@
>
</File>
<File
- RelativePath="..\time_win.cc"
+ RelativePath="..\time_format.cc"
>
</File>
<File
- RelativePath="..\time_format.cc"
+ RelativePath="..\time_format.h"
>
</File>
<File
- RelativePath="..\time_format.h"
+ RelativePath="..\time_win.cc"
>
</File>
<File
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
new file mode 100644
index 0000000..af00654
--- /dev/null
+++ b/base/compiler_specific.h
@@ -0,0 +1,80 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef BASE_COMPILER_SPECIFIC_H_
+#define BASE_COMPILER_SPECIFIC_H_
+
+#include "build/build_config.h"
+
+#if defined(COMPILER_MSVC)
+
+// Macros for suppressing and disabling warnings on MSVC.
+//
+// Warning numbers are enumerated at:
+// http://msdn.microsoft.com/en-us/library/8x5x43k7(VS.80).aspx
+//
+// The warning pragma:
+// http://msdn.microsoft.com/en-us/library/2c8f766e(VS.80).aspx
+//
+// Using __pragma instead of #pragma inside macros:
+// http://msdn.microsoft.com/en-us/library/d9x1s805.aspx
+
+// MSVC_SUPPRESS_WARNING disables warning |n| for the remainder of the line and
+// for the next line of the source file.
+#define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress:n))
+
+// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled.
+// The warning remains disabled until popped by MSVC_POP_WARNING.
+#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
+ __pragma(warning(disable:n))
+#define MSVC_POP_WARNING() __pragma(warning(pop))
+
+// Allows |this| to be passed as an argument in constructor initializer lists.
+// This uses push/pop instead of the seemingly simpler suppress feature to avoid
+// having the warning be disabled for more than just |code|.
+//
+// Example usage:
+// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {}
+//
+// Compiler warning C4355: 'this': used in base member initializer list:
+// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx
+#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \
+ code \
+ MSVC_POP_WARNING()
+
+#else // COMPILER_MSVC
+
+#define MSVC_SUPPRESS_WARNING(n)
+#define MSVC_PUSH_DISABLE_WARNING(n)
+#define MSVC_POP_WARNING()
+#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code
+
+#endif // COMPILER_MSVC
+
+#endif // BASE_COMPILER_SPECIFIC_H_
diff --git a/base/message_loop.cc b/base/message_loop.cc
index bdf99f0..2b7d274 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -31,6 +31,7 @@
#include <algorithm>
+#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/message_pump_default.h"
#include "base/string_util.h"
@@ -80,7 +81,7 @@ static LPTOP_LEVEL_EXCEPTION_FILTER GetTopSEHFilter() {
//------------------------------------------------------------------------------
MessageLoop::MessageLoop()
- : timer_manager_(this),
+ : ALLOW_THIS_IN_INITIALIZER_LIST(timer_manager_(this)),
nestable_tasks_allowed_(true),
exception_restoration_(false),
state_(NULL) {