diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-06-03 14:04:54 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-06-03 14:04:54 +0000 |
| commit | b788d9bd277d8e8c829cd5a53fedb934fdb0ae48 (patch) | |
| tree | 580ddcbb1f91829dc792e007d9c6b90b7d625b77 /clang/lib | |
| parent | 0b225dac9b30ff21b0c5e27ab08e935c4ed10371 (diff) | |
| download | bcm5719-llvm-b788d9bd277d8e8c829cd5a53fedb934fdb0ae48.tar.gz bcm5719-llvm-b788d9bd277d8e8c829cd5a53fedb934fdb0ae48.zip | |
Allow implicit pointer/int conversions on ObjCQualifiedIdTypes in Sema::CheckCompareOperands() and Sema::CheckAssignmentConstraints().
Fixes <rdar://problem/5980804> clang on xcode: error: incompatible type sending 'id<XDUMLType>', expected 'NSCellType'.
llvm-svn: 51902
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index c384a9a5a2c..8b31d8856a7 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1301,6 +1301,11 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) { if (lhsType->isObjCQualifiedIdType() || rhsType->isObjCQualifiedIdType()) { if (ObjCQualifiedIdTypesAreCompatible(lhsType, rhsType, false)) return Compatible; + // Relax integer conversions like we do for pointers below. + if (rhsType->isIntegerType()) + return IntToPointer; + if (lhsType->isIntegerType()) + return PointerToInt; return Incompatible; } @@ -1647,12 +1652,14 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation loc, ImpCastExprToType(rex, lType); // promote the pointer to pointer return Context.IntTy; } - if ((lType->isObjCQualifiedIdType() || rType->isObjCQualifiedIdType()) - && ObjCQualifiedIdTypesAreCompatible(lType, rType, true)) { - ImpCastExprToType(rex, lType); - return Context.IntTy; + if ((lType->isObjCQualifiedIdType() || rType->isObjCQualifiedIdType())) { + if (ObjCQualifiedIdTypesAreCompatible(lType, rType, true)) { + ImpCastExprToType(rex, lType); + return Context.IntTy; + } } - if (lType->isPointerType() && rType->isIntegerType()) { + if ((lType->isPointerType() || lType->isObjCQualifiedIdType()) && + rType->isIntegerType()) { if (!RHSIsNull) Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer, lType.getAsString(), rType.getAsString(), @@ -1660,7 +1667,8 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation loc, ImpCastExprToType(rex, lType); // promote the integer to pointer return Context.IntTy; } - if (lType->isIntegerType() && rType->isPointerType()) { + if (lType->isIntegerType() && + (rType->isPointerType() || rType->isObjCQualifiedIdType())) { if (!LHSIsNull) Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer, lType.getAsString(), rType.getAsString(), |

