OwningStmtResult ParseDefaultStatement();
OwningStmtResult ParseCompoundStatement(bool isStmtExpr = false);
OwningStmtResult ParseCompoundStatementBody(bool isStmtExpr = false);
- bool ParseParenExprOrCondition(OwningExprResult &CondExp);
+ bool ParseParenExprOrCondition(OwningExprResult &CondExp,
+ bool OnlyAllowCondition = false);
OwningStmtResult ParseIfStatement();
OwningStmtResult ParseSwitchStatement();
OwningStmtResult ParseWhileStatement();
/// 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
/// 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)
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())