diff options
author | Mike Stump <mrs@apple.com> | 2010-01-19 23:08:01 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2010-01-19 23:08:01 +0000 |
commit | 314825bc8ac6ef3245ca4c1b3aee89f0da2632f6 (patch) | |
tree | 7c39f72d4602cc590c50eb3547710043026796e7 /clang/lib/Sema/SemaExpr.cpp | |
parent | 99469702a359b723352d251ce994bfaeaa15e306 (diff) | |
download | bcm5719-llvm-314825bc8ac6ef3245ca4c1b3aee89f0da2632f6.tar.gz bcm5719-llvm-314825bc8ac6ef3245ca4c1b3aee89f0da2632f6.zip |
Implement goto inside of blocks.
llvm-svn: 93945
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 8c740dd1dbf..19d38bf9d12 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6884,6 +6884,26 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, CurFunctionNeedsScopeChecking = BSI->SavedFunctionNeedsScopeChecking; BSI->TheDecl->setBody(body.takeAs<CompoundStmt>()); + + bool Good = true; + // Check goto/label use. + for (llvm::DenseMap<IdentifierInfo*, LabelStmt*>::iterator + I = BSI->LabelMap.begin(), E = BSI->LabelMap.end(); I != E; ++I) { + LabelStmt *L = I->second; + + // Verify that we have no forward references left. If so, there was a goto + // or address of a label taken, but no definition of it. + if (L->getSubStmt() != 0) + continue; + + // Emit error. + Diag(L->getIdentLoc(), diag::err_undeclared_label_use) << L->getName(); + Good = false; + } + BSI->LabelMap.clear(); + if (!Good) + return ExprError(); + AnalysisContext AC(BSI->TheDecl); CheckFallThroughForBlock(BlockTy, BSI->TheDecl->getBody(), AC); CheckUnreachable(AC); |