mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-28 08:02:08 +00:00
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! llvm-svn: 332821
This commit is contained in:
parent
777afc7fbd
commit
278e1c460b
@ -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,
|
||||
|
9
clang/test/SemaObjC/catch-invalid.m
Normal file
9
clang/test/SemaObjC/catch-invalid.m
Normal file
@ -0,0 +1,9 @@
|
||||
// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -fobjc-exceptions -fobjc-runtime=ios -verify %s
|
||||
|
||||
extern void g(void);
|
||||
void f() {
|
||||
@try {
|
||||
g();
|
||||
} @catch (Class c) { // expected-error{{@catch parameter is not a pointer to an interface type}}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user