summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2018-05-20 19:26:44 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2018-05-20 19:26:44 +0000
commit4d415cd5b38074fa908fc6faed2321ccb63ad5a4 (patch)
tree8a0ee8098f1945df1edc72ec699b9dce208182ac /lib/Sema/SemaDeclObjC.cpp
parentb212149560e3d1403b49c5d0a44eac271a9f0938 (diff)
downloadclang-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/Sema/SemaDeclObjC.cpp')
-rw-r--r--lib/Sema/SemaDeclObjC.cpp11
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,