[cfe-commits] r89843 - /cfe/trunk/lib/Sema/SemaStmt.cpp
Douglas Gregor
dgregor at apple.com
Tue Nov 24 21:02:22 PST 2009
Author: dgregor
Date: Tue Nov 24 23:02:21 2009
New Revision: 89843
URL: http://llvm.org/viewvc/llvm-project?rev=89843&view=rev
Log:
Refactor ActOnFinishSwitchStmt to simplify it further
Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=89843&r1=89842&r2=89843&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Nov 24 23:02:21 2009
@@ -481,11 +481,6 @@
return true;
}
}
- CondType = CondExpr->getType();
-
- // Integral promotions are performed.
- if (CondType->isIntegralType() || CondType->isEnumeralType())
- S.UsualUnaryConversions(CondExpr);
return false;
}
@@ -504,17 +499,12 @@
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:
@@ -531,6 +521,8 @@
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".
More information about the cfe-commits
mailing list