diff options
author | Steve Naroff <snaroff@apple.com> | 2009-03-13 16:03:38 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-03-13 16:03:38 +0000 |
commit | cfb6cf4c021e41db7b36b7909296798d955e8123 (patch) | |
tree | a63259f07ce81c4b2fa9557976fd752b87c565e9 /clang/lib/Sema/SemaStmt.cpp | |
parent | 87710ca527f624ef0c5b4c5e2fbf1474e4eac219 (diff) | |
download | bcm5719-llvm-cfb6cf4c021e41db7b36b7909296798d955e8123.tar.gz bcm5719-llvm-cfb6cf4c021e41db7b36b7909296798d955e8123.zip |
Reimplement fix for <rdar://problem/6451399> problems with labels and blocks.
This solution is much simpler (and doesn't add any per-scope overhead, which concerned Chris).
The only downside is the LabelMap is now declared in two places (Sema and BlockSemaInfo). My original fix tried to unify the LabelMap in "Scope" (which would support nested functions in general). In any event, this fixes the bug given the current language definition. If/when we decide to support GCC style nested functions, this will need to be tweaked.
llvm-svn: 66896
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index f8e225540bc..96e59f0f82b 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -170,7 +170,7 @@ Sema::ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II, SourceLocation ColonLoc, StmtArg subStmt) { Stmt *SubStmt = static_cast<Stmt*>(subStmt.release()); // Look up the record for this label identifier. - LabelStmt *&LabelDecl = LabelMap[II]; + LabelStmt *&LabelDecl = CurBlock ? CurBlock->LabelMap[II] : LabelMap[II]; // If not forward referenced or defined already, just create a new LabelStmt. if (LabelDecl == 0) @@ -676,7 +676,8 @@ Sema::ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, return StmtError(Diag(GotoLoc, diag::err_goto_in_block)); // Look up the record for this label identifier. - LabelStmt *&LabelDecl = LabelMap[LabelII]; + LabelStmt *&LabelDecl = CurBlock ? CurBlock->LabelMap[LabelII] : + LabelMap[LabelII]; // If we haven't seen this label yet, create a forward reference. if (LabelDecl == 0) |