Make sure to call FullExpr before parsing anything else.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72834 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 758b662..f041d7d 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -550,6 +550,8 @@
if (ParseParenExprOrCondition(CondExp))
return StmtError();
+ FullExprArg FullCondExp(Actions.FullExpr(CondExp));
+
// C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
// if the body isn't a compound statement to avoid push/pop in common cases.
@@ -631,7 +633,7 @@
if (ElseStmt.isInvalid())
ElseStmt = Actions.ActOnNullStmt(ElseStmtLoc);
- return Actions.ActOnIfStmt(IfLoc, Actions.FullExpr(CondExp), move(ThenStmt),
+ return Actions.ActOnIfStmt(IfLoc, FullCondExp, move(ThenStmt),
ElseLoc, move(ElseStmt));
}
@@ -752,6 +754,8 @@
if (ParseParenExprOrCondition(Cond))
return StmtError();
+ FullExprArg FullCond(Actions.FullExpr(Cond));
+
// C99 6.8.5p5 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
// if the body isn't a compound statement to avoid push/pop in common cases.
@@ -776,7 +780,7 @@
if (Cond.isInvalid() || Body.isInvalid())
return StmtError();
- return Actions.ActOnWhileStmt(WhileLoc, Actions.FullExpr(Cond), move(Body));
+ return Actions.ActOnWhileStmt(WhileLoc, FullCond, move(Body));
}
/// ParseDoStatement
diff --git a/lib/Sema/SemaTemplateInstantiateStmt.cpp b/lib/Sema/SemaTemplateInstantiateStmt.cpp
index 1f69479..fd349df 100644
--- a/lib/Sema/SemaTemplateInstantiateStmt.cpp
+++ b/lib/Sema/SemaTemplateInstantiateStmt.cpp
@@ -194,6 +194,8 @@
if (Cond.isInvalid())
return SemaRef.StmtError();
+ Sema::FullExprArg FullCond(FullExpr(Cond));
+
// Instantiate the "then" branch.
OwningStmtResult Then = SemaRef.InstantiateStmt(S->getThen(), TemplateArgs);
if (Then.isInvalid())
@@ -204,7 +206,7 @@
if (Else.isInvalid())
return SemaRef.StmtError();
- return SemaRef.ActOnIfStmt(S->getIfLoc(), FullExpr(Cond), move(Then),
+ return SemaRef.ActOnIfStmt(S->getIfLoc(), FullCond, move(Then),
S->getElseLoc(), move(Else));
}
@@ -236,12 +238,14 @@
if (Cond.isInvalid())
return SemaRef.StmtError();
+ Sema::FullExprArg FullCond(FullExpr(Cond));
+
// Instantiate the body
OwningStmtResult Body = SemaRef.InstantiateStmt(S->getBody(), TemplateArgs);
if (Body.isInvalid())
return SemaRef.StmtError();
- return SemaRef.ActOnWhileStmt(S->getWhileLoc(), FullExpr(Cond), move(Body));
+ return SemaRef.ActOnWhileStmt(S->getWhileLoc(), FullCond, move(Body));
}
Sema::OwningStmtResult TemplateStmtInstantiator::VisitDoStmt(DoStmt *S) {