From 6673317aabd12e4575027ed300d006f9e2bc3824 Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Wed, 22 Sep 2010 00:09:28 +0000 Subject: Mac: clang build Fixes the last few warnings / errors necessary to build chrome/mac with clang. See http://code.google.com/p/chromium/wiki/Clang BUG=none TEST=none Review URL: http://codereview.chromium.org/2762014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60131 0039d316-1c4b-4281-b951-d872f2087c98 --- build/common.gypi | 7 +++++++ chrome/browser/autofill/autofill_text_field_mac.mm | 12 +++++++++--- chrome/browser/cocoa/authorization_util.mm | 3 ++- chrome/browser/cocoa/bookmark_bar_controller.mm | 7 ++++++- gpu/command_buffer/client/fenced_allocator.h | 4 +++- gpu/command_buffer/client/gles2_implementation.cc | 11 ++++++----- ipc/ipc_channel_posix.cc | 3 +-- 7 files changed, 34 insertions(+), 13 deletions(-) diff --git a/build/common.gypi b/build/common.gypi index d81c567..66294115 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -1234,6 +1234,13 @@ ['chromium_mac_pch', {'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'}, {'GCC_PRECOMPILE_PREFIX_HEADER': 'NO'} ], + ['clang==1', { + 'WARNING_CFLAGS': [ + # Don't die on dtoa code that uses a char as an array index. + # This is required solely for base/third_party/dmg_fp/dtoa.cc. + '-Wno-char-subscripts', + ], + }], ], }, 'target_conditions': [ diff --git a/chrome/browser/autofill/autofill_text_field_mac.mm b/chrome/browser/autofill/autofill_text_field_mac.mm index 509b1a6..5db2ffb 100644 --- a/chrome/browser/autofill/autofill_text_field_mac.mm +++ b/chrome/browser/autofill/autofill_text_field_mac.mm @@ -24,10 +24,16 @@ } } -- (void)setObjectValue:(id)object { - if (isCreditCardField_ && [object isKindOfClass:[NSString class]]) { +- (void)setObjectValue:(id)anObject { + // -[NSControl setObjectValue:] says that the passed-in object has type + // |id|, but this function needs to call the NSObject method + // -isKindOfClass: on the parameter. In theory, this is not correct, but this + // is probably a bug in the method signature. + NSObject* object = static_cast*>(anObject); + if (isCreditCardField_ && + [object isKindOfClass:[NSString class]]) { // Obfuscate the number. - NSString* string = object; + NSString* string = static_cast(object); CreditCard card; card.SetInfo(AutoFillType(CREDIT_CARD_NUMBER), base::SysNSStringToUTF16(string)); diff --git a/chrome/browser/cocoa/authorization_util.mm b/chrome/browser/cocoa/authorization_util.mm index fdd4387..e255993 100644 --- a/chrome/browser/cocoa/authorization_util.mm +++ b/chrome/browser/cocoa/authorization_util.mm @@ -48,7 +48,8 @@ AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt) { // The OS will append " Type an administrator's name and password to allow // to make changes." - NSString* prompt_ns = reinterpret_cast(prompt); + NSString* prompt_ns = const_cast( + reinterpret_cast(prompt)); const char* prompt_c = [prompt_ns UTF8String]; size_t prompt_length = prompt_c ? strlen(prompt_c) : 0; diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index 9c6f8d5..0c7ec9d 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -874,7 +874,12 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; // Enable or disable items. We are the menu delegate for both the bar // and for bookmark folder buttons. -- (BOOL)validateUserInterfaceItem:(id)item { +- (BOOL)validateUserInterfaceItem:(id)anItem { + // NSUserInterfaceValidations says that the passed-in object has type + // |id|, but this function needs to call the + // NSObject method -isKindOfClass: on the parameter. In theory, this is not + // correct, but this is probably a bug in the method signature. + NSMenuItem* item = static_cast(anItem); // Yes for everything we don't explicitly deny. if (![item isKindOfClass:[NSMenuItem class]]) return YES; diff --git a/gpu/command_buffer/client/fenced_allocator.h b/gpu/command_buffer/client/fenced_allocator.h index fb97e37..fd162db41 100644 --- a/gpu/command_buffer/client/fenced_allocator.h +++ b/gpu/command_buffer/client/fenced_allocator.h @@ -212,7 +212,9 @@ class FencedAllocatorWrapper { // Gets the offset to a memory block given the base memory and the address. // It translates NULL to FencedAllocator::kInvalidOffset. FencedAllocator::Offset GetOffset(void *pointer) { - return pointer ? static_cast(pointer) - static_cast(base_) : + return pointer ? + static_cast( + static_cast(pointer) - static_cast(base_)) : FencedAllocator::kInvalidOffset; } diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 6dad4e2..58ddd2b 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -311,8 +311,8 @@ class ClientSideBufferHelper { size_t bytes_per_element = GLES2Util::GetGLTypeSizeForTexturesAndBuffers(info.type()) * info.size(); - GLsizei real_stride = - info.stride() ? info.stride() : bytes_per_element; + GLsizei real_stride = info.stride() ? + info.stride() : static_cast(bytes_per_element); GLsizei bytes_collected = CollectData( info.pointer(), bytes_per_element, real_stride, num_elements); gl->BufferSubData( @@ -814,8 +814,8 @@ void GLES2Implementation::ShaderSource( uint32 total_size = 1; for (GLsizei ii = 0; ii < count; ++ii) { if (source[ii]) { - total_size += - (length && length[ii] >= 0) ? length[ii] : strlen(source[ii]); + total_size += (length && length[ii] >= 0) ? + static_cast(length[ii]) : strlen(source[ii]); } } @@ -826,7 +826,8 @@ void GLES2Implementation::ShaderSource( for (GLsizei ii = 0; ii <= count; ++ii) { const char* src = ii < count ? source[ii] : ""; if (src) { - uint32 size = ii < count ? (length ? length[ii] : strlen(src)) : 1; + uint32 size = ii < count ? + (length ? static_cast(length[ii]) : strlen(src)) : 1; while (size) { uint32 part_size = std::min(size, max_size); void* buffer = transfer_buffer_.Alloc(part_size); diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc index e4852b4..1c1b4e6 100644 --- a/ipc/ipc_channel_posix.cc +++ b/ipc/ipc_channel_posix.cc @@ -135,8 +135,7 @@ int ChannelNameToFD(const std::string& channel_id) { } //------------------------------------------------------------------------------ -sockaddr_un sizecheck; -const size_t kMaxPipeNameLength = sizeof(sizecheck.sun_path); +const size_t kMaxPipeNameLength = sizeof(((sockaddr_un*)0)->sun_path); // Creates a Fifo with the specified name ready to listen on. bool CreateServerFifo(const std::string& pipe_name, int* server_listen_fd) { -- cgit v1.1