When parsing an expr in stmt context, make sure to consume the semicolon

after the expr along with the expr.  If we don't do this, the semicolon
gets parsed as a nullstmt, which makes the generated AST very strange.

llvm-svn: 39600
This commit is contained in:
Chris Lattner 2007-06-06 05:26:32 +00:00
parent 3d01e4eacb
commit 2e550fea6a
2 changed files with 5 additions and 2 deletions

View File

@ -99,9 +99,10 @@ Parser::StmtResult Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
// ParseExpression does not consume any tokens.
SkipUntil(tok::semi);
return true;
} else {
return Res.Val;
}
// Otherwise, eat the semicolon.
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
return Res.Val;
}
case tok::kw_case: // C99 6.8.1: labeled-statement

View File

@ -348,6 +348,8 @@ DIAG(err_expected_while, ERROR,
"expected 'while' in do/while loop")
DIAG(err_expected_semi_after, ERROR,
"expected ';' after %0")
DIAG(err_expected_semi_after_expr, ERROR,
"expected ';' after expression")
DIAG(err_expected_semi_for, ERROR,
"expected ';' in 'for' statement specifier")
DIAG(err_expected_colon_after, ERROR,