}
if ((lType->isObjCQualifiedIdType() || rType->isObjCQualifiedIdType())) {
- if ((lType->isPointerType() || rType->isPointerType()) &&
- !Context.typesAreCompatible(lType, rType)) {
- Diag(loc, diag::ext_typecheck_comparison_of_distinct_pointers,
- lType.getAsString(), rType.getAsString(),
- lex->getSourceRange(), rex->getSourceRange());
+ if (lType->isPointerType() || rType->isPointerType()) {
+ if (!Context.typesAreCompatible(lType, rType)) {
+ Diag(loc, diag::ext_typecheck_comparison_of_distinct_pointers,
+ lType.getAsString(), rType.getAsString(),
+ lex->getSourceRange(), rex->getSourceRange());
+ ImpCastExprToType(rex, lType);
+ return Context.IntTy;
+ }
ImpCastExprToType(rex, lType);
return Context.IntTy;
}
must generate a warning. */
/* FIXME: GCC considers this a warning ("comparison of distinct pointer types"). */
/* There is a corresponding FIXME in ASTContext::mergeTypes() */
- if (obj_p == obj_c) foo() ; // expected-error {{invalid operands to binary expression ('id<MyProtocol>' and 'MyClass *')}}
+ if (obj_p == obj_c) foo() ;
if (obj_c == obj_cp) foo() ; // expected-warning {{comparison of distinct pointer types ('MyClass *' and 'MyOtherClass *')}}
if (obj_cp == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('MyOtherClass *' and 'MyClass *')}}