Improve diagnostics on cases like:

return a ? `  a;

After the expression is diagnosed, skip to the ';', so that the lack of
semicolon is not also diagnosed.

llvm-svn: 38877
This commit is contained in:
Chris Lattner 2006-08-12 16:59:03 +00:00
parent 6c3f05d1d2
commit a0927cecb5
1 changed files with 8 additions and 3 deletions

View File

@ -482,7 +482,9 @@ void Parser::ParseGotoStatement() {
// GNU indirect goto extension. // GNU indirect goto extension.
Diag(Tok, diag::ext_gnu_indirect_goto); Diag(Tok, diag::ext_gnu_indirect_goto);
ConsumeToken(); ConsumeToken();
ParseExpression(); ExprResult R = ParseExpression();
if (R.isInvalid) // Skip to the semicolon, but don't consume it.
SkipUntil(tok::semi, false, true);
} }
} }
@ -493,6 +495,9 @@ void Parser::ParseReturnStatement() {
assert(Tok.getKind() == tok::kw_return && "Not a return stmt!"); assert(Tok.getKind() == tok::kw_return && "Not a return stmt!");
ConsumeToken(); // eat the 'return'. ConsumeToken(); // eat the 'return'.
if (Tok.getKind() != tok::semi) if (Tok.getKind() != tok::semi) {
ParseExpression(); ExprResult R = ParseExpression();
if (R.isInvalid) // Skip to the semicolon, but don't consume it.
SkipUntil(tok::semi, false, true);
}
} }