Fix a bug recovering from broken code with a goto that Eli reported.

llvm-svn: 46336
This commit is contained in:
Chris Lattner 2008-01-25 00:01:10 +00:00
parent 9046dc1080
commit 3efff5472b
3 changed files with 12 additions and 3 deletions

View File

@ -131,7 +131,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags,
ColNo = LPos.getColumnNumber();
const char *TokLogicalPtr = LPos.getCharacterData();
LineStart = TokLogicalPtr-ColNo+1; // Column # is 1-based
// Compute the line end. Scan forward from the error position to the end of
// the line.
const llvm::MemoryBuffer *Buffer = LPos.getBuffer();

View File

@ -1031,8 +1031,13 @@ Sema::DeclTy *Sema::ActOnFinishFunctionBody(DeclTy *D, StmtTy *Body) {
// At this point, we have gotos that use the bogus label. Stitch it into
// the function body so that they aren't leaked and that the AST is well
// formed.
L->setSubStmt(new NullStmt(L->getIdentLoc()));
cast<CompoundStmt>((Stmt*)Body)->push_back(L);
if (Body) {
L->setSubStmt(new NullStmt(L->getIdentLoc()));
cast<CompoundStmt>((Stmt*)Body)->push_back(L);
} else {
// The whole function wasn't parsed correctly, just delete this.
delete L;
}
}
}
LabelMap.clear();

View File

@ -0,0 +1,4 @@
// RUN: clang -fsyntax-only %s -verify
void a() {goto A; // expected-error {{use of undeclared label}}
// expected-error {{expected '}'}}