]> granicus.if.org Git - clang/commitdiff
Have @finally introduce a new scope.
authorTed Kremenek <kremenek@apple.com>
Fri, 26 Sep 2008 00:31:16 +0000 (00:31 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 26 Sep 2008 00:31:16 +0000 (00:31 +0000)
Fixes: <rdar://problem/6248119> @finally doesn't introduce a new scope
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56629 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseObjc.cpp
test/Sema/rdar6248119.m [new file with mode: 0644]

index e957db4ed9afa05764319c907c63527adad283b7..8917eeb0ffa3685ac54673a3c7ba14f7c69e5aca 100644 (file)
@@ -1311,6 +1311,8 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
     } else {
       assert(Tok.isObjCAtKeyword(tok::objc_finally) && "Lookahead confused?");
       ConsumeToken(); // consume finally
+      EnterScope(Scope::DeclScope);
+
       
       StmtResult FinallyBody(true);
       if (Tok.is(tok::l_brace))
@@ -1322,6 +1324,7 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
       FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc, 
                                                    FinallyBody.Val);
       catch_or_finally_seen = true;
+      ExitScope();
       break;
     }
   }
diff --git a/test/Sema/rdar6248119.m b/test/Sema/rdar6248119.m
new file mode 100644 (file)
index 0000000..fbfa1e3
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: clang -fsyntax-only %s -verify
+// Test case for: 
+//   <rdar://problem/6248119> @finally doesn't introduce a new scope
+
+void f0() {
+  int i;
+  @try { 
+  } @finally {
+    int i = 0;
+  }
+}