[cfe-commits] r39600 - in /cfe/cfe/trunk: Parse/ParseStmt.cpp include/clang/Basic/DiagnosticKinds.def
clattner at cs.uiuc.edu
clattner at cs.uiuc.edu
Wed Jul 11 09:46:07 PDT 2007
Author: clattner
Date: Wed Jul 11 11:46:06 2007
New Revision: 39600
URL: http://llvm.org/viewvc/llvm-project?rev=39600&view=rev
Log:
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.
Modified:
cfe/cfe/trunk/Parse/ParseStmt.cpp
cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def
Modified: cfe/cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseStmt.cpp?rev=39600&r1=39599&r2=39600&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseStmt.cpp Wed Jul 11 11:46:06 2007
@@ -99,9 +99,10 @@
// 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
Modified: cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=39600&r1=39599&r2=39600&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Jul 11 11:46:06 2007
@@ -348,6 +348,8 @@
"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,
More information about the cfe-commits
mailing list