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();
// 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();
--- /dev/null
+// RUN: clang -fsyntax-only %s -verify
+
+void a() {goto A; // expected-error {{use of undeclared label}}
+// expected-error {{expected '}'}}