[cfe-commits] r73315 - in /cfe/trunk: lib/Parse/ParseStmt.cpp test/Parser/statements.c
Chris Lattner
sabre at nondot.org
Sat Jun 13 17:23:56 PDT 2009
Author: lattner
Date: Sat Jun 13 19:23:56 2009
New Revision: 73315
URL: http://llvm.org/viewvc/llvm-project?rev=73315&view=rev
Log:
change ParseStatementOrDeclaration to emit the 'missing ;' with
ExpectAndConsume instead of custom diag logic. This gets us an
insertion hint and positions the ; at the end of the line
instead of on the next token. Before:
t.c:5:1: error: expected ';' after return statement
}
^
after:
t.c:4:11: error: expected ';' after return statement
return 4
^
;
Modified:
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/test/Parser/statements.c
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=73315&r1=73314&r2=73315&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Sat Jun 13 19:23:56 2009
@@ -180,10 +180,14 @@
if (Tok.is(tok::semi)) {
ConsumeToken();
} else if (!Res.isInvalid()) {
- Diag(Tok, diag::err_expected_semi_after_stmt) << SemiError;
+ // If the result was valid, then we do want to diagnose this. Use
+ // ExpectAndConsume to emit the diagnostic, even though we know it won't
+ // succeed.
+ ExpectAndConsume(tok::semi, diag::err_expected_semi_after_stmt, SemiError);
// Skip until we see a } or ;, but don't eat it.
SkipUntil(tok::r_brace, true, true);
}
+
return move(Res);
}
Modified: cfe/trunk/test/Parser/statements.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/statements.c?rev=73315&r1=73314&r2=73315&view=diff
==============================================================================
--- cfe/trunk/test/Parser/statements.c (original)
+++ cfe/trunk/test/Parser/statements.c Sat Jun 13 19:23:56 2009
@@ -54,3 +54,6 @@
while (0);
}
+int test7() {
+ return 4 // expected-error {{expected ';' after return statement}}
+}
More information about the cfe-commits
mailing list