forked from OSchip/llvm-project
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:
parent
2db07581b7
commit
7fdcbaf291
|
@ -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".
|
||||
|
|
Loading…
Reference in New Issue