return true;
}
}
- CondType = CondExpr->getType();
-
- // Integral promotions are performed.
- if (CondType->isIntegralType() || CondType->isEnumeralType())
- S.UsualUnaryConversions(CondExpr);
return false;
}
Expr *CondExpr = SS->getCond();
QualType CondTypeBeforePromotion =
GetTypeBeforeIntegralPromotion(CondExpr);
- QualType CondType = CondExpr->getType();
- if (getLangOptions().CPlusPlus) {
- if (CheckCXXSwitchCondition(*this, SwitchLoc, CondExpr))
+ if (getLangOptions().CPlusPlus &&
+ CheckCXXSwitchCondition(*this, SwitchLoc, CondExpr))
return StmtError();
- } else {
- // C99 6.8.4.2p5 - Integer promotions are performed on the
- // controlling expr.
- UsualUnaryConversions(CondExpr);
- }
- CondType = CondExpr->getType();
+
+ QualType CondType = CondExpr->getType();
SS->setCond(CondExpr);
// C++ 6.4.2.p2:
return StmtError();
}
+ UsualUnaryConversions(CondExpr);
+
if (CondTypeBeforePromotion->isBooleanType()) {
// switch(bool_expr) {...} is often a programmer error, e.g.
// switch(n && mask) { ... } // Doh - should be "n & mask".