diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5cc234e64036..9f27f8d7cd0e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -2153,6 +2153,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation loc, Diag(loc, diag::ext_typecheck_comparison_of_distinct_pointers, lType.getAsString(), rType.getAsString(), lex->getSourceRange(), rex->getSourceRange()); + ImpCastExprToType(rex, lType); return Context.IntTy; } if (ObjCQualifiedIdTypesAreCompatible(lType, rType, true)) { @@ -2161,8 +2162,9 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation loc, } else { if ((lType->isObjCQualifiedIdType() && rType->isObjCQualifiedIdType())) { Diag(loc, diag::warn_incompatible_qualified_id_operands, - lex->getType().getAsString(), rex->getType().getAsString(), + lType.getAsString(), rType.getAsString(), lex->getSourceRange(), rex->getSourceRange()); + ImpCastExprToType(rex, lType); return Context.IntTy; } } diff --git a/clang/test/CodeGenObjC/2008-10-23-invalid-icmp.m b/clang/test/CodeGenObjC/2008-10-23-invalid-icmp.m new file mode 100644 index 000000000000..abfe6afcc7cc --- /dev/null +++ b/clang/test/CodeGenObjC/2008-10-23-invalid-icmp.m @@ -0,0 +1,7 @@ +// RUN: clang -emit-llvm -o %t %s + +@protocol P @end + +int f0(id

d) { + return (d != ((void*) 0)); +}