From: Ted Kremenek Date: Fri, 26 Sep 2008 00:31:16 +0000 (+0000) Subject: Have @finally introduce a new scope. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aefc36656d3113ef32a50cea9ae0621e07c8b26c;p=clang Have @finally introduce a new scope. Fixes: @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 e957db4ed9..8917eeb0ff 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -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 index 0000000000..fbfa1e3af3 --- /dev/null +++ b/test/Sema/rdar6248119.m @@ -0,0 +1,11 @@ +// RUN: clang -fsyntax-only %s -verify +// Test case for: +// @finally doesn't introduce a new scope + +void f0() { + int i; + @try { + } @finally { + int i = 0; + } +}