[cfe-commits] r69073 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaObjC/scope-check-try-catch.m

Steve Naroff snaroff at apple.com
Tue Apr 14 13:53:38 PDT 2009


Author: snaroff
Date: Tue Apr 14 15:53:38 2009
New Revision: 69073

URL: http://llvm.org/viewvc/llvm-project?rev=69073&view=rev
Log:
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.


Added:
    cfe/trunk/test/SemaObjC/scope-check-try-catch.m
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=69073&r1=69072&r2=69073&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 14 15:53:38 2009
@@ -2897,21 +2897,22 @@
 }
 
 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;
 }
 

Added: cfe/trunk/test/SemaObjC/scope-check-try-catch.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/scope-check-try-catch.m?rev=69073&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/scope-check-try-catch.m (added)
+++ cfe/trunk/test/SemaObjC/scope-check-try-catch.m Tue Apr 14 15:53:38 2009
@@ -0,0 +1,18 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+ at 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: ;
+  }
+}





More information about the cfe-commits mailing list