diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-01 23:15:13 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-01 23:15:13 +0000 |
commit | 9a28e84b325851310ca2cdfa59d8d8f2875d5a2e (patch) | |
tree | 0e7941cd59e926d8b6f66030016fecab0896c1df /clang/lib/Parse/Parser.cpp | |
parent | 3144e663778be58a6e378e642cef0136dface777 (diff) | |
download | bcm5719-llvm-9a28e84b325851310ca2cdfa59d8d8f2875d5a2e.tar.gz bcm5719-llvm-9a28e84b325851310ca2cdfa59d8d8f2875d5a2e.zip |
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.
llvm-svn: 97518
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index a6ae9cfd0d3..223d8865d61 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -274,6 +274,7 @@ void Parser::EnterScope(unsigned ScopeFlags) { } else { CurScope = new Scope(CurScope, ScopeFlags); } + CurScope->NumErrorsAtStart = Diags.getNumErrors(); } /// ExitScope - Pop a scope off the scope stack. |