Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New clang warns Wincompatible-pointer-types in OCMConstraint.m #369

Closed
nico opened this issue Jan 3, 2019 · 2 comments
Closed

New clang warns Wincompatible-pointer-types in OCMConstraint.m #369

nico opened this issue Jan 3, 2019 · 2 comments

Comments

@nico
Copy link

nico commented Jan 3, 2019

We're seeing this in the Chromium build when using trunk clang:

FAILED: obj/third_party/ocmock/ocmock/OCMConstraint.o 
../../third_party/llvm-build/Release+Asserts/bin/clang -MMD -MF obj/third_party/ocmock/ocmock/OCMConstraint.o.d -DV8_DEPRECATION_WARNINGS -DNO_TCMALLOC -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -D_LIBCPP_HAS_NO_ALIGNED_ALLOCATION -DCR_XCODE_VERSION=0832 -DCR_CLANG_REVISION=\"350301\" -DCOMPONENT_BUILD -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DGTEST_API_= -DGTEST_HAS_POSIX_RE=0 -DGTEST_LANG_CXX11=1 -DGTEST_HAS_TR1_TUPLE=0 -DUNIT_TEST -I../.. -Igen -I../../third_party/ocmock -I../../third_party/googletest/custom -I../../third_party/googletest/src/googletest/include -fno-strict-aliasing -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -arch x86_64 -O2 -fno-omit-frame-pointer -g1 -isysroot ../../build/mac_files/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9.0 -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-semicolon-before-method-body -Wno-undeclared-selector -Werror -Wall -Wno-unused-variable -Wunguarded-availability -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-null-pointer-arithmetic -Wno-ignored-pragma-optimize -std=c11 -c ../../third_party/ocmock/OCMock/OCMConstraint.m -o obj/third_party/ocmock/ocmock/OCMConstraint.o
../../third_party/ocmock/OCMock/OCMConstraint.m:52:27: error: incompatible pointer types initializing 'OCMInvocationConstraint *' with an expression of type 'OCMConstraint *' [-Werror,-Wincompatible-pointer-types]
        OCMInvocationConstraint *constraint = [self constraintWithSelector:aSelector onObject:anObject];
                                 ^            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/ocmock/OCMock/OCMConstraint.h:29:1: note: class method 'constraintWithSelector:onObject:' is assumed to return an instance of its receiver type ('OCMConstraint *')
+ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject;
^
1 error generated

Looks like the warning is correct. constraintWithSelector: seems to always return an OCMInvocationConstraint though, so the return type of that method should probably just be OCMInvocationConstraint instead of instancetype.

aarongable pushed a commit to chromium/chromium that referenced this issue Jan 3, 2019
See erikdoe/ocmock#369

TBR=rnk

Bug: none
Change-Id: Ice9aca9e524d54eecb4bb41615f36c9926de1e2e
Reviewed-on: https://chromium-review.googlesource.com/c/1394430
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619636}
erikdoe added a commit that referenced this issue Oct 20, 2019
I decided to use a downcast to keep the external contract clearer. The downcast uses an implicit contract from the method just one up.
@erikdoe
Copy link
Owner

erikdoe commented Oct 20, 2019

Let me know whether the fix works for you.

@erikdoe
Copy link
Owner

erikdoe commented Nov 19, 2019

Assuming this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants