diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-09-28 01:11:11 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-09-28 01:11:11 +0000 |
| commit | e18f94c20debd029b283e380665de3fe9fcd7b7c (patch) | |
| tree | 0e27d154b7f5a0bb7c06c3e092ad4e9e4c08db84 /clang/lib/Sema/SemaExpr.cpp | |
| parent | d3dcb4f8edf3a9ce5a64bc6259fe23153ce702d3 (diff) | |
| download | bcm5719-llvm-e18f94c20debd029b283e380665de3fe9fcd7b7c.tar.gz bcm5719-llvm-e18f94c20debd029b283e380665de3fe9fcd7b7c.zip | |
Fix <rdar://problem/6252216> compare block to NULL.
llvm-svn: 56764
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
| -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 dfa53ac4398..07ce6b0b2f0 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)) { |

