summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 755d99d54b3..f975b817e00 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14341,7 +14341,7 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *ParenE) {
}
}
-ExprResult Sema::CheckBooleanCondition(Expr *E, SourceLocation Loc) {
+ExprResult Sema::CheckBooleanCondition(SourceLocation Loc, Expr *E) {
DiagnoseAssignmentAsCondition(E);
if (ParenExpr *parenE = dyn_cast<ParenExpr>(E))
DiagnoseEqualityWithExtraParens(parenE);
@@ -14371,12 +14371,26 @@ ExprResult Sema::CheckBooleanCondition(Expr *E, SourceLocation Loc) {
return E;
}
-ExprResult Sema::ActOnBooleanCondition(Scope *S, SourceLocation Loc,
- Expr *SubExpr) {
+Sema::ConditionResult Sema::ActOnCondition(Scope *S, SourceLocation Loc,
+ Expr *SubExpr, ConditionKind CK) {
+ // Empty conditions are valid in for-statements.
if (!SubExpr)
- return ExprError();
+ return ConditionResult();
+
+ ExprResult Cond;
+ switch (CK) {
+ case ConditionKind::Boolean:
+ Cond = CheckBooleanCondition(Loc, SubExpr);
+ break;
+
+ case ConditionKind::Switch:
+ Cond = CheckSwitchCondition(Loc, SubExpr);
+ break;
+ }
+ if (Cond.isInvalid())
+ return ConditionError();
- return CheckBooleanCondition(SubExpr, Loc);
+ return ConditionResult(nullptr, MakeFullExpr(Cond.get(), Loc));
}
namespace {
OpenPOWER on IntegriCloud