From: Fariborz Jahanian Date: Thu, 20 Dec 2007 01:06:58 +0000 (+0000) Subject: More objective-c typechecking stuff. This is work in progress and more patches X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7359f04a80cae1dcbd944ee07eb50a27ce7f5077;p=clang 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 --- 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(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(CanonicalType); } inline bool Type::isPointerType() const { - return isa(CanonicalType) || - isa(CanonicalType); + return isa(CanonicalType); } inline bool Type::isFunctionPointerType() const { if (const PointerType* T = getAsPointerType())