mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-15 12:09:51 +00:00
Fix a bug recovering from broken code with a goto that Eli reported.
llvm-svn: 46336
This commit is contained in:
parent
9046dc1080
commit
3efff5472b
@ -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();
|
||||
|
@ -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();
|
||||
|
4
clang/test/Sema/recover-goto.c
Normal file
4
clang/test/Sema/recover-goto.c
Normal file
@ -0,0 +1,4 @@
|
||||
// RUN: clang -fsyntax-only %s -verify
|
||||
|
||||
void a() {goto A; // expected-error {{use of undeclared label}}
|
||||
// expected-error {{expected '}'}}
|
Loading…
Reference in New Issue
Block a user