[cfe-commits] r46336 - in /cfe/trunk: Driver/TextDiagnosticPrinter.cpp Sema/SemaDecl.cpp test/Sema/recover-goto.c
Chris Lattner
sabre at nondot.org
Thu Jan 24 16:01:10 PST 2008
Author: lattner
Date: Thu Jan 24 18:01:10 2008
New Revision: 46336
URL: http://llvm.org/viewvc/llvm-project?rev=46336&view=rev
Log:
Fix a bug recovering from broken code with a goto that Eli reported.
Added:
cfe/trunk/test/Sema/recover-goto.c
Modified:
cfe/trunk/Driver/TextDiagnosticPrinter.cpp
cfe/trunk/Sema/SemaDecl.cpp
Modified: cfe/trunk/Driver/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticPrinter.cpp?rev=46336&r1=46335&r2=46336&view=diff
==============================================================================
--- cfe/trunk/Driver/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/Driver/TextDiagnosticPrinter.cpp Thu Jan 24 18:01:10 2008
@@ -131,7 +131,7 @@
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();
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=46336&r1=46335&r2=46336&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Thu Jan 24 18:01:10 2008
@@ -1031,8 +1031,13 @@
// 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();
Added: cfe/trunk/test/Sema/recover-goto.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/recover-goto.c?rev=46336&view=auto
==============================================================================
--- cfe/trunk/test/Sema/recover-goto.c (added)
+++ cfe/trunk/test/Sema/recover-goto.c Thu Jan 24 18:01:10 2008
@@ -0,0 +1,4 @@
+// RUN: clang -fsyntax-only %s -verify
+
+void a() {goto A; // expected-error {{use of undeclared label}}
+// expected-error {{expected '}'}}
More information about the cfe-commits
mailing list