Fix a thinko where we weren't always performing unary conversions on the switch condition, fixing PR5612

llvm-svn: 89864
This commit is contained in:
Douglas Gregor 2009-11-25 15:17:36 +00:00
parent 2db07581b7
commit 7fdcbaf291
1 changed files with 4 additions and 4 deletions

View File

@ -501,10 +501,12 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
QualType CondTypeBeforePromotion =
GetTypeBeforeIntegralPromotion(CondExpr);
if (getLangOptions().CPlusPlus &&
if (getLangOptions().CPlusPlus &&
CheckCXXSwitchCondition(*this, SwitchLoc, CondExpr))
return StmtError();
return StmtError();
// C99 6.8.4.2p5 - Integer promotions are performed on the controlling expr.
UsualUnaryConversions(CondExpr);
QualType CondType = CondExpr->getType();
SS->setCond(CondExpr);
@ -522,8 +524,6 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
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".