diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index dfa53ac..07ce6b0 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -2034,6 +2034,17 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation loc, ImpCastExprToType(rex, lType); // promote the pointer to pointer return Context.IntTy; } + // Allow block pointers to be compared with null pointer constants. + if ((lType->isBlockPointerType() && rType->isPointerType()) || + (lType->isPointerType() && rType->isBlockPointerType())) { + if (!LHSIsNull && !RHSIsNull) { + Diag(loc, diag::err_typecheck_comparison_of_distinct_blocks, + lType.getAsString(), rType.getAsString(), + lex->getSourceRange(), rex->getSourceRange()); + } + ImpCastExprToType(rex, lType); // promote the pointer to pointer + return Context.IntTy; + } if ((lType->isObjCQualifiedIdType() || rType->isObjCQualifiedIdType())) { if (ObjCQualifiedIdTypesAreCompatible(lType, rType, true)) { |