forked from OSchip/llvm-project
Fix <rdar://problem/6252084> [sema] jumps into Obj-C exception blocks should be disallowed.
This builds on Eli's work from http://llvm.org/viewvc/llvm-project?view=rev&revision=65678. llvm-svn: 69073
This commit is contained in:
parent
b874dbd478
commit
5196c618fb
|
@ -2897,21 +2897,22 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
|
|||
}
|
||||
|
||||
static bool StatementCreatesScope(Stmt* S) {
|
||||
DeclStmt *DS = dyn_cast<DeclStmt>(S);
|
||||
if (DS == 0) return false;
|
||||
|
||||
for (DeclStmt::decl_iterator I = DS->decl_begin(), E = DS->decl_end();
|
||||
I != E; ++I) {
|
||||
if (VarDecl *D = dyn_cast<VarDecl>(*I)) {
|
||||
if (D->getType()->isVariablyModifiedType() ||
|
||||
D->hasAttr<CleanupAttr>())
|
||||
return true;
|
||||
} else if (TypedefDecl *D = dyn_cast<TypedefDecl>(*I)) {
|
||||
if (D->getUnderlyingType()->isVariablyModifiedType())
|
||||
return true;
|
||||
if (DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
|
||||
for (DeclStmt::decl_iterator I = DS->decl_begin(), E = DS->decl_end();
|
||||
I != E; ++I) {
|
||||
if (VarDecl *D = dyn_cast<VarDecl>(*I)) {
|
||||
if (D->getType()->isVariablyModifiedType() ||
|
||||
D->hasAttr<CleanupAttr>())
|
||||
return true;
|
||||
} else if (TypedefDecl *D = dyn_cast<TypedefDecl>(*I)) {
|
||||
if (D->getUnderlyingType()->isVariablyModifiedType())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (isa<ObjCAtTryStmt>(S)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
// RUN: clang-cc -fsyntax-only -verify %s
|
||||
|
||||
@class A, B, C;
|
||||
|
||||
void f() {
|
||||
goto L; // expected-error{{illegal jump}}
|
||||
goto L2; // expected-error{{illegal jump}}
|
||||
goto L3; // expected-error{{illegal jump}}
|
||||
@try {
|
||||
L: ;
|
||||
} @catch (A *x) {
|
||||
L2: ;
|
||||
} @catch (B *x) {
|
||||
} @catch (C *c) {
|
||||
} @finally {
|
||||
L3: ;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue