diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2018-05-20 19:26:44 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2018-05-20 19:26:44 +0000 |
commit | 4d415cd5b38074fa908fc6faed2321ccb63ad5a4 (patch) | |
tree | 8a0ee8098f1945df1edc72ec699b9dce208182ac /lib | |
parent | b212149560e3d1403b49c5d0a44eac271a9f0938 (diff) | |
download | clang-4d415cd5b38074fa908fc6faed2321ccb63ad5a4.tar.gz |
Sema: diagnose invalid catch parameter in ObjC
Ensure that the type being used has an associated interface when
declaring the parameter for `@catch`.
Resolves PR37384!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332821 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 87d37e6825..d7544ecfaf 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -4838,12 +4838,17 @@ VarDecl *Sema::BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType T, // Don't do any further checking. } else if (T->isDependentType()) { // Okay: we don't know what this type will instantiate to. - } else if (!T->isObjCObjectPointerType()) { - Invalid = true; - Diag(IdLoc ,diag::err_catch_param_not_objc_type); } else if (T->isObjCQualifiedIdType()) { Invalid = true; Diag(IdLoc, diag::err_illegal_qualifiers_on_catch_parm); + } else if (T->isObjCIdType()) { + // Okay: we don't know what this type will instantiate to. + } else if (!T->isObjCObjectPointerType()) { + Invalid = true; + Diag(IdLoc, diag::err_catch_param_not_objc_type); + } else if (!T->getAs<ObjCObjectPointerType>()->getInterfaceType()) { + Invalid = true; + Diag(IdLoc, diag::err_catch_param_not_objc_type); } VarDecl *New = VarDecl::Create(Context, CurContext, StartLoc, IdLoc, Id, |