From f15d4b6050a96c3261ceeda7aacdb4a2168de0ab Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 3 Sep 2009 00:43:07 +0000 Subject: This patch does the following. 1) Issue digsnostics in non-fragile ABI, when an expression evaluates to an interface type (except when it is used to access a non-fragile ivar). 2) Issue unsupported error in fragile ABI when an expression evaluates to an interface type (except when it is used to access a fragile ivar). llvm-svn: 80860 --- clang/lib/Sema/SemaExpr.cpp | 11 ++--------- clang/lib/Sema/SemaStmt.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 7072443829a..c01097e363c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -5023,15 +5023,8 @@ QualType Sema::CheckIndirectionOperand(Expr *Op, SourceLocation OpLoc) { if (const PointerType *PT = Ty->getAs()) return PT->getPointeeType(); - if (const ObjCObjectPointerType *OPT = Ty->getAsObjCObjectPointerType()) { - QualType PTy = OPT->getPointeeType(); - if (LangOpts.ObjCNonFragileABI && PTy->isObjCInterfaceType()) { - Diag(OpLoc, diag::err_indirection_requires_nonfragile_object) - << Ty << Op->getSourceRange(); - return QualType(); - } - return PTy; - } + if (const ObjCObjectPointerType *OPT = Ty->getAsObjCObjectPointerType()) + return OPT->getPointeeType(); Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer) << Ty << Op->getSourceRange(); diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index ae59aec5658..76113107ba8 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -26,7 +26,15 @@ using namespace clang; Sema::OwningStmtResult Sema::ActOnExprStmt(FullExprArg expr) { Expr *E = expr->takeAs(); assert(E && "ActOnExprStmt(): missing expression"); - + if (E->getType()->isObjCInterfaceType()) { + if (LangOpts.ObjCNonFragileABI) + Diag(E->getLocEnd(), diag::err_indirection_requires_nonfragile_object) + << E->getType(); + else + Diag(E->getLocEnd(), diag::err_direct_interface_unsupported) + << E->getType(); + return StmtError(); + } // C99 6.8.3p2: The expression in an expression statement is evaluated as a // void expression for its side effects. Conversion to void allows any // operand, even incomplete types. -- cgit v1.2.3