diff options
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 45092aa612..ed4563bb6f 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/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()) |