]> granicus.if.org Git - clang/commitdiff
Conversions from Objective C object pointers to bool are "pointer conversions
authorJohn McCall <rjmccall@apple.com>
Fri, 11 Jun 2010 10:04:22 +0000 (10:04 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 11 Jun 2010 10:04:22 +0000 (10:04 +0000)
to bool" in the sense of C++ [over.ics.rank]p4 bullet 1.  I have decreed it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105817 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaObjCXX/overload.mm

index d3e8243f94f6ca2e585c3cd958c25c88efb615f3..89eb90bc13d7710218c0c0e13898b225f3153079 100644 (file)
@@ -155,7 +155,9 @@ bool StandardConversionSequence::isPointerConversionToBool() const {
   // check for their presence as well as checking whether FromType is
   // a pointer.
   if (getToType(1)->isBooleanType() &&
-      (getFromType()->isPointerType() || getFromType()->isBlockPointerType() ||
+      (getFromType()->isPointerType() ||
+       getFromType()->isObjCObjectPointerType() ||
+       getFromType()->isBlockPointerType() ||
        First == ICK_Array_To_Pointer || First == ICK_Function_To_Pointer))
     return true;
 
index 18da69f5442ea80639bbafea527876cabdf75b25..487a42e1a1103bb6ac491dd16d3f1b33cba1dd8a 100644 (file)
@@ -93,3 +93,12 @@ void (*_NSExceptionRaiser(void))(NSException *) {
     objc_exception_functions_t exc_funcs;
     return exc_funcs.throw_exc; // expected-warning{{incompatible pointer types returning 'void (*)(NSException *)', expected 'void (*)(id)'}}
 }
+
+namespace test5 {
+  void foo(bool);
+  void foo(void *);
+
+  void test(id p) {
+    foo(p);
+  }
+}