Have @finally introduce a new scope.
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
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index e957db4..8917eeb 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -1311,6 +1311,8 @@
} 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 @@
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
index 0000000..fbfa1e3
--- /dev/null
+++ b/test/Sema/rdar6248119.m
@@ -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;
+ }
+}