Conversions from Objective C object pointers to bool are "pointer conversions

to bool" in the sense of C++ [over.ics.rank]p4 bullet 1.  I have decreed it.

llvm-svn: 105817
This commit is contained in:
John McCall 2010-06-11 10:04:22 +00:00
parent 5d474d0a96
commit 6d1116ac49
2 changed files with 12 additions and 1 deletions

View 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;

View 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);
}
}