summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-12-12 06:35:28 +0000
committerChris Lattner <sabre@nondot.org>2008-12-12 06:35:28 +0000
commit10da53c60c3ca7c6d976048c854d27ece193ed89 (patch)
treeaf932f776e4cde1df15619af2fee8c3004db32f9 /clang/lib/Parse/ParseStmt.cpp
parentc0081db332c8ba7c08715ed8699ad957abaa0af3 (diff)
downloadbcm5719-llvm-10da53c60c3ca7c6d976048c854d27ece193ed89.tar.gz
bcm5719-llvm-10da53c60c3ca7c6d976048c854d27ece193ed89.zip
use smarter error recovery for do/while.
llvm-svn: 60933
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r--clang/lib/Parse/ParseStmt.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 45092aa612f..ed4563bb6fd 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -416,7 +416,7 @@ Parser::OwningStmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
/// ParseParenExprOrCondition:
/// [C ] '(' expression ')'
-/// [C++] '(' condition ')'
+/// [C++] '(' condition ')' [not allowed if OnlyAllowCondition=true]
///
/// This function parses and performs error recovery on the specified condition
/// or expression (depending on whether we're in C++ or C mode). This function
@@ -425,7 +425,8 @@ Parser::OwningStmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
/// should try to recover harder. It returns false if the condition is
/// successfully parsed. Note that a successful parse can still have semantic
/// errors in the condition.
-bool Parser::ParseParenExprOrCondition(OwningExprResult &CondExp) {
+bool Parser::ParseParenExprOrCondition(OwningExprResult &CondExp,
+ bool OnlyAllowCondition) {
SourceLocation LParenLoc = ConsumeParen();
if (getLang().CPlusPlus)
@@ -769,8 +770,10 @@ Parser::OwningStmtResult Parser::ParseDoStatement() {
return StmtError();
}
- // Parse the condition.
- OwningExprResult Cond(ParseSimpleParenExpression());
+ // Parse the parenthesized condition.
+ OwningExprResult Cond(Actions);
+ ParseParenExprOrCondition(Cond, true);
+
DoScope.Exit();
if (Cond.isInvalid() || Body.isInvalid())
OpenPOWER on IntegriCloud