From a0927cecb579389f8c3f76feec0c3543c730f79f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 12 Aug 2006 16:59:03 +0000 Subject: [PATCH] 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 --- clang/Parse/ParseStmt.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/clang/Parse/ParseStmt.cpp b/clang/Parse/ParseStmt.cpp index 89bbb70cfe66..909af64b644a 100644 --- a/clang/Parse/ParseStmt.cpp +++ b/clang/Parse/ParseStmt.cpp @@ -482,7 +482,9 @@ void Parser::ParseGotoStatement() { // GNU indirect goto extension. Diag(Tok, diag::ext_gnu_indirect_goto); 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!"); ConsumeToken(); // eat the 'return'. - if (Tok.getKind() != tok::semi) - ParseExpression(); + if (Tok.getKind() != tok::semi) { + ExprResult R = ParseExpression(); + if (R.isInvalid) // Skip to the semicolon, but don't consume it. + SkipUntil(tok::semi, false, true); + } }