Fix <rdar://problem/6632061> [sema] non object types should not be allowed in @catch statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65968 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 49bd85a..7e7edbe 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -965,9 +965,15 @@
SourceLocation RParen, DeclTy *Parm,
StmtArg Body, StmtArg catchList) {
Stmt *CatchList = static_cast<Stmt*>(catchList.release());
+ ParmVarDecl *PVD = static_cast<ParmVarDecl*>(Parm);
+
+ // PVD == 0 implies @catch(...).
+ if (PVD && !Context.isObjCObjectPointerType(PVD->getType()))
+ return StmtError(Diag(PVD->getLocation(),
+ diag::err_catch_param_not_objc_type));
+
ObjCAtCatchStmt *CS = new (Context) ObjCAtCatchStmt(AtLoc, RParen,
- static_cast<ParmVarDecl*>(Parm), static_cast<Stmt*>(Body.release()),
- CatchList);
+ PVD, static_cast<Stmt*>(Body.release()), CatchList);
return Owned(CatchList ? CatchList : CS);
}