]> granicus.if.org Git - clang/commit
Keep an explicit stack of function and block scopes, each element of
authorDouglas Gregor <dgregor@apple.com>
Mon, 1 Mar 2010 23:15:13 +0000 (23:15 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 1 Mar 2010 23:15:13 +0000 (23:15 +0000)
commit9ea9bdbc14374f7bacdb50d3e52c664ff12150ff
tree26b4cdeaef74f71025025825a4f13b5fef0d9b44
parent7bf3600f56342dc434dad994d0c71068e5d3b5c7
Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.

The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.

Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97518 91177308-0d34-0410-b5e6-96231b3b80d8
12 files changed:
include/clang/Parse/Scope.h
lib/Parse/Parser.cpp
lib/Sema/Sema.cpp
lib/Sema/Sema.h
lib/Sema/SemaChecking.cpp
lib/Sema/SemaCodeComplete.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclObjC.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaStmt.cpp
test/Sema/warn-unused-variables.c
test/SemaCXX/local-classes.cpp [new file with mode: 0644]