diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2007-12-20 01:06:58 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2007-12-20 01:06:58 +0000 |
commit | 7359f04a80cae1dcbd944ee07eb50a27ce7f5077 (patch) | |
tree | 83ef1a052606d892956d61e6049af390e529bad9 | |
parent | fe23e217774aaec350086fab839210d7d9e1e3f4 (diff) |
More objective-c typechecking stuff. This is work in progress and more patches
are due to arrive.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45244 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Sema/SemaChecking.cpp | 7 | ||||
-rw-r--r-- | Sema/SemaExpr.cpp | 5 | ||||
-rw-r--r-- | include/clang/AST/Type.h | 3 |
3 files changed, 11 insertions, 4 deletions
diff --git a/Sema/SemaChecking.cpp b/Sema/SemaChecking.cpp index 01314102d4..09304399e9 100644 --- a/Sema/SemaChecking.cpp +++ b/Sema/SemaChecking.cpp @@ -594,7 +594,9 @@ Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType, static DeclRefExpr* EvalAddr(Expr *E) { // We should only be called for evaluating pointer expressions. - assert (E->getType()->isPointerType() && "EvalAddr only works on pointers"); + assert ((E->getType()->isPointerType() || + E->getType()->isObjcQualifiedIdType()) + && "EvalAddr only works on pointers"); // Our "symbolic interpreter" is just a dispatch off the currently // viewed AST node. We then recursively traverse the AST by calling @@ -654,7 +656,8 @@ static DeclRefExpr* EvalAddr(Expr *E) { ImplicitCastExpr *IE = cast<ImplicitCastExpr>(E); Expr* SubExpr = IE->getSubExpr(); - if (SubExpr->getType()->isPointerType()) + if (SubExpr->getType()->isPointerType() || + SubExpr->getType()->isObjcQualifiedIdType()) return EvalAddr(SubExpr); else return EvalVal(SubExpr); diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index 846c52905c..e720c2e460 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -1399,6 +1399,11 @@ inline QualType Sema::CheckCompareOperands( // C99 6.5.8 promoteExprToType(rex, lType); // promote the pointer to pointer return Context.IntTy; } + if ((lType->isObjcQualifiedIdType() || rType->isObjcQualifiedIdType()) + && Context.ObjcQualifiedIdTypesAreCompatible(lType, rType)) { + promoteExprToType(rex, lType); + return Context.IntTy; + } if (lType->isPointerType() && rType->isIntegerType()) { if (!RHSIsNull) Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer, diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 7c93910806..e3825a9f31 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -1029,8 +1029,7 @@ inline bool Type::isFunctionType() const { return isa<FunctionType>(CanonicalType); } inline bool Type::isPointerType() const { - return isa<PointerType>(CanonicalType) || - isa<ObjcQualifiedIdType>(CanonicalType); + return isa<PointerType>(CanonicalType); } inline bool Type::isFunctionPointerType() const { if (const PointerType* T = getAsPointerType()) |