aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-14 00:23:56 +0000
committerChris Lattner <sabre@nondot.org>2009-06-14 00:23:56 +0000
commit7b3684afffa2d5eda3dd6930f01faaa673686c16 (patch)
treed2173fc0e0a3f15c083bca544c7a8134caefb10f /lib/Parse/ParseStmt.cpp
parent6869d8ea1bb7d191b5b290f5a55ee74f2174829a (diff)
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 ^ ; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73315 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r--lib/Parse/ParseStmt.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 8cdcd517ca..955f00d7a0 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -180,10 +180,14 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
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);
}